public class DatabaseTreeRecord
extends java.lang.Object
implements java.lang.Comparable, javax.swing.tree.MutableTreeNode
Instances of the DatabaseTreeRecord
class represent
nodes in a tree of the DatabaseTreeModel
class, which in
turn is used by the DatabaseTreeBrowser
class.
This class is publically visible primarily so that selection change listeners can be
constructed for DatabaseTreeBrowser
, since
the user's selection is returned as a path of DatabaseTreeRecord
instances, which need to be cast accordingly.
Constructor and Description |
---|
DatabaseTreeRecord(DatabaseInformationModel d,
DatabaseTreeRecord parent,
java.lang.String value,
InformationEntity ie,
java.lang.String localPrimaryKeyValue,
java.lang.String localFileNameValue)
Make a new node in a
tree.
|
DatabaseTreeRecord(DatabaseInformationModel d,
DatabaseTreeRecord parent,
java.lang.String value,
InformationEntity ie,
java.lang.String localPrimaryKeyValue,
java.lang.String localFileNameValue,
java.lang.String localFileReferenceTypeValue)
Make a new node in a
tree.
|
Modifier and Type | Method and Description |
---|---|
void |
addChild(DatabaseTreeRecord child)
Add a child to this nodes sorted collection of children.
|
void |
addSibling(DatabaseTreeRecord sibling)
Add a sibling to this node,
that is add a child to this
node's parent's sorted collection of children.
|
java.util.Enumeration |
children()
Returns the children of this node as an
Enumeration . |
int |
compareTo(java.lang.Object o)
Compare nodes based on the lexicographic order of their string values.
|
java.lang.String |
dump()
Dump the contents of the node.
|
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.
|
DatabaseInformationModel |
getDatabaseInformationModel()
Get the DatabaseInformationModel that the database record is used in.
|
int |
getIndex(javax.swing.tree.TreeNode child)
Returns the index of the specified child from amongst this node's children, if present.
|
InformationEntity |
getInformationEntity()
Get the information entity that this node represents.
|
java.lang.String |
getLocalFileNameValue()
Get the file name that the database record points to (meaningful only for instance (image) level nodes).
|
java.lang.String |
getLocalFileReferenceTypeValue()
Get the type of reference to the file that the database record points to (meaningful only for instance (image) level nodes).
|
java.lang.String |
getLocalPrimaryKeyValue()
Get the string value of the local primary key of the database record corresponding to this node.
|
javax.swing.tree.TreeNode |
getParent()
Returns the parent node of this node.
|
java.lang.String |
getValue()
Get the string value of the node which is used for sorting and human-readable rendering.
|
void |
insert(javax.swing.tree.MutableTreeNode child,
int index)
Should add child to the node at index - but is not implemented.
|
boolean |
isLeaf()
Returns true if the receiver is a leaf (has no children).
|
void |
remove(int index)
Removes the child at index from this node.
|
void |
remove(javax.swing.tree.MutableTreeNode node)
Removes the specified child from this node.
|
void |
removeFromParent()
Removes the node from its parent.
|
void |
setParent(javax.swing.tree.MutableTreeNode newParent)
Sets the parent of the node to newParent.
|
void |
setUserObject(java.lang.Object object)
Resets the user object of the node to object - but is not implemented since user objects are not required.
|
java.lang.String |
toString()
Return the string value of the node.
|
public DatabaseTreeRecord(DatabaseInformationModel d, DatabaseTreeRecord parent, java.lang.String value, InformationEntity ie, java.lang.String localPrimaryKeyValue, java.lang.String localFileNameValue)
Make a new node in a tree.
d
- the databaseparent
- the parent of this nodevalue
- a string value which is used primarily to sort siblings into lexicographic orderie
- the entity in the database information model that the constructed node is an instance oflocalPrimaryKeyValue
- the local primary key of the database record corresponding to this nodelocalFileNameValue
- the file name that the database record points to (meaningful only for instance (image) level nodes)public DatabaseTreeRecord(DatabaseInformationModel d, DatabaseTreeRecord parent, java.lang.String value, InformationEntity ie, java.lang.String localPrimaryKeyValue, java.lang.String localFileNameValue, java.lang.String localFileReferenceTypeValue)
Make a new node in a tree.
d
- the databaseparent
- the parent of this nodevalue
- a string value which is used primarily to sort siblings into lexicographic orderie
- the entity in the database information model that the constructed node is an instance oflocalPrimaryKeyValue
- the local primary key of the database record corresponding to this nodelocalFileNameValue
- the file name that the database record points to (meaningful only for instance (image) level nodes)localFileReferenceTypeValue
- "C" for copied (i.e., delete on purge), "R" for referenced (i.e., do not delete on purge)public void addChild(DatabaseTreeRecord child)
Add a child to this nodes sorted collection of children.
child
- the child node to be addedpublic void addSibling(DatabaseTreeRecord sibling)
Add a sibling to this node, that is add a child to this node's parent's sorted collection of children.
sibling
- the sibling node to be addedpublic java.util.Enumeration children()
Returns the children of this node as an Enumeration
.
children
in interface javax.swing.tree.TreeNode
public int compareTo(java.lang.Object o)
Compare nodes based on the lexicographic order of their string values.
Note that the comparison is more complex than a simple lexicographic comparison
of strings (as described in the definition of java.lang.String.compareTo(String)
but rather accounts for embedded non-zero padded integers. See com.pixelmed.utils.compareStringsWithEmbeddedNonZeroPaddedIntegers(String,String)
If the string values are equal but they are not the same database record, then an arbitrary but consistent order is return.
compareTo
in interface java.lang.Comparable
o
- the DatabaseTreeRecord
to compare this DatabaseTreeRecord
againstpublic java.lang.String dump()
Dump the contents of the node.
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
o
- public boolean getAllowsChildren()
Always returns true, since children may always be added.
getAllowsChildren
in interface javax.swing.tree.TreeNode
public javax.swing.tree.TreeNode getChildAt(int index)
Returns the child at the specified index.
getChildAt
in interface javax.swing.tree.TreeNode
index
- the index of the child to be returned, numbered from 0TreeNode
at the specified indexpublic int getChildCount()
Return the number of children that this node contains.
getChildCount
in interface javax.swing.tree.TreeNode
public DatabaseInformationModel getDatabaseInformationModel()
Get the DatabaseInformationModel that the database record is used in.
public int getIndex(javax.swing.tree.TreeNode child)
Returns the index of the specified child from amongst this node's children, if present.
getIndex
in interface javax.swing.tree.TreeNode
child
- the child to search for amongst this node's childrenpublic InformationEntity getInformationEntity()
Get the information entity that this node represents.
public java.lang.String getLocalFileNameValue()
Get the file name that the database record points to (meaningful only for instance (image) level nodes).
public java.lang.String getLocalFileReferenceTypeValue()
Get the type of reference to the file that the database record points to (meaningful only for instance (image) level nodes).
public java.lang.String getLocalPrimaryKeyValue()
Get the string value of the local primary key of the database record corresponding to this node.
public javax.swing.tree.TreeNode getParent()
Returns the parent node of this node.
getParent
in interface javax.swing.tree.TreeNode
public java.lang.String getValue()
Get the string value of the node which is used for sorting and human-readable rendering.
public void insert(javax.swing.tree.MutableTreeNode child, int index)
Should add child to the node at index - but is not implemented.
child.setParent(null) would be called if implemented
The database entries corresponding to the child and node would need to be updated.
insert
in interface javax.swing.tree.MutableTreeNode
child
- index
- public boolean isLeaf()
Returns true if the receiver is a leaf (has no children).
isLeaf
in interface javax.swing.tree.TreeNode
public void remove(int index)
Removes the child at index from this node.
node.setParent(null) will be called.
The database entry corresponding to the node will actually be deleted.
remove
in interface javax.swing.tree.MutableTreeNode
index
- public void remove(javax.swing.tree.MutableTreeNode node)
Removes the specified child from this node.
node.setParent(null) will be called.
The database entry corresponding to the node will actually be deleted.
remove
in interface javax.swing.tree.MutableTreeNode
node
- public void removeFromParent()
Removes the node from its parent.
removeFromParent
in interface javax.swing.tree.MutableTreeNode
public void setParent(javax.swing.tree.MutableTreeNode newParent)
Sets the parent of the node to newParent.
param newParent the new parent node, or null if the rootsetParent
in interface javax.swing.tree.MutableTreeNode
public void setUserObject(java.lang.Object object)
Resets the user object of the node to object - but is not implemented since user objects are not required.
setUserObject
in interface javax.swing.tree.MutableTreeNode
object
- ignoredpublic java.lang.String toString()
Return the string value of the node.
toString
in class java.lang.Object