arlut.csd.ganymede
Class DBBaseCategory

java.lang.Object
  |
  +--java.rmi.server.RemoteObject
        |
        +--java.rmi.server.RemoteServer
              |
              +--java.rmi.server.UnicastRemoteObject
                    |
                    +--arlut.csd.ganymede.DBBaseCategory
All Implemented Interfaces:
Category, CategoryNode, java.rmi.Remote, java.io.Serializable

public class DBBaseCategory
extends java.rmi.server.UnicastRemoteObject
implements Category, CategoryNode

A DBBaseCategory is a 'red folder node' in the server's category and object hierarchy. The purpose of DBBaseCategory is to be able to group object types with related purpose into a common folder for display on the client.

The DBStore contains a tree of CategoryNodes, each of which is either a DBObjectBase or a DBBaseCategory. The Category RMI interface is used by the server and the schema editor to perform browsing and manipulating the server's category tree.

See Also:
Serialized Form

Field Summary
private  java.util.Hashtable baseHash
          We use this baseHash to keep a map of DBObjectBase.getKey() to instances of DBObjectBase.
private static Compare comparator
           
private  java.util.Vector contents
          The actual members of this category.
private static boolean debug
           
private  DBSchemaEdit editor
          A reference to the DBSchemaEdit object that is editing us for a client-side schema editor.
private  java.lang.String name
           
private  DBBaseCategory parent
           
private  DBStore store
           
(package private)  int tmp_displayOrder
          In order to keep compatibility with versions 1.17 and previous of the ganymede.db file format, we'll keep this field so we can do a sort after loading when reading an old file.
 
Fields inherited from class java.rmi.server.UnicastRemoteObject
csf, port, portFactoryParamTypes, portParamTypes, serialVersionUID, ssf
 
Fields inherited from class java.rmi.server.RemoteServer
log, logname
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Constructor Summary
DBBaseCategory(DBStore store, java.io.DataInput in)
          Receive constructor.
DBBaseCategory(DBStore store, java.io.DataInput in, DBBaseCategory parent)
          Receive constructor.
DBBaseCategory(DBStore store, DBBaseCategory rootCategory, java.util.Hashtable baseHash, DBSchemaEdit editor)
          Recursive duplication constructor.
DBBaseCategory(DBStore store, java.lang.String name)
          Default value constructor.
DBBaseCategory(DBStore store, java.lang.String name, DBBaseCategory parent)
          Primary constructor.
 
Method Summary
 void addNodeAfter(CategoryNode node, java.lang.String prevNodeName)
          This method is used to place a Category Node under us.
 void addNodeBefore(CategoryNode node, java.lang.String nextNodeName)
          This method is used to place a Category Node under us.
 void clearEditor()
          This method is used when a schema editor is 'checking in' a category tree.
 boolean contains(java.lang.String name)
          This method returns true if this category directly contains a CategoryNode with name <name>
(package private)  void emit(java.io.DataOutput out)
          Emits this category and its contents to <out>, in ganymede.db form.
(package private)  void emitXML(XMLDumpContext xmlOut)
          Emits this category and its contents to <out>, in XML form.
 DBObjectBase getBaseFromBase(Base base)
          This method is used to convert an RMI remote reference to a Base object to a reference to the local copy.
 DBObjectBase getBaseFromKey(short id)
          This method is used to convert an RMI remote reference to a Base object to a reference to the local copy.
 Category getCategory()
          This method returns the category that this category node belongs to.
 java.lang.String getName()
          Returns the name of this category.
 CategoryNode getNode(java.lang.String name)
          Returns a subcategory of name <name>.
 java.util.Vector getNodes()
          Returns child nodes
 java.lang.String getPath()
          Returns the full path to this category, with levels in the hierarchy separated by '/'s.
 DBBaseCategory getRoot()
          This method returns a reference to the top of this category's tree.
 boolean isUnder(Category cat)
          This method returns true if this is a subcategory of <cat>.
 void moveCategoryNode(java.lang.String catPath, java.lang.String prevNodeName)
          This method can be used to move a Category from another Category to this Category, or to move a Category around within this Category.
 Category newSubCategory()
          This creates a new subcategory under this category, with displayOrder after the last item currently in the category.
 Category newSubCategory(java.lang.String name)
          This creates a new subcategory under this category, with displayOrder after the last item currently in the category.
 void print(java.io.PrintWriter out, java.lang.String indent)
          Recursively prints a portion of a text representation of this category to <out>, with leading indent.
 void printHTML(java.io.PrintWriter out)
          Recursively prints a portion of an HTML representation of this category to <out> Must be called from DBStore.printCategoryTreeHTML(), as it assumes the HTML context generated by that method.
