Package com.pixelmed.database

## Class DatabaseTreeRecord

- java.lang.Object
- - com.pixelmed.database.DatabaseTreeRecord

- All Implemented Interfaces:
    `java.lang.Comparable`, `javax.swing.tree.MutableTreeNode`, `javax.swing.tree.TreeNode`

      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 Summary

    Constructors
    Constructor | 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.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | 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.

    - ### Methods inherited from class java.lang.Object

      `clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DatabaseTreeRecord

          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.

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

      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 Detail

    - #### dump

          public java.lang.String dump()

      Dump the contents of the node.

      Returns:
        the contents of this node

    - #### toString

          public java.lang.String toString()

      Return the string value of the node.

      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        the string value of this node

    - #### compareTo

          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.

      Specified by:
        `compareTo` in interface `java.lang.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​(java.lang.Object o)

      Overrides:
        `equals` in class `java.lang.Object`
      Parameters:
        `o` -

    - #### setParent

          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 root
      Specified by:
        `setParent` in interface `javax.swing.tree.MutableTreeNode`

    - #### removeFromParent

          public void removeFromParent()

      Removes the node from its parent.

      Specified by:
        `removeFromParent` in interface `javax.swing.tree.MutableTreeNode`

    - #### remove

          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.

      Specified by:
        `remove` in interface `javax.swing.tree.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 `javax.swing.tree.MutableTreeNode`
      Parameters:
        `index` -

    - #### insert

          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.

      Specified by:
        `insert` in interface `javax.swing.tree.MutableTreeNode`
      Parameters:
        `child` -
        `index` -

    - #### setUserObject

          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.

      Specified by:
        `setUserObject` in interface `javax.swing.tree.MutableTreeNode`
      Parameters:
        `object` - ignored

    - #### getParent

          public javax.swing.tree.TreeNode getParent()

      Returns the parent node of this node.

      Specified by:
        `getParent` in interface `javax.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 interface `javax.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 interface `javax.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 interface `javax.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 interface `javax.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 interface `javax.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 interface `javax.swing.tree.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 java.lang.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 java.lang.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 java.lang.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 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).

      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