⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 syncstatus.java

📁 j2me sip客户端程序源码 提供了J2ME中SIP协议开发样例源码
💻 JAVA
字号:
/**
 * @(#)$RCSfile: SyncStatus.java,v $            $Revision: 1.2 $
 *
 * ====================================================================
 * Copyright 2001, Reaxion Corp.,
 * 11418 105th PL NE, Kirkland, WA, 98033, USA
 * All rights reserved.
 * ====================================================================
 *
 * The contents of this file are subject to the Mozilla Public
 * License Version 1.1 (the "License"); you may not use this file
 * except in compliance with the License. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS
 * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
 * implied. See the License for the specific language governing
 * rights and limitations under the License.
 *
 * The Original Code is the Tequila SyncML.
 *
 * The Initial Developer of the Original Code is Reaxion Corp.
 * All Rights Reserved.
 */
package com.reaxion.tequila.syncml;

import com.reaxion.tequila.syncml.xml.IXMLNode;

/**
 * <!ELEMENT Status (CmdID, MsgRef, CmdRef, Cmd, TargetRef?, SourceRef?, Data)>
 * <p>
 * <pre>
 *  &lt;Status&gt;
 *    &lt;CmdID&gt;CmdId (int&lt;/CmdID&gt;
 *    &lt;MsgRef&gt;MsgRef (int&lt;/MsgRef&gt;
 *    &lt;CmdRef&gt;CmdRef (int&lt;/CmdRef&gt;
 *    &lt;Cmd&gt;"Alert"/"Sync"/"Add"/"Delete"/"Put"/"Replace"&lt;/Cmd&gt;
 *      &lt;TargetRef&gt;URL/DB Name/XPath&lt;/TargetRef&gt;
 *      &lt;SourceRef&gt;URL/DB Name/XPath&lt;/SourceRef&gt;
 *    &lt;Data&gt;Status Code (see sync.SyncStatuses) &lt;/Data&gt;
 *  &lt;/Status&gt;
 * </pre>
 *
 * @see       sync.SyncStatuses
 * @version   $1.0$
 * @author    Oleg A. Oksyuk
 */
public class SyncStatus extends SyncCmdIdOwner
{

    private SyncMsgRef msgRef;
    private SyncCmdRef cmdRef;
    private SyncCmd cmd;
    private SyncTargetRef targetRef;
    private SyncSourceRef sourceRef;
    private SyncData data;

    public SyncStatus(IXMLNode el)
    {
        super(el);
        msgRef = new SyncMsgRef(el.getChild(SyncCommandNames.MSG_REF));
        cmdRef = new SyncCmdRef(el.getChild(SyncCommandNames.CMD_REF));
        cmd = new SyncCmd(el.getChild(SyncCommandNames.CMD));
        IXMLNode child = el.getChild(SyncCommandNames.TARGET_REF);
        targetRef = (child != null) ? new SyncTargetRef(child) : null;
        child = el.getChild(SyncCommandNames.SOURCE_REF);
        sourceRef = (child != null) ? new SyncSourceRef(child) : null;
        data = new SyncData(el.getChild(SyncCommandNames.DATA));
    }

    public SyncStatus(
            SyncCmdId pCmdId, SyncMsgRef pMsgRef, SyncCmdRef pCmdRef,
            SyncCmd pCmd, SyncTargetRef pTargetRef, SyncSourceRef pSourceRef,
            SyncData pData)
    {
        super(SyncCommandNames.STATUS, pCmdId);
        msgRef = pMsgRef;
        cmdRef = pCmdRef;
        cmd = pCmd;
        targetRef = pTargetRef;
        sourceRef = pSourceRef;
        data = pData;
    }

    public SyncStatus(
            String pMsgRef, String pCmdRef,
            String pCmd, String pTargetRef, String pSourceRef,
            int alertStatus)
    {
        this(SyncCommandNames.DEF.EMPTY_CMD_ID,
            new SyncMsgRef(pMsgRef), new SyncCmdRef(pCmdRef),
            new SyncCmd(pCmd), new SyncTargetRef(pTargetRef), new SyncSourceRef(pSourceRef),
            new SyncData(""+alertStatus, null));
    }

    public SyncMsgRef getMsgRef()
    {
        return msgRef;
    }
    public SyncCmdRef getCmdRef()
    {
        return cmdRef;
    }
    public SyncCmd getCmd()
    {
        return cmd;
    }
    public SyncTargetRef getTargetRef()
    {
        return targetRef;
    }
    public SyncSourceRef getSourceRef()
    {
        return sourceRef;
    }
    public SyncData getData()
    {
        return data;
    }

    public Object getElData(int level)
    {
		StringBuffer res = new StringBuffer();
        res.append(getCmdId().toString(level+1));
        res.append(msgRef.toString(level+1));
        res.append(cmdRef.toString(level+1));
        res.append(cmd.toString(level+1));
        if (targetRef != null)
        {
            res.append(targetRef.toString(level+1));
        }
        if (sourceRef != null)
        {
            res.append(sourceRef.toString(level+1));
        }
        res.append(data.toString(level+1));
		return res;
    }

    public short getCode()
    {
        return Short.parseShort(data.getData());
    }
}

/* -----------------------------------------------------------------------------
 * Change log:
 * -----------------------------------------------------------------------------
 * $Log: SyncStatus.java,v $
 * Revision 1.2  2001/10/17 15:27:43  OlegO
 * changed comments for better javadoc
 *
 * Revision 1.1.1.1  2001/10/11 13:13:32  OlegO
 * no message
 *
 * Revision 1.1  2001/07/24 13:08:17  OlegO
 * no message
 *
 */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -