Class MxNode


  • public class MxNode
    extends java.lang.Object

    This 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.String PATH_SEPARATOR  
    • Constructor Summary

      Constructors 
      Constructor Description
      MxNode()  
      MxNode​(MxNode parent, java.lang.String localName)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addAttribute​(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.
      MxNode findFirst​(java.lang.String path)
      Given a basic path, find the first instance of a node matching the path parameter.
      MxNode findFirstByName​(java.lang.String name)
      Traverse the tree from this node looking for the first node matching the given name.
      java.lang.String getAttribute​(java.lang.String name)  
      java.util.Map<java.lang.String,​java.lang.String> getAttributes()  
      java.util.List<MxNode> getChildren()  
      MxNode getParent()  
      MxNode getRoot()  
      java.lang.String getValue()  
      static MxNode parse​(java.lang.String xml)
      Parses the complete message content into an MxNode tree structure.
      java.lang.String path()
      Builds this node's path up to the root element
      void print()
      Prints this node tree structure in standard output
      void setAttributes​(java.util.Map<java.lang.String,​java.lang.String> attributes)  
      void setValue​(java.lang.String value)  
      java.lang.String singlePathValue​(java.lang.String path)  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 an MxNode tree 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:
        toString in class java.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