public class HierarchicalClassLabel extends ClassLabel
Modifier and Type | Class and Description |
---|---|
static class |
HierarchicalClassLabel.Factory
Factory class.
|
Modifier and Type | Field and Description |
---|---|
static java.util.regex.Pattern |
DEFAULT_SEPARATOR
The default separator pattern, a point ('.').
|
static java.lang.String |
DEFAULT_SEPARATOR_STRING
The default separator, a point ('.').
|
private java.lang.Comparable<?>[] |
levelwiseNames
Holds the names on the different levels.
|
private java.util.regex.Pattern |
separatorPattern
Holds the Pattern to separate different levels parsing input.
|
private java.lang.String |
separatorString
A String to separate different levels in a String representation of this
HierarchicalClassLabel.
|
static SimpleTypeInformation<HierarchicalClassLabel> |
TYPE
Type information.
|
Constructor and Description |
---|
HierarchicalClassLabel(java.lang.String label)
Constructs a hierarchical class label from the given name.
|
HierarchicalClassLabel(java.lang.String name,
java.util.regex.Pattern regex,
java.lang.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.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(ClassLabel o)
Compares two HierarchicalClassLabels.
|
int |
depth()
The length of the hierarchy of names.
|
java.lang.String |
getNameAt(int level)
Returns the name at the given level as a String.
|
java.lang.String |
toString()
Returns a String representation of this HierarchicalClassLabel using
separatorString to separate levels. |
java.lang.String |
toString(int level)
Create a String representation of this ClassLabel comprising only the
first
level levels. |
equals, hashCode
public static final java.util.regex.Pattern DEFAULT_SEPARATOR
public static final java.lang.String DEFAULT_SEPARATOR_STRING
public static final SimpleTypeInformation<HierarchicalClassLabel> TYPE
private java.util.regex.Pattern separatorPattern
private java.lang.String separatorString
private java.lang.Comparable<?>[] levelwiseNames
public HierarchicalClassLabel(java.lang.String name, java.util.regex.Pattern regex, java.lang.String separator)
name
- a String describing a hierarchical class labelregex
- a Pattern to match separators of different levels in the given
nameseparator
- a separator String to separate different levels in the
String-representation of this HierarchicalClassLabelpublic HierarchicalClassLabel(java.lang.String label)
DEFAULT_SEPARATOR
. Also, in a
String-representation of this HierarchicalClassLabel, different levels get
separated by '.'.label
- a String describing a hierarchical class labelpublic int compareTo(ClassLabel o)
public int depth()
public java.lang.String getNameAt(int level)
level
- the level to return the name atpublic java.lang.String toString()
separatorString
to separate levels.
Any ClassLabel requires a method to represent the label as a String. If
ClassLabel a.equals((ClassLabel) b)
, then also
a.toString().equals(b.toString())
should hold.
toString
in class ClassLabel
public java.lang.String toString(int level)
level
levels.level
- the lowest level to include in the String representation.level
levelsCopyright © 2019 ELKI Development Team. License information.