Class DatabaseTreeRecord
- All Implemented Interfaces:
Comparable
,MutableTreeNode
,TreeNode
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 Summary
ConstructorsConstructorDescriptionDatabaseTreeRecord
(DatabaseInformationModel d, DatabaseTreeRecord parent, String value, InformationEntity ie, String localPrimaryKeyValue, String localFileNameValue) Make a new node in a tree.DatabaseTreeRecord
(DatabaseInformationModel d, DatabaseTreeRecord parent, String value, InformationEntity ie, String localPrimaryKeyValue, String localFileNameValue, String localFileReferenceTypeValue) Make a new node in a tree. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.children()
Returns the children of this node as anEnumeration
.int
Compare nodes based on the lexicographic order of their string values.dump()
Dump the contents of the node.boolean
boolean
Always returns true, since children may always be added.getChildAt
(int index) Returns the child at the specified index.int
Return the number of children that this node contains.Get the DatabaseInformationModel that the database record is used in.int
Returns the index of the specified child from amongst this node's children, if present.Get the information entity that this node represents.Get the file name that the database record points to (meaningful only for instance (image) level nodes).Get the type of reference to the file that the database record points to (meaningful only for instance (image) level nodes).Get the string value of the local primary key of the database record corresponding to this node.Returns the parent node of this node.getValue()
Get the string value of the node which is used for sorting and human-readable rendering.void
insert
(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
(MutableTreeNode node) Removes the specified child from this node.void
Removes the node from its parent.void
setParent
(MutableTreeNode newParent) Sets the parent of the node to newParent.void
setUserObject
(Object object) Resets the user object of the node to object - but is not implemented since user objects are not required.toString()
Return the string value of the node.
-
Constructor Details
-
DatabaseTreeRecord
public DatabaseTreeRecord(DatabaseInformationModel d, DatabaseTreeRecord parent, String value, InformationEntity ie, String localPrimaryKeyValue, String localFileNameValue) Make a new node in a tree.
- Parameters:
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)
-
DatabaseTreeRecord
public DatabaseTreeRecord(DatabaseInformationModel d, DatabaseTreeRecord parent, String value, InformationEntity ie, String localPrimaryKeyValue, String localFileNameValue, String localFileReferenceTypeValue) Make a new node in a tree.
- Parameters:
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)
-
-
Method Details
-
dump
Dump the contents of the node.
- Returns:
- the contents of this node
-
toString
Return the string value of the node.
-
compareTo
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. Seecom.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.
- Specified by:
compareTo
in interfaceComparable
- Parameters:
o
- theDatabaseTreeRecord
to compare thisDatabaseTreeRecord
against- Returns:
- the value 0 if the argument is equal to this object; a value less than 0 if this object is lexicographically less than the argument; and a value greater than 0 if this object is lexicographically greater than the argument
-
equals
-
setParent
Sets the parent of the node to newParent.
param newParent the new parent node, or null if the root- Specified by:
setParent
in interfaceMutableTreeNode
-
removeFromParent
public void removeFromParent()Removes the node from its parent.
- Specified by:
removeFromParent
in interfaceMutableTreeNode
-
remove
Removes the specified child from this node.
node.setParent(null) will be called.
The database entry corresponding to the node will actually be deleted.
- Specified by:
remove
in interfaceMutableTreeNode
- Parameters:
node
-
-
remove
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.
- Specified by:
remove
in interfaceMutableTreeNode
- Parameters:
index
-
-
insert
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.
- Specified by:
insert
in interfaceMutableTreeNode
- Parameters:
child
-index
-
-
setUserObject
Resets the user object of the node to object - but is not implemented since user objects are not required.
- Specified by:
setUserObject
in interfaceMutableTreeNode
- Parameters:
object
- ignored
-
getParent
Returns the parent node of this node.
-
getChildAt
Returns the child at the specified index.
- Specified by:
getChildAt
in interfaceTreeNode
- Parameters:
index
- the index of the child to be returned, numbered from 0- Returns:
- the child
TreeNode
at the specified index
-
getIndex
Returns the index of the specified child from amongst this node's children, if present.
-
getAllowsChildren
public boolean getAllowsChildren()Always returns true, since children may always be added.
- Specified by:
getAllowsChildren
in interfaceTreeNode
- Returns:
- always true
-
isLeaf
public boolean isLeaf()Returns true if the receiver is a leaf (has no children).
-
getChildCount
public int getChildCount()Return the number of children that this node contains.
- Specified by:
getChildCount
in interfaceTreeNode
- Returns:
- the number of children, 0 if none
-
children
Returns the children of this node as an
Enumeration
. -
addChild
Add a child to this nodes sorted collection of children.
- Parameters:
child
- the child node to be added
-
addSibling
Add a sibling to this node, that is add a child to this node's parent's sorted collection of children.
- Parameters:
sibling
- the sibling node to be added
-
getValue
Get the string value of the node which is used for sorting and human-readable rendering.
- Returns:
- the string value of this node
-
getInformationEntity
Get the information entity that this node represents.
- Returns:
- information entity that this node represents
-
getLocalPrimaryKeyValue
Get the string value of the local primary key of the database record corresponding to this node.
- Returns:
- the string value of the local primary key
-
getLocalFileNameValue
Get the file name that the database record points to (meaningful only for instance (image) level nodes).
- Returns:
- the file name
-
getLocalFileReferenceTypeValue
Get the type of reference to the file that the database record points to (meaningful only for instance (image) level nodes).
- Returns:
- the file reference type; "C" for copied (i.e., delete on purge), "R" for referenced (i.e., do not delete on purge)
-
getDatabaseInformationModel
Get the DatabaseInformationModel that the database record is used in.
- Returns:
- the DatabaseInformationModel
-