mulan.data
Class LabelsMetaDataImpl

java.lang.Object
  extended by mulan.data.LabelsMetaDataImpl
All Implemented Interfaces:
Externalizable, Serializable, LabelsMetaData

public class LabelsMetaDataImpl
extends Object
implements LabelsMetaData, Serializable, Externalizable

Implementation of LabelsMetaData info about labels and their structure.

Author:
Jozef Vilcek
See Also:
LabelsMetaData, Serialized Form

Constructor Summary
LabelsMetaDataImpl()
          Creates a new instance of LabelsMetaDataImpl.
 
Method Summary
 void addRootNode(LabelNode rootNode)
          Adds a root LabelNode.
 LabelsMetaData clone()
          Returns a deep copy of the LabelsMetaDataImpl instance.
 boolean containsLabel(String labelName)
          Determines if LabelsMetaData contains a label with specified name.
 Set<String> getLabelNames()
          Gets the names of all labels.
 LabelNode getLabelNode(String labelName)
          Gets the LabelNode specified by label name.
 int getNumLabels()
          Gets the total number of LabelNode nodes.
 Set<LabelNode> getRootLabels()
          Gets the unmodifiable Set of root LabelNode nodes of label attributes hierarchy.
 boolean isHierarchy()
          Determines if there is a hierarchy defined between labels.
 void readExternal(ObjectInput in)
           
 int removeLabelNode(String labelName)
          Removes LabelNode specified by the name.
 void writeExternal(ObjectOutput out)
           
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LabelsMetaDataImpl

public LabelsMetaDataImpl()
Creates a new instance of LabelsMetaDataImpl.

Method Detail

addRootNode

public void addRootNode(LabelNode rootNode)
Adds a root LabelNode. The node is assumed to has linked all related child nodes, if they exists. The node is added into root set and all child nodes are added into internal mapping. The node is uniquely identified by the label name.

Parameters:
rootNode - the root node with underlying hierarchy of nodes
Throws:
ArgumentNullException - if specified root node is null

getLabelNode

public LabelNode getLabelNode(String labelName)
Description copied from interface: LabelsMetaData
Gets the LabelNode specified by label name. The name is unique identifier of the node and corresponds to label attribute in the data set. If LabelNode for given label name does not exists, null is returned.

Specified by:
getLabelNode in interface LabelsMetaData
Parameters:
labelName - the name of label of which the node should be retrieved
Returns:
the LabelNode for specified label of null if LabelNode does not exists for specified label name

getLabelNames

public Set<String> getLabelNames()
Description copied from interface: LabelsMetaData
Gets the names of all labels. The label name is a unique identifier among all labels in the meta data.

Specified by:
getLabelNames in interface LabelsMetaData
Returns:
the names of all labels.

containsLabel

public boolean containsLabel(String labelName)
Description copied from interface: LabelsMetaData
Determines if LabelsMetaData contains a label with specified name.

Specified by:
containsLabel in interface LabelsMetaData
Parameters:
labelName - the label name
Returns:
true if meta data contains the given label name; false otherwise.

isHierarchy

public boolean isHierarchy()
Description copied from interface: LabelsMetaData
Determines if there is a hierarchy defined between labels. If not, all labels are represented as root LabelNode nodes.

Specified by:
isHierarchy in interface LabelsMetaData
Returns:
true if there is hierarchy defined between labels; false otherwise.

getNumLabels

public int getNumLabels()
Description copied from interface: LabelsMetaData
Gets the total number of LabelNode nodes.

Specified by:
getNumLabels in interface LabelsMetaData
Returns:
total number of LabelNode nodes

getRootLabels

public Set<LabelNode> getRootLabels()
Description copied from interface: LabelsMetaData
Gets the unmodifiable Set of root LabelNode nodes of label attributes hierarchy.

Specified by:
getRootLabels in interface LabelsMetaData
Returns:
the Set of root nodes.

clone

public LabelsMetaData clone()
Description copied from interface: LabelsMetaData
Returns a deep copy of the LabelsMetaDataImpl instance.

Specified by:
clone in interface LabelsMetaData
Overrides:
clone in class Object
Returns:
a deep copy of the LabelsMetaDataImpl instance

removeLabelNode

public int removeLabelNode(String labelName)
Removes LabelNode specified by the name. If there is a hierarchy between label nodes, whole subtree with all its children is also removed.

Parameters:
labelName - the name of LabelNode to be removed
Returns:
the number of removed nodes

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Specified by:
writeExternal in interface Externalizable
Throws:
IOException