Class SCPTreeRecord
- java.lang.Object
-
- com.pixelmed.scpecg.SCPTreeRecord
-
- All Implemented Interfaces:
java.lang.Comparable
,javax.swing.tree.TreeNode
public class SCPTreeRecord extends java.lang.Object implements java.lang.Comparable, javax.swing.tree.TreeNode
Instances of the
SCPTreeRecord
class represent nodes in a tree of theSCPTree
class, which in turn is used by theSCPTreeBrowser
class.Each record represents a single name-value pair, with the value potentially empty (e.g. a container).
-
-
Constructor Summary
Constructors Constructor Description SCPTreeRecord(SCPTreeRecord parent, int iname)
Construct a record for a named container, linking to the specied parent.SCPTreeRecord(SCPTreeRecord parent, int iname, java.lang.String value)
Construct a record for a name-value pair linking to the specified parent.SCPTreeRecord(SCPTreeRecord parent, java.lang.String name)
Construct a record for a named container, linking to the specied parent.SCPTreeRecord(SCPTreeRecord parent, java.lang.String name, java.lang.String value)
Construct a record for a name-value pair linking to the specified parent.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.Enumeration
children()
Returns the children of this node as anEnumeration
.int
compareTo(java.lang.Object o)
boolean
equals(java.lang.Object o)
boolean
getAllowsChildren()
Always returns true, since children may always be added.javax.swing.tree.TreeNode
getChildAt(int index)
Returns the child at the specified index.int
getChildCount()
Return the number of children that this node contains.int
getIndex(javax.swing.tree.TreeNode child)
Returns the index of the specified child from amongst this node's children, if present.javax.swing.tree.TreeNode
getParent()
Returns the parent node of this node.boolean
isLeaf()
Returns true if the receiver is a leaf (has no children).java.lang.String
toString()
Dump the record as a string.
-
-
-
Constructor Detail
-
SCPTreeRecord
public SCPTreeRecord(SCPTreeRecord parent, java.lang.String name, java.lang.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 recordname
- theString
name of this node (by which they are sorted)value
- theString
value of this node
-
SCPTreeRecord
public SCPTreeRecord(SCPTreeRecord parent, java.lang.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 recordname
- theString
name of this node (by which they are sorted)
-
SCPTreeRecord
public SCPTreeRecord(SCPTreeRecord parent, int iname, java.lang.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 recordiname
- the numeric name of this node (by which they are sorted)value
- theString
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 recordiname
- the numeric name of this node (by which they are sorted)
-
-
Method Detail
-
toString
public java.lang.String toString()
Dump the record as a string.
- Overrides:
toString
in classjava.lang.Object
- Returns:
- name and value as a string
-
compareTo
public int compareTo(java.lang.Object o)
- Specified by:
compareTo
in interfacejava.lang.Comparable
- Parameters:
o
-
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
-
-
getParent
public javax.swing.tree.TreeNode getParent()
Returns the parent node of this node.
- Specified by:
getParent
in interfacejavax.swing.tree.TreeNode
- Returns:
- the parent node, or null if the root
-
getChildAt
public javax.swing.tree.TreeNode getChildAt(int index)
Returns the child at the specified index.
- Specified by:
getChildAt
in interfacejavax.swing.tree.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(javax.swing.tree.TreeNode child)
Returns the index of the specified child from amongst this node's children, if present.
- Specified by:
getIndex
in interfacejavax.swing.tree.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 interfacejavax.swing.tree.TreeNode
- Returns:
- always true
-
isLeaf
public boolean isLeaf()
Returns true if the receiver is a leaf (has no children).
- Specified by:
isLeaf
in interfacejavax.swing.tree.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 interfacejavax.swing.tree.TreeNode
- Returns:
- the number of children, 0 if none
-
children
public java.util.Enumeration children()
Returns the children of this node as an
Enumeration
.- Specified by:
children
in interfacejavax.swing.tree.TreeNode
- Returns:
- the children of this node
-
-