de.lmu.ifi.dbs.elki.data
Class HierarchicalClassLabel

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.data.ClassLabel
      extended by de.lmu.ifi.dbs.elki.data.HierarchicalClassLabel
All Implemented Interfaces:
Comparable<ClassLabel>

public class HierarchicalClassLabel
extends ClassLabel

A HierarchicalClassLabel is a ClassLabel to reflect a hierarchical structure of classes.


Nested Class Summary
static class HierarchicalClassLabel.Factory
          Factory class
 
Field Summary
static Pattern DEFAULT_SEPARATOR
          The default separator pattern, a point ('.').
static String DEFAULT_SEPARATOR_STRING
          The default separator, a point ('.').
private  Comparable<?>[] levelwiseNames
          Holds the names on the different levels.
private  Pattern separatorPattern
          Holds the Pattern to separate different levels parsing input.
private  String separatorString
          A String to separate different levels in a String representation of this HierarchicalClassLabel.
 
Constructor Summary
HierarchicalClassLabel(String label)
          Constructs a hierarchical class label from the given name.
HierarchicalClassLabel(String name, Pattern regex, String separator)
          Constructs a hierarchical class label from the given name, using the given Pattern to match separators of different levels in the given name, and setting the given separator-String to separate different levels in String representations of this HierarchicalClassLabel.
 
Method Summary
 int compareTo(ClassLabel o)
          Compares two HierarchicalClassLabels.
 int depth()
          The length of the hierarchy of names.
 String getNameAt(int level)
          Returns the name at the given level as a String.
 String toString()
          Returns a String representation of this HierarchicalClassLabel using separatorString to separate levels.
 String toString(int level)
          Provides a String representation of this ClassLabel comprising only the first level levels.
 
Methods inherited from class de.lmu.ifi.dbs.elki.data.ClassLabel
equals, hashCode
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

DEFAULT_SEPARATOR

public static final Pattern DEFAULT_SEPARATOR
The default separator pattern, a point ('.').


DEFAULT_SEPARATOR_STRING

public static final String DEFAULT_SEPARATOR_STRING
The default separator, a point ('.').

See Also:
Constant Field Values

separatorPattern

private Pattern separatorPattern
Holds the Pattern to separate different levels parsing input.


separatorString

private String separatorString
A String to separate different levels in a String representation of this HierarchicalClassLabel.


levelwiseNames

private Comparable<?>[] levelwiseNames
Holds the names on the different levels.

Constructor Detail

HierarchicalClassLabel

public HierarchicalClassLabel(String name,
                              Pattern regex,
                              String separator)
Constructs a hierarchical class label from the given name, using the given Pattern to match separators of different levels in the given name, and setting the given separator-String to separate different levels in String representations of this HierarchicalClassLabel.

Parameters:
name - a String describing a hierarchical class label
regex - a Pattern to match separators of different levels in the given name
separator - a separator String to separate different levels in the String-representation of this HierarchicalClassLabel

HierarchicalClassLabel

public HierarchicalClassLabel(String label)
Constructs a hierarchical class label from the given name. Different levels are supposed to be separated by points ('.'), as defined by DEFAULT_SEPARATOR. Also, in a String-representation of this HierarchicalClassLabel, different levels get separated by '.'.

Parameters:
label - a String describing a hierarchical class label
Method Detail

compareTo

public int compareTo(ClassLabel o)
Compares two HierarchicalClassLabels. Names at higher levels are compared first. Names at a lower level are compared only if their parent-names are equal. Names at a level are tried to be compared as integer values. If this does not succeed, both names are compared as Strings.


depth

public int depth()
The length of the hierarchy of names.

Returns:
length of the hierarchy of names

getNameAt

public String getNameAt(int level)
Returns the name at the given level as a String.

Parameters:
level - the level to return the name at
Returns:
the name at the given level as a String

toString

public String toString()
Returns a String representation of this HierarchicalClassLabel using separatorString to separate levels.

Specified by:
toString in class ClassLabel
See Also:
toString(int)

toString

public String toString(int level)
Provides a String representation of this ClassLabel comprising only the first level levels.

Parameters:
level - the lowest level to include in the String representation.
Returns:
a String representation of this ClassLabel comprising only the first level levels

Release 0.4.0 (2011-09-20_1324)