(package private)  void receive(java.io.DataInput in, DBBaseCategory parent)
          Reads this category and its contents from <in>, in ganymede.db form.
private  void recurseDown(DBBaseCategory category, java.util.Hashtable baseHash, DBSchemaEdit editor)
          This method takes all the children of the passed-in category (both DBObjectBase objects and contained DBBaseCategory objects) and makes copies under this.
 void removeNode(CategoryNode node)
          This method is used to remove a Category Node from under us.
 void removeNode(java.lang.String name)
          This method is used to remove a Category Node from under us.
 void resort()
          Resorts this category's contents based on the tmp_displayOrder field.
 void setCategory(Category category)
          This method tells the CategoryNode what it's containing category is.
 boolean setName(java.lang.String newName)
          Sets the name of this node.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
, clone, exportObject, exportObject, exportObject, exportObject, readObject, reexport, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub, writeObject
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

debug

private static final boolean debug

comparator

private static Compare comparator

name

private java.lang.String name

parent

private DBBaseCategory parent

store

private DBStore store

contents

private java.util.Vector contents
The actual members of this category. Each member will be either a DBObjectBase or another DBBaseCategory.

tmp_displayOrder

int tmp_displayOrder
In order to keep compatibility with versions 1.17 and previous of the ganymede.db file format, we'll keep this field so we can do a sort after loading when reading an old file.

baseHash

private java.util.Hashtable baseHash
We use this baseHash to keep a map of DBObjectBase.getKey() to instances of DBObjectBase. addNodeAfter() uses this to find a server-local DBObjectBase from a remote Base reference passed us by the schema editor on the client.

editor

private DBSchemaEdit editor
A reference to the DBSchemaEdit object that is editing us for a client-side schema editor.
Constructor Detail

DBBaseCategory

public DBBaseCategory(DBStore store,
                      java.lang.String name,
                      DBBaseCategory parent)
               throws java.rmi.RemoteException
Primary constructor.
Parameters:
store - DBStore that is managing us. We'll ask it to look up parents for us.
name - Name for this base
parent - If we're not being constructed at the top level, who is our parent?

DBBaseCategory

public DBBaseCategory(DBStore store,
                      java.lang.String name)
               throws java.rmi.RemoteException
Default value constructor. This is used to construct a top-level category.
Parameters:
store - DBStore that is managing us. We'll ask it to look up parents for us.
name - Name for this category

DBBaseCategory

public DBBaseCategory(DBStore store,
                      java.io.DataInput in)
               throws java.rmi.RemoteException,
                      java.io.IOException
Receive constructor.
Parameters:
store - DBStore that is managing us. We'll ask it to look up parents for us.
in - DataInput stream to load the db representation of this category from

DBBaseCategory

public DBBaseCategory(DBStore store,
                      java.io.DataInput in,
                      DBBaseCategory parent)
               throws java.rmi.RemoteException,
                      java.io.IOException
Receive constructor.
Parameters:
store - DBStore that is managing us. We'll ask it to look up parents for us.
in - DataInput stream to load the db representation of this category from

DBBaseCategory

public DBBaseCategory(DBStore store,
                      DBBaseCategory rootCategory,
                      java.util.Hashtable baseHash,
                      DBSchemaEdit editor)
               throws java.rmi.RemoteException
Recursive duplication constructor. This constructor recurses down through the newly created DBBaseCategory and creates copies of the bases and categories therein.
Method Detail

recurseDown

private void recurseDown(DBBaseCategory category,
                         java.util.Hashtable baseHash,
                         DBSchemaEdit editor)
                  throws java.rmi.RemoteException

This method takes all the children of the passed-in category (both DBObjectBase objects and contained DBBaseCategory objects) and makes copies under this.


clearEditor

public void clearEditor()
This method is used when a schema editor is 'checking in' a category tree.

printHTML

public void printHTML(java.io.PrintWriter out)

Recursively prints a portion of an HTML representation of this category to <out> Must be called from DBStore.printCategoryTreeHTML(), as it assumes the HTML context generated by that method.


print

public void print(java.io.PrintWriter out,
                  java.lang.String indent)

Recursively prints a portion of a text representation of this category to <out>, with leading indent.

Parameters:
out -  
indent - leading indent for this category and below
showAll - if true, show built-in field types

emit

void emit(java.io.DataOutput out)
    throws java.io.IOException

Emits this category and its contents to <out>, in ganymede.db form.


receive

void receive(java.io.DataInput in,
             DBBaseCategory parent)
       throws java.io.IOException

Reads this category and its contents from <in>, in ganymede.db form.


emitXML

void emitXML(XMLDumpContext xmlOut)
       throws java.io.IOException

Emits this category and its contents to <out>, in XML form.


resort

public void resort()

Resorts this category's contents based on the tmp_displayOrder field.

We only use this when loading DBBaseCategory's from old-style ganymede.db files. The modern way of doing things depends on the order of categories within a contents Vector, and needs no explicit tmp_displayOrder or sorting to be done.


getPath

public java.lang.String getPath()

Returns the full path to this category, with levels in the hierarchy separated by '/'s.

Specified by:
getPath in interface Category
See Also:
Category

getName

public java.lang.String getName()
Returns the name of this category.
Specified by:
getName in interface Category
See Also:
Category

setName

public boolean setName(java.lang.String newName)
Sets the name of this node. The name must not include a '/' character, but all other characters are acceptable.
Specified by:
setName in interface Category
See Also:
CategoryNode

getCategory

public Category getCategory()
This method returns the category that this category node belongs to.
Specified by:
getCategory in interface Category
See Also:
Category, CategoryNode

setCategory

public void setCategory(Category category)
This method tells the CategoryNode what it's containing category is.
Specified by:
setCategory in interface CategoryNode
See Also:
CategoryNode

addNodeAfter

public void addNodeAfter(CategoryNode node,
                         java.lang.String prevNodeName)

This method is used to place a Category Node under us. This method adds a new node into this category, after prevNodeName if prevNodeName is not null, or at the end of the category if it is.

Specified by:
addNodeAfter in interface Category
Parameters:
node - Node to place under this category
prevNodeName - the name of the node that the new node is to be added after, must not be path-qualified.
See Also:
Category

addNodeBefore

public void addNodeBefore(CategoryNode node,
                          java.lang.String nextNodeName)

This method is used to place a Category Node under us. This method adds a new node into this category, before nextNodeName if nextNodeName is not null, or at the beginning of the category if it is.

Specified by:
addNodeBefore in interface Category
Parameters:
node - Node to place under this category
nextNodeName - the name of the node that the new node is to be added before, must not be path-qualified.
See Also:
Category

moveCategoryNode

public void moveCategoryNode(java.lang.String catPath,
                             java.lang.String prevNodeName)

This method can be used to move a Category from another Category to this Category, or to move a Category around within this Category.

Specified by:
moveCategoryNode in interface Category
Parameters:
catPath - the fully specified path of the node to be moved
prevNodeName - the name of the node that the catPath node is to be placed after in this category, or null if the node is to be placed at the first element of this category
See Also:
Category

removeNode

public void removeNode(CategoryNode node)
                throws java.rmi.RemoteException

This method is used to remove a Category Node from under us.

Specified by:
removeNode in interface Category
See Also:
Category

removeNode

public void removeNode(java.lang.String name)
                throws java.rmi.RemoteException

This method is used to remove a Category Node from under us.

Specified by:
removeNode in interface Category
See Also:
Category

getNode

public CategoryNode getNode(java.lang.String name)

Returns a subcategory of name <name>.

Specified by:
getNode in interface Category
See Also:
Category

getNodes

public java.util.Vector getNodes()
Returns child nodes
Specified by:
getNodes in interface Category
See Also:
Category

newSubCategory

public Category newSubCategory(java.lang.String name)

This creates a new subcategory under this category, with displayOrder after the last item currently in the category. This method should only be called when there are no nodes left to be added to the category with prefixed displayOrder values.


newSubCategory

public Category newSubCategory()

This creates a new subcategory under this category, with displayOrder after the last item currently in the category. This method should only be called when there are no nodes left to be added to the category with prefixed displayOrder values.

Specified by:
newSubCategory in interface Category
See Also:
Category

isUnder

public boolean isUnder(Category cat)

This method returns true if this is a subcategory of <cat>.

Specified by:
isUnder in interface Category
See Also:
Category

contains

public boolean contains(java.lang.String name)

This method returns true if this category directly contains a CategoryNode with name <name>


getRoot

public DBBaseCategory getRoot()
This method returns a reference to the top of this category's tree.

getBaseFromBase

public DBObjectBase getBaseFromBase(Base base)

This method is used to convert an RMI remote reference to a Base object to a reference to the local copy.

Needed for RMI under JDK 1.1.


getBaseFromKey

public DBObjectBase getBaseFromKey(short id)

This method is used to convert an RMI remote reference to a Base object to a reference to the local copy.

Needed for RMI under JDK 1.1.