Package com.prowidesoftware.swift.model
Class MxNode
- java.lang.Object
-
- com.prowidesoftware.swift.model.MxNode
-
public class MxNode extends java.lang.ObjectThis class represents a node element within a tree of MX message. It is basically a generic XML node structure used to provide basic parsing functionality.
- Since:
- 7.6
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringPATH_SEPARATOR
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAttribute(java.lang.String name, java.lang.String value)Adds the given attribute to the node.java.util.List<MxNode>find(java.lang.String path)Given a basic path, find all nodes matching the path parameter.MxNodefindFirst(java.lang.String path)Given a basic path, find the first instance of a node matching the path parameter.MxNodefindFirstByName(java.lang.String name)Traverse the tree from this node looking for the first node matching the given name.java.lang.StringgetAttribute(java.lang.String name)java.util.Map<java.lang.String,java.lang.String>getAttributes()java.util.List<MxNode>getChildren()MxNodegetParent()MxNodegetRoot()java.lang.StringgetValue()booleanisEmpty()static MxNodeparse(java.lang.String xml)Parses the complete message content into anMxNodetree structure.java.lang.Stringpath()Builds this node's path up to the root elementvoidprint()Prints this node tree structure in standard outputvoidremoveEmptyElements()Traverses the XML tree from this node down, removing all leaves with empty attributes and empty content.voidsetAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)voidsetValue(java.lang.String value)java.lang.StringsinglePathValue(java.lang.String path)java.lang.StringtoString()
-
-
-
Field Detail
-
PATH_SEPARATOR
public static final transient java.lang.String PATH_SEPARATOR
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
MxNode
public MxNode()
-
MxNode
public MxNode(MxNode parent, java.lang.String localName)
-
-
Method Detail
-
parse
public static MxNode parse(java.lang.String xml)
Parses the complete message content into anMxNodetree structure.- Since:
- 9.1.2
-
singlePathValue
public java.lang.String singlePathValue(java.lang.String path)
-
findFirst
public MxNode findFirst(java.lang.String path)
Given a basic path, find the first instance of a node matching the path parameter.
If the path starts with '/' it will search from the root element, else it will search from this node.
- Parameters:
path- absolute or relative path to find- Returns:
- found node or null
- Since:
- 7.7
-
find
public java.util.List<MxNode> find(java.lang.String path)
Given a basic path, find all nodes matching the path parameter.
If the path starts with '/' it will search from the root element, else it will search from this node.
- Parameters:
path- absolute or relative path to find- Returns:
- found node or null
- Since:
- 7.7
-
getRoot
public MxNode getRoot()
-
getValue
public java.lang.String getValue()
-
setValue
public void setValue(java.lang.String value)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
print
public void print()
Prints this node tree structure in standard output
-
getParent
public MxNode getParent()
-
findFirstByName
public MxNode findFirstByName(java.lang.String name)
Traverse the tree from this node looking for the first node matching the given name.- Parameters:
name- a node name to find- Returns:
- the found node or null if not found
- Since:
- 7.7
-
getChildren
public java.util.List<MxNode> getChildren()
- Returns:
- returns this node children nodes
- Since:
- 7.8
-
getAttributes
public java.util.Map<java.lang.String,java.lang.String> getAttributes()
- Since:
- 7.8
-
setAttributes
public void setAttributes(java.util.Map<java.lang.String,java.lang.String> attributes)
- Since:
- 7.8
-
addAttribute
public void addAttribute(java.lang.String name, java.lang.String value)Adds the given attribute to the node. If an attribute already exist with the same local name, its value is updated.- Since:
- 7.8
-
getAttribute
public java.lang.String getAttribute(java.lang.String name)
- Returns:
- found attribute value or null if not found or node does not contain attributes
- Since:
- 7.8
-
path
public java.lang.String path()
Builds this node's path up to the root element- Returns:
- the absolute path of the node in the form /foo/foo/foo
- Since:
- 7.8
-
removeEmptyElements
public void removeEmptyElements()
Traverses the XML tree from this node down, removing all leaves with empty attributes and empty content.- Since:
- 9.5.7
-
isEmpty
public boolean isEmpty()
- Returns:
- true if this node has no value, no attributes and no children
- Since:
- 9.5.7
-
-