Class SCPTreeRecord

java.lang.Object
com.pixelmed.scpecg.SCPTreeRecord
All Implemented Interfaces:
Comparable, TreeNode

public class SCPTreeRecord extends Object implements Comparable, TreeNode

Instances of the SCPTreeRecord class represent nodes in a tree of the SCPTree class, which in turn is used by the SCPTreeBrowser class.

Each record represents a single name-value pair, with the value potentially empty (e.g. a container).

  • Constructor Details

    • SCPTreeRecord

      public SCPTreeRecord(SCPTreeRecord parent, String name, String value)

      Construct a record for a name-value pair linking to the specified parent.

      Adds the new node to the children of the parent node, keeping them sorted.

      Parameters:
      parent - parent record
      name - the String name of this node (by which they are sorted)
      value - the String value of this node
    • SCPTreeRecord

      public SCPTreeRecord(SCPTreeRecord parent, String name)

      Construct a record for a named container, linking to the specied parent.

      Adds the new node to the children of the parent node, keeping them sorted.

      Parameters:
      parent - parent record
      name - the String name of this node (by which they are sorted)
    • SCPTreeRecord

      public SCPTreeRecord(SCPTreeRecord parent, int iname, String value)

      Construct a record for a name-value pair linking to the specified parent.

      Adds the new node to the children of the parent node, keeping them sorted.

      Parameters:
      parent - parent record
      iname - the numeric name of this node (by which they are sorted)
      value - the String value of this node
    • SCPTreeRecord

      public SCPTreeRecord(SCPTreeRecord parent, int iname)

      Construct a record for a named container, linking to the specied parent.

      Adds the new node to the children of the parent node, keeping them sorted.

      Parameters:
      parent - parent record
      iname - the numeric name of this node (by which they are sorted)
  • Method Details

    • toString

      public String toString()

      Dump the record as a string.

      Overrides:
      toString in class Object
      Returns:
      name and value as a string
    • compareTo

      public int compareTo(Object o)
      Specified by:
      compareTo in interface Comparable
      Parameters:
      o -
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
      Parameters:
      o -
    • getParent

      public TreeNode getParent()

      Returns the parent node of this node.

      Specified by:
      getParent in interface TreeNode
      Returns:
      the parent node, or null if the root
    • getChildAt

      public TreeNode getChildAt(int index)

      Returns the child at the specified index.

      Specified by:
      getChildAt in interface TreeNode
      Parameters:
      index - the index of the child to be returned, numbered from 0
      Returns:
      the child TreeNode at the specified index
    • getIndex

      public int getIndex(TreeNode child)

      Returns the index of the specified child from amongst this node's children, if present.

      Specified by:
      getIndex in interface TreeNode
      Parameters:
      child - the child to search for amongst this node's children
      Returns:
      the index of the child, or -1 if not present
    • getAllowsChildren

      public boolean getAllowsChildren()

      Always returns true, since children may always be added.

      Specified by:
      getAllowsChildren in interface TreeNode
      Returns:
      always true
    • isLeaf

      public boolean isLeaf()

      Returns true if the receiver is a leaf (has no children).

      Specified by:
      isLeaf in interface TreeNode
      Returns:
      true if the receiver is a leaf
    • getChildCount

      public int getChildCount()

      Return the number of children that this node contains.

      Specified by:
      getChildCount in interface TreeNode
      Returns:
      the number of children, 0 if none
    • children

      public Enumeration children()

      Returns the children of this node as an Enumeration.

      Specified by:
      children in interface TreeNode
      Returns:
      the children of this node