Package gda.data.nexus.tree
Class NexusTreeNode
java.lang.Object
gda.data.nexus.tree.NexusTreeNode
- All Implemented Interfaces:
INexusTree,Serializable,Iterable<INexusTree>
- Direct Known Subclasses:
NexusTreeScanDataLeaf,NexusTreeTopNode
Class to represent a Nexus Group - a child is either a DATASET or an ATTRIBUTE
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionNexusTreeNode(String name, String nxClass, INexusTree parentNode) NexusTreeNode(String name, String nxClass, INexusTree parentNode, NexusGroupData groupData) -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a tree as a child node of the current itembooleanRecursively find node depth-firstgetAttribute(String name) Get an attribute of current nodeGet all attributes of current node, nevernull.intgetChildNode(int index) Get child tree node at position indexgetChildNode(String name, String className) Get child tree node with given name and classgetData()getName()intinthashCode()booleaniterator()protected Comparator<INexusTree> priorityComparator(INexusTree priority) voidRemove tree from collection of child nodes of the current itemvoidsetIsPointDependent(boolean val) voidsetParentNode(INexusTree parentNode) voidsetPrioritised(INexusTree child) Set that the param tree, which should be a child of this node, should be prioritised over its siblings.voidSet that this NexusTree should be prioritised over its siblings Allows for setting the primary field of the NexusObjectProvider that returns this treevoidsort(Comparator<INexusTree> comparator) toString()toXML(boolean newlineAfterEach, boolean dataAsString) toXMLbegin(boolean newlineAfterEach, boolean dataAsString) toXMLend(boolean newlineAfterEach, boolean dataAsString) Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
groupData
The actual data read from the element -
name
The name of the element read from the Nexus file -
nxClass
The class of the element
-
-
Constructor Details
-
NexusTreeNode
- Parameters:
name-nxClass-parentNode-groupData-
-
NexusTreeNode
- Parameters:
name-nxClass-parentNode-
-
-
Method Details
-
getName
- Specified by:
getNamein interfaceINexusTree- Returns:
- The name of the element as stored as a group name in Nexus
-
getNxClass
- Specified by:
getNxClassin interfaceINexusTree- Returns:
- The class of the element as stored as a group class in Nexus
-
setParentNode
- Specified by:
setParentNodein interfaceINexusTree- Parameters:
parentNode-
-
getParentNode
- Specified by:
getParentNodein interfaceINexusTree- Returns:
- The node of which the current object is a child.
-
toString
-
toXML
- Specified by:
toXMLin interfaceINexusTree- Parameters:
newlineAfterEach- - if true the output is interspersed with newlines to make it more humanly readabledataAsString- - - 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
- Specified by:
toXMLbeginin interfaceINexusTree- Parameters:
newlineAfterEach-dataAsString-- Returns:
- xml representation of the node and children up to final invalid input: '<'/ > item
-
toXMLend
- Specified by:
toXMLendin interfaceINexusTree- Parameters:
newlineAfterEach-dataAsString-- Returns:
- final invalid input: '<'/ > part of an xml representation of the node and children
-
getData
- Specified by:
getDatain interfaceINexusTree- Returns:
- Nexus data associated with the node - null if not present
-
getNumberOfChildNodes
public int getNumberOfChildNodes()- Specified by:
getNumberOfChildNodesin interfaceINexusTree- Returns:
- List of child nodes
-
addChildNode
Description copied from interface:INexusTreeAdd a tree as a child node of the current item- Specified by:
addChildNodein interfaceINexusTree- Parameters:
e-
-
removeChildNode
Description copied from interface:INexusTreeRemove tree from collection of child nodes of the current item- Specified by:
removeChildNodein interfaceINexusTree- Parameters:
e-
-
getChildNode
Description copied from interface:INexusTreeGet child tree node at position index- Specified by:
getChildNodein interfaceINexusTree- 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:INexusTreeSet that this NexusTree should be prioritised over its siblings Allows for setting the primary field of the NexusObjectProvider that returns this tree- Specified by:
setPriorityin interfaceINexusTree
-
setPrioritised
Description copied from interface:INexusTreeSet that the param tree, which should be a child of this node, should be prioritised over its siblings.- Specified by:
setPrioritisedin interfaceINexusTree
-
priorityComparator
-
toText
- Specified by:
toTextin interfaceINexusTree- 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:
toTextin interfaceINexusTree- 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
- Specified by:
iteratorin interfaceIterable<INexusTree>
-
findNode
Recursively find node depth-first- Parameters:
nodeName-- Returns:
- node with given name
-
getNodePath
- Specified by:
getNodePathin interfaceINexusTree- Returns:
- path of node
-
getNodePathWithClasses
- Specified by:
getNodePathWithClassesin interfaceINexusTree- Returns:
- unique id of item in the tree - name_of_top/class_of_top/.../name/class
-
getNode
- Specified by:
getNodein interfaceINexusTree- Parameters:
path-- Returns:
- node with given path
-
getAttribute
Get an attribute of current node- Specified by:
getAttributein interfaceINexusTree- Parameters:
name-- Returns:
- an attribute with given name or null if not found
-
getAttributes
Get all attributes of current node, nevernull.- Specified by:
getAttributesin interfaceINexusTree- Returns:
- a HashMap of attributes
-
sort
- Specified by:
sortin interfaceINexusTree- Parameters:
comparator-
-
getChildNode
Description copied from interface:INexusTreeGet child tree node with given name and class- Specified by:
getChildNodein interfaceINexusTree- Parameters:
name-className-- Returns:
- child node of the current item
-
setIsPointDependent
public void setIsPointDependent(boolean val) -
isPointDependent
public boolean isPointDependent()- Specified by:
isPointDependentin interfaceINexusTree- Returns:
- true if the data can vary during a scan
-
hashCode
public int hashCode() -
equals
-