|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sibvisions.util.xml.XmlNode
public final class XmlNode
The XmlNode encapsulates the information of a xml tag.
A node can be a comment, tag or xml. The xml type is the first
node of a xml file. The xml node contains all other sub xml nodes.
| Field Summary | |
|---|---|
static String |
NAME_COMMENT
Constant value for the name of comment nodes. |
static String |
NAME_XMLDECLARATION
Constant value the name of the declaration node ( <? |
static short |
TYPE_ATTRIBUTE
Constant value for the type of attributes. |
static short |
TYPE_COMMENT
Constant value for the type of comment nodes. |
static short |
TYPE_DECLARATION
Constant value for the type of declaration elements. |
static short |
TYPE_TEXT
Constant value for the type of standard nodes. |
| Constructor Summary | |
|---|---|
XmlNode(short pType,
String pName)
Creates a new instance of XmlNode without a parent. |
|
XmlNode(short pType,
String pName,
String pValue)
Creates a new instance of XmlNode without a parent. |
|
XmlNode(short pType,
String pName,
String pValue,
XmlNode pParentNode)
Creates a new instance of XmlNode. |
|
XmlNode(short pType,
String pName,
XmlNode pParentNode)
Creates a new instance of XmlNode with a parent. |
|
XmlNode(String pName)
Creates a new instance of XmlNode
without a parent. |
|
| Method Summary | |
|---|---|
void |
add(XmlNode xmnSub)
Adds a XmlNode as a known sub node, at the end of
the known sub nodes list. |
void |
clearSubNodes()
Clears the list of known sub elements. |
Object |
clone()
|
void |
createXml(OutputStream pOut,
int pIndent)
Create the xml structure based on the current node. |
static XmlNode |
createXmlDeclaration()
Creates the xml declaration tag <? |
int |
getColumnNumber()
Gets the column number behind the start-tag tag. |
int |
getLineNumber()
Gets the line number of the tag occurence. |
String |
getName()
Gets the node name. |
XmlNode |
getNode(String pNodePath)
Gets a specific (sub) XmlNode based on the current
XmlNode. |
int |
getNodeCount(String pNodePath)
Count the elements of a node list. |
List<XmlNode> |
getNodes(String pNodePath)
Gets a list of XmlNodes based on the current
XmlNode. |
XmlNode |
getParent()
Gets the parent XmlNode. |
List<XmlNode> |
getSubNodes()
Gets the list of sub XmlNode elements. |
short |
getType()
Gets the node type. |
String |
getValue()
Gets the node value. |
void |
insert(int iPosition,
XmlNode xmnSub)
Inserts a XmlNode as a known sub node at a defined
position, in the sub node list. |
XmlNode |
insertNode(String pNodePath,
Object pValue)
Inserts a specific (sub) XmlNode at a defined position
based on the current XmlNode. |
boolean |
remove(XmlNode xmnSub)
Remove a sub XmlNode from the known sub nodes. |
XmlNode |
removeNode(String pNodePath)
Removes a specific (sub) XmlNode based on the current
XmlNode. |
XmlNode |
setNode(String pNodePath,
Object pValue)
Sets a specific (sub) XmlNode based on the current
XmlNode. |
void |
setValue(String pValue)
Sets the node value. |
int |
size()
Returns the number of sub elements. |
int |
size(short pType)
Returns the number of sub elements of the defined type. |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final short TYPE_DECLARATION
public static final short TYPE_COMMENT
public static final short TYPE_TEXT
public static final short TYPE_ATTRIBUTE
public static final String NAME_COMMENT
public static final String NAME_XMLDECLARATION
<?xml?>).
| Constructor Detail |
|---|
public XmlNode(String pName)
XmlNode
without a parent. The node type is TYPE_TEXT.
pName - name of the node
public XmlNode(short pType,
String pName)
XmlNode without a parent.
pType - node typepName - name of the node
public XmlNode(short pType,
String pName,
String pValue)
XmlNode without a parent.
pType - node typepValue - value of the nodepName - name of the node
public XmlNode(short pType,
String pName,
XmlNode pParentNode)
XmlNode with a parent.
pType - node typepName - name of the nodepParentNode - parent XmlNode or null
public XmlNode(short pType,
String pName,
String pValue,
XmlNode pParentNode)
XmlNode.
pType - node typepName - name of the nodepValue - value of the nodepParentNode - parent XmlNode or null| Method Detail |
|---|
public String toString()
toString in class Object
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic void add(XmlNode xmnSub)
XmlNode as a known sub node, at the end of
the known sub nodes list.
xmnSub - instance of the sub node
public void insert(int iPosition,
XmlNode xmnSub)
XmlNode as a known sub node at a defined
position, in the sub node list.
iPosition - position at which the specified element is to be insertedxmnSub - instance of the sub nodepublic List<XmlNode> getSubNodes()
XmlNode elements.
public boolean remove(XmlNode xmnSub)
XmlNode from the known sub nodes.
xmnSub - instance of the sub node
public void clearSubNodes()
public XmlNode getParent()
XmlNode.
XmlNode or null if the
node has no parentpublic short getType()
TYPE_ATTRIBUTE, TYPE_COMMENT, TYPE_TEXT, TYPE_DECLARATION)public String getName()
public void setValue(String pValue)
pValue - node valuepublic String getValue()
public XmlNode getNode(String pNodePath)
XmlNode based on the current
XmlNode. To get a special element of a node list, use
brackets to define the element position e.g. /document/nodes(2)
pNodePath - Node path e.g. /document/singlenode
XmlNode is not present or the position is invalid,
otherwise the XmlNode
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed lengthpublic List<XmlNode> getNodes(String pNodePath)
XmlNodes based on the current
XmlNode. If you define a special list element,
you will get a list with only one element instead of all
list elements.
pNodePath - Node path e.g. /document/nodelist or null to get all sub nodes
XmlNode is not present or the position is invalid,
otherwise the list with XmlNodes
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed lengthgetSubNodes()public int getNodeCount(String pNodePath)
pNodePath - Node path e.g. /document/nodelist
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed lengthpublic int size()
size() includes
all element types (comment, attribute, ...).
public int size(short pType)
pType - type of sub elements to count
public XmlNode removeNode(String pNodePath)
XmlNode based on the current
XmlNode.
pNodePath - Node path e.g. /document/singlenode
XmlNode is not present or the position is invalid,
otherwise the removed XmlNode
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed lengthgetNode(String)
public XmlNode setNode(String pNodePath,
Object pValue)
XmlNode based on the current
XmlNode. If the hierarchy is not present, this method
will create the necessary elements.
pNodePath - Node path e.g. /document/singlenodepValue - the pValue can be an instance of XmlNode or any other object. If
the pValue is not an instance of XmlNode then the node value will
be set to pValue.toString(). Otherwise, if pValue is
an instance of XmlNode, the pValue will be added as
sub node to the current node. If there are already sub elements, they will be
removed. The node value will be set to null if pValue == null.
XmlNode is not present or the position is invalid,
otherwise the new XmlNode
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed length
public XmlNode insertNode(String pNodePath,
Object pValue)
XmlNode at a defined position
based on the current XmlNode. This method will not
create the element hierarchy, if not present.
pNodePath - Node path with or without position e.g. /document/singlenode(2). The
pValue will be inserted before the found node or after
the last occurence of the pNodePath, if the position is size() + 1.pValue - the value can be an instance of XmlNode or any other object. If
pValue is not an instance of XmlNode, the node
value will be pValue.toString(). If it is an instance of
XmlNode then the pValue will be inserted as clone,
with all sub elements. The node value will be set to null if pValue == null.
pValue is null,
otherwise the inserted XmlNode
IllegalArgumentException - if the path contains an incomplete or an invalid index
IndexOutOfBoundsException - if the path contains an index which is smaller or
larger than the allowed length
public void createXml(OutputStream pOut,
int pIndent)
throws IOException
pOut - stream for writing the xml structurepIndent - indentation for sub nodes
IOException - if the output operation to pOut fails or
the encoding UTF-8 is not usablepublic static XmlNode createXmlDeclaration()
public int getLineNumber()
public int getColumnNumber()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||