📄 syncpackage.java
字号:
/**
* @(#)$RCSfile: SyncPackage.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 java.util.*;
import com.reaxion.tequila.syncml.xml.IXMLNode;
import com.reaxion.tequila.syncml.sync.ISyncServer;
/**
* <!ELEMENT SyncML (SyncHdr, SyncBody)>
* <p>
* <pre>
* <SyncML>
* <SyncHdr>
* ...
* </SyncHdr>
* <SyncBody>
* ...
* </SyncBody>
* </SyncML>
* </pre>
*
* @version $1.0$
* @author Oleg A. Oksyuk
*/
public class SyncPackage extends SyncElement
{
private SyncHeader header;
private SyncBody body;
public SyncPackage(IXMLNode el)
{
super(el);
header = new SyncHeader(el.getChild(SyncCommandNames.HDR));
body = new SyncBody(el.getChild(SyncCommandNames.BODY));
}
public SyncPackage(SyncHeader h, SyncBody b)
{
super(SyncCommandNames.SYNCML);
header = h;
body = b;
}
public void setIds()
{
int nextCmdId = 1;
Enumeration sEn, en = body.getCommands();
SyncCmdIdOwner command;
SyncSync sync;
SyncPut put;
SyncSyncCommand syncCommand;
while (en.hasMoreElements())
{
command = (SyncCmdIdOwner) en.nextElement();
command.setCmdId(new SyncCmdId(""+nextCmdId));
++nextCmdId;
if (SyncCommandNames.SYNC.equals(command.getName()))
{
sync = (SyncSync) command;
put = sync.getPut();
if (null != put)
{
put.setCmdId(new SyncCmdId(""+nextCmdId));
++nextCmdId;
}
sEn = sync.getCommands();
while (sEn.hasMoreElements())
{
syncCommand = (SyncSyncCommand) sEn.nextElement();
syncCommand.setCmdId(new SyncCmdId(""+nextCmdId));
++nextCmdId;
}
}
}
}
/* public boolean isResponceExpected() {
boolean onlyStatuses = true;
boolean onlyNoResponce = true;
boolean alertExists = false;
Enumeration commands = body.getCommands();
SyncCmdIdOwner command;
SyncTargetOwner targetOwner;
while (commands.hasMoreElements()) {
command = (SyncCmdIdOwner) commands.nextElement();
if (!SyncCommandNames.STATUS.equals(command.getName())) {
onlyStatuses = false;
if (onlyNoResponce) {
targetOwner = (SyncTargetOwner) command;
if ((ISyncServer.HDR_RESP_NEEDED) && (!targetOwner.isNoResp())) {
onlyNoResponce = false;
}
}
if (!alertExists) {
if (SyncCommandNames.ALERT.equals(command.getName())) {
alertExists = true;
}
}
}
}
if (onlyStatuses) {
return false;
} else if ((onlyNoResponce) && (!alertExists)) {
return false;
} else {
return true;
}
}
*/
private boolean isOnlyStatuses()
{
Enumeration commands = body.getCommands();
SyncCmdIdOwner command;
while (commands.hasMoreElements())
{
command = (SyncCmdIdOwner) commands.nextElement();
if (!SyncCommandNames.STATUS.equals(command.getName()))
{
return false;
}
}
return true;
}
public boolean isEmpty()
{
Enumeration commands = body.getCommands();
if (commands.hasMoreElements())
{
SyncCmdIdOwner command = (SyncCmdIdOwner) commands.nextElement();
if (!SyncCommandNames.STATUS.equals(command.getName()))
{
return false;
}
SyncStatus status = (SyncStatus) command;
if (!SyncCommandNames.HDR.equals(status.getCmd().getCmd()))
{
return false;
}
if (commands.hasMoreElements())
{
return false;
}
}
return true;
}
public SyncHeader getHeader()
{
return header;
}
public SyncBody getBody()
{
return body;
}
public Object getElData(int level)
{
StringBuffer res = new StringBuffer();
res.append(header.toString(level+1));
res.append(body.toString(level+1));
return res;
}
private void setCmdId(SyncCmdIdOwner command)
{
}
}
/* -----------------------------------------------------------------------------
* Change log:
* -----------------------------------------------------------------------------
* $Log: SyncPackage.java,v $
* Revision 1.2 2001/10/17 15:27:42 OlegO
* changed comments for better javadoc
*
* Revision 1.1.1.1 2001/10/11 13:13:32 OlegO
* no message
*
* Revision 1.2 2001/07/27 07:41:18 OlegO
* no message
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -