org.greenstone.gs3client.data
Class NodeData

java.lang.Object
  extended by org.greenstone.gs3client.data.NodeData
Direct Known Subclasses:
ClassifierNodeData, DocumentNodeData

public abstract class NodeData
extends java.lang.Object

Abstract superclass NodeData can represent either a the information in a <classifierNode> (stored in a ClassifierNodeData object) or in a <documentNode> (stored in a DocumentNodeData object).

Author:
ak19

Field Summary
 boolean hasChildren
          Since we are setting the descendents lazily (only setting the children each time), we have a little flag to indicate whether this node has any children.
 java.lang.String nodeID
          The unique nodeID identifying this documentNode or classificationNode
protected  java.util.Map nodeMetadata
          Map of the metadata (name, value) pairs of this document- or classifier-node
protected  org.w3c.dom.Element nodeTag
          stores this NodeData's tag element: can be either <documentNode> or <classifierNode>
 
Constructor Summary
NodeData(org.w3c.dom.Element nodeTag)
          Constructor that extracts the nodeID value from the given nodeTag: <classifierNode nodeID = "x" /> or <documentNode nodeID = "x" />
 
Method Summary
abstract  NodeData[] getChildren()
           
 java.util.Map getMetadataList()
           
 java.lang.String getTitle()
           
protected  void setChildren(java.util.Vector v, java.util.Map idsToNodes_map)
          Called when setting descendents lazily: only the children of this node are set.
 void setMetadataList(org.w3c.dom.Element nodeTag)
          Sets member metadataList if there is a <metadataList> subelement in docNodeTag: first get the <metadataList> then its <metadata> children
 java.lang.String show()
           
 java.lang.String showMeta()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

nodeID

public final java.lang.String nodeID
The unique nodeID identifying this documentNode or classificationNode


hasChildren

public final boolean hasChildren
Since we are setting the descendents lazily (only setting the children each time), we have a little flag to indicate whether this node has any children.


nodeTag

protected final org.w3c.dom.Element nodeTag
stores this NodeData's tag element: can be either <documentNode> or <classifierNode>


nodeMetadata

protected java.util.Map nodeMetadata
Map of the metadata (name, value) pairs of this document- or classifier-node

Constructor Detail

NodeData

public NodeData(org.w3c.dom.Element nodeTag)
Constructor that extracts the nodeID value from the given nodeTag: <classifierNode nodeID = "x" /> or <documentNode nodeID = "x" />

Method Detail

getChildren

public abstract NodeData[] getChildren()
Returns:
an array of the children of this NodeData, however such a structure may be stored internally by a NodeData subclass.

setMetadataList

public void setMetadataList(org.w3c.dom.Element nodeTag)
Sets member metadataList if there is a <metadataList> subelement in docNodeTag: first get the <metadataList> then its <metadata> children

Parameters:
nodeTag - is a documentNode or classifierNode XML Element that contains metadata information which is used to set this NodeData object's metadata (if there are any, the HashMap nodeMetadata will be set).

setChildren

protected void setChildren(java.util.Vector v,
                           java.util.Map idsToNodes_map)
Called when setting descendents lazily: only the children of this node are set. We don't care to setDescendents now, will set it later when necessary.

Parameters:
v - is an empty/non-null Vector which will, at method's end, contain all the Document- or ClassifierNodeData objects that are children of this NodeData object.

getMetadataList

public java.util.Map getMetadataList()
Returns:
a hashmap of this document's metadata (name, val) pairs. A null is returned if the nodeMetadata has not been set yet.

getTitle

public java.lang.String getTitle()
Returns:
the title of this docNodeData object, if any is set. If it's not been set yet (title metadata not yet set, a null is returned.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the title of this docNodeData object, if any. Otherwise the nodeID is returned. This method is useful for displaying this docNodeData object as a node in a JTree. Some meaningful displayable value is returned, unlike getTitle() which returns a null if title is not set yet.

show

public java.lang.String show()
Returns:
the details contained in this NodeData object. Useful for debugging purposes.

showMeta

public java.lang.String showMeta()
Returns:
a String representation of the contains of the nodeMetadata list (useful for debugging purposes).