📄 syncelement.java
字号:
/**
* @(#)$RCSfile: SyncElement.java,v $ $Revision: 1.3 $
*
* ====================================================================
* 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;
/**
* Parent class for each Sync<...> class.
* <p>
* <pre>
* <tagName>...</tagName>
* </pre>
*
* @version $1.0$
* @author Oleg A. Oksyuk
*/
public abstract class SyncElement
{
public abstract Object getElData(int level);
//Tag name
private String name;
//XML tag represenatation
private IXMLNode node;
public SyncElement(IXMLNode el)
{
node = el;
name = node.getName();
}
public SyncElement(String pName)
{
name = pName;
}
public IXMLNode getNode()
{
return node;
}
public String getName()
{
return name;
}
public Object getElData()
{
return getElData(0);
}
public String toString()
{
return toString(0);
}
public String toString(int level)
{
Object data = getElData(level);
if ((null == data) || (0 == data.toString().trim().length()))
{
if (this instanceof SyncEmptyElement)
{
StringBuffer res = getTabs(level);
res.append("<");
res.append(name);
res.append("/>\r\n");
return res.toString();
}
else
{
return "";
}
}
return new String(addTags(getElData(level), name, level));
}
private static StringBuffer addTags(Object data, String tag, int level)
{
StringBuffer res = getTabs(level);
res.append("<");
res.append(tag);
res.append(">\r\n");
res.append(data);
res.append(getTabs(level));
res.append("</");
res.append(tag);
res.append(">\r\n");
return res;
}
public static StringBuffer getTabs(int n)
{
StringBuffer res = new StringBuffer();
for (int i = 0 ; i < n ; i++)
{
res.append("\t");
}
return res;
}
}
/* -----------------------------------------------------------------------------
* Change log:
* -----------------------------------------------------------------------------
* $Log: SyncElement.java,v $
* Revision 1.3 2001/11/16 10:54:39 OlegO
* no message
*
* 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 + -