📄 syncdata.java
字号:
/**
* @(#)$RCSfile: SyncData.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 java.io.*;
import com.reaxion.tequila.syncml.xml.IXMLNode;
import com.reaxion.tequila.syncml.util.*;
/**
* <!ELEMENT Data (#PCDATA)>
* <p>
* <pre>
* <Data>String/XML</Data>
* </pre>
*
* @version $1.0$
* @author Oleg A. Oksyuk
*/
public class SyncData extends SyncElement
{
private IXMLNode child;
private String data;
public SyncData(IXMLNode el)
{
super(el);
Enumeration children = getNode().getChildren();
if (children.hasMoreElements())
{
child = (IXMLNode) children.nextElement();
}
else
{
data = el.getTextTrim();
}
}
public SyncData(String aData, IXMLNode aChild)
{
super(SyncCommandNames.DATA);
data = aData;
child = aChild;
}
public static SyncData createFromChild(Object aChild)
{
if (aChild instanceof String)
{
return new SyncData((String) aChild, null);
}
else
{
return new SyncData(null, (IXMLNode) aChild);
}
}
public String getData()
{
return data;
}
public IXMLNode getChildNode()
{
return child;
}
public Object getAnyData()
{
if (child != null)
{
return child;
}
else
{
return data;
}
}
public Object getElData(int level)
{
Object anyData = getAnyData();
if (null == anyData)
{
return null;
}
else if (anyData instanceof String)
{
return SyncElement.getTabs(level+1).append(anyData+"\r\n");
}
else if (anyData instanceof IXMLNode)
{
return ((IXMLNode) anyData).getXml();
}
else
{
throw new InternalException("Wrong data in SyncData");
}
}
}
/* -----------------------------------------------------------------------------
* Change log:
* -----------------------------------------------------------------------------
* $Log: SyncData.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.1 2001/07/24 13:08:17 OlegO
* no message
*
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -