Class DatabaseTreeRecord

java.lang.Object
com.pixelmed.database.DatabaseTreeRecord
All Implemented Interfaces:
Comparable, MutableTreeNode, TreeNode

public class DatabaseTreeRecord extends Object implements Comparable, 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 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 database
      parent - the parent of this node
      value - a string value which is used primarily to sort siblings into lexicographic order
      ie - the entity in the database information model that the constructed node is an instance of
      localPrimaryKeyValue - the local primary key of the database record corresponding to this node
      localFileNameValue - 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 database
      parent - the parent of this node
      value - a string value which is used primarily to sort siblings into lexicographic order
      ie - the entity in the database information model that the constructed node is an instance of
      localPrimaryKeyValue - the local primary key of the database record corresponding to this node
      localFileNameValue - 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

      public String dump()

      Dump the contents of the node.

      Returns:
      the contents of this node
    • toString

      public String toString()

      Return the string value of the node.

      Overrides:
      toString in class Object
      Returns:
      the string value of this node
    • compareTo

      public int compareTo(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.

      Specified by:
      compareTo in interface Comparable
      Parameters:
      o - the DatabaseTreeRecord to compare this DatabaseTreeRecord 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

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

      public void setParent(MutableTreeNode newParent)

      Sets the parent of the node to newParent.

      param newParent the new parent node, or null if the root
      Specified by:
      setParent in interface MutableTreeNode
    • removeFromParent

      public void removeFromParent()

      Removes the node from its parent.

      Specified by:
      removeFromParent in interface MutableTreeNode
    • remove

      public void remove(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.

      Specified by:
      remove in interface MutableTreeNode
      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 interface MutableTreeNode
      Parameters:
      index -
    • insert

      public void insert(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.

      Specified by:
      insert in interface MutableTreeNode
      Parameters:
      child -
      index -
    • setUserObject

      public void setUserObject(Object object)

      Resets the user object of the node to object - but is not implemented since user objects are not required.

      Specified by:
      setUserObject in interface MutableTreeNode
      Parameters:
      object - ignored
    • 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
    • addChild

      public void addChild(DatabaseTreeRecord child)

      Add a child to this nodes sorted collection of children.

      Parameters:
      child - the child node to be added
    • addSibling

      public 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.

      Parameters:
      sibling - the sibling node to be added
    • getValue

      public String 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

      public InformationEntity getInformationEntity()

      Get the information entity that this node represents.

      Returns:
      information entity that this node represents
    • getLocalPrimaryKeyValue

      public String 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

      public String getLocalFileNameValue()

      Get the file name that the database record points to (meaningful only for instance (image) level nodes).

      Returns:
      the file name
    • getLocalFileReferenceTypeValue

      public String 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

      public DatabaseInformationModel getDatabaseInformationModel()

      Get the DatabaseInformationModel that the database record is used in.

      Returns:
      the DatabaseInformationModel