Class NexusTreeNode

java.lang.Object
gda.data.nexus.tree.NexusTreeNode
All Implemented Interfaces:
INexusTree, Serializable, Iterable<INexusTree>
Direct Known Subclasses:
NexusTreeScanDataLeaf, NexusTreeTopNode

public class NexusTreeNode extends Object implements INexusTree, Serializable
Class to represent a Nexus Group - a child is either a DATASET or an ATTRIBUTE
See Also:
  • Field Details

    • groupData

      public final NexusGroupData groupData
      The actual data read from the element
    • name

      public final String name
      The name of the element read from the Nexus file
    • nxClass

      public final String nxClass
      The class of the element
  • Constructor Details

    • NexusTreeNode

      public NexusTreeNode(String name, String nxClass, INexusTree parentNode, NexusGroupData groupData)
      Parameters:
      name -
      nxClass -
      parentNode -
      groupData -
    • NexusTreeNode

      public NexusTreeNode(String name, String nxClass, INexusTree parentNode)
      Parameters:
      name -
      nxClass -
      parentNode -
  • Method Details

    • getName

      public String getName()
      Specified by:
      getName in interface INexusTree
      Returns:
      The name of the element as stored as a group name in Nexus
    • getNxClass

      public String getNxClass()
      Specified by:
      getNxClass in interface INexusTree
      Returns:
      The class of the element as stored as a group class in Nexus
    • setParentNode

      public void setParentNode(INexusTree parentNode)
      Specified by:
      setParentNode in interface INexusTree
      Parameters:
      parentNode -
    • getParentNode

      public INexusTree getParentNode()
      Specified by:
      getParentNode in interface INexusTree
      Returns:
      The node of which the current object is a child.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • toXML

      public String toXML(boolean newlineAfterEach, boolean dataAsString)
      Specified by:
      toXML in interface INexusTree
      Parameters:
      newlineAfterEach - - if true the output is interspersed with newlines to make it more humanly readable
      dataAsString - - - if true data array are written as string. NX_CHAR data is always shown as a string
      Returns:
      A string that represents the tree in xml
    • toXMLbegin

      public StringBuilder toXMLbegin(boolean newlineAfterEach, boolean dataAsString)
      Specified by:
      toXMLbegin in interface INexusTree
      Parameters:
      newlineAfterEach -
      dataAsString -
      Returns:
      xml representation of the node and children up to final invalid input: '<'/ > item
    • toXMLend

      public StringBuilder toXMLend(boolean newlineAfterEach, boolean dataAsString)
      Specified by:
      toXMLend in interface INexusTree
      Parameters:
      newlineAfterEach -
      dataAsString -
      Returns:
      final invalid input: '<'/ > part of an xml representation of the node and children
    • getData

      public NexusGroupData getData()
      Specified by:
      getData in interface INexusTree
      Returns:
      Nexus data associated with the node - null if not present
    • getNumberOfChildNodes

      public int getNumberOfChildNodes()
      Specified by:
      getNumberOfChildNodes in interface INexusTree
      Returns:
      List of child nodes
    • addChildNode

      public void addChildNode(INexusTree e)
      Description copied from interface: INexusTree
      Add a tree as a child node of the current item
      Specified by:
      addChildNode in interface INexusTree
      Parameters:
      e -
    • removeChildNode

      public void removeChildNode(INexusTree e)
      Description copied from interface: INexusTree
      Remove tree from collection of child nodes of the current item
      Specified by:
      removeChildNode in interface INexusTree
      Parameters:
      e -
    • getChildNode

      public INexusTree getChildNode(int index)
      Description copied from interface: INexusTree
      Get child tree node at position index
      Specified by:
      getChildNode in interface INexusTree
      Parameters:
      index - - between 0 and getNumberOfChildNodes-1
      Returns:
      child node of the current item
    • getChildCount

      public int getChildCount()
    • setPriority

      public void setPriority()
      Description copied from interface: INexusTree
      Set that this NexusTree should be prioritised over its siblings Allows for setting the primary field of the NexusObjectProvider that returns this tree
      Specified by:
      setPriority in interface INexusTree
    • setPrioritised

      public void setPrioritised(INexusTree child)
      Description copied from interface: INexusTree
      Set that the param tree, which should be a child of this node, should be prioritised over its siblings.
      Specified by:
      setPrioritised in interface INexusTree
    • priorityComparator

      protected Comparator<INexusTree> priorityComparator(INexusTree priority)
    • toText

      public String toText(String prefix, String keyValueSep, String dataItemSep, String nodeSep)
      Specified by:
      toText in interface INexusTree
      Parameters:
      prefix - Text that begins each line e.g. ""
      keyValueSep - Text between key and value e.g. ":"
      dataItemSep - Text between key and data e.g. "="
      nodeSep - Text between nodes e.g. "|"
      Returns:
      A string that represents the tree in text format e.g. NXextry:NXinstrument:name=
    • toText

      public String toText(String prefix, String keyValueSep, String dataItemSep, String nodeSep, boolean includeData)
      Specified by:
      toText in interface INexusTree
      Parameters:
      prefix - Text that begins each line e.g. ""
      keyValueSep - Text between key and value e.g. ":"
      dataItemSep - Text between key and data e.g. "="
      nodeSep - Text between nodes e.g. "|"
      includeData - Whether to include the data in the output
      Returns:
      A string that represents the tree in text format e.g. NXextry:NXinstrument:name=
    • iterator

      public Iterator<INexusTree> iterator()
      Specified by:
      iterator in interface Iterable<INexusTree>
    • findNode

      public NexusTreeNode findNode(String nodeName)
      Recursively find node depth-first
      Parameters:
      nodeName -
      Returns:
      node with given name
    • getNodePath

      public String getNodePath()
      Specified by:
      getNodePath in interface INexusTree
      Returns:
      path of node
    • getNodePathWithClasses

      public String getNodePathWithClasses()
      Specified by:
      getNodePathWithClasses in interface INexusTree
      Returns:
      unique id of item in the tree - name_of_top/class_of_top/.../name/class
    • getNode

      public INexusTree getNode(String path)
      Specified by:
      getNode in interface INexusTree
      Parameters:
      path -
      Returns:
      node with given path
    • getAttribute

      public Serializable getAttribute(String name)
      Get an attribute of current node
      Specified by:
      getAttribute in interface INexusTree
      Parameters:
      name -
      Returns:
      an attribute with given name or null if not found
    • getAttributes

      public Map<String,Serializable> getAttributes()
      Get all attributes of current node, never null.
      Specified by:
      getAttributes in interface INexusTree
      Returns:
      a HashMap of attributes
    • sort

      public void sort(Comparator<INexusTree> comparator)
      Specified by:
      sort in interface INexusTree
      Parameters:
      comparator -
    • getChildNode

      public INexusTree getChildNode(String name, String className)
      Description copied from interface: INexusTree
      Get child tree node with given name and class
      Specified by:
      getChildNode in interface INexusTree
      Parameters:
      name -
      className -
      Returns:
      child node of the current item
    • setIsPointDependent

      public void setIsPointDependent(boolean val)
    • isPointDependent

      public boolean isPointDependent()
      Specified by:
      isPointDependent in interface INexusTree
      Returns:
      true if the data can vary during a scan
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object