Package elki.data

Class HierarchicalClassLabel

  • All Implemented Interfaces:
    java.lang.Comparable<ClassLabel>

    public class HierarchicalClassLabel
    extends ClassLabel
    A HierarchicalClassLabel is a ClassLabel to reflect a hierarchical structure of classes.
    Since:
    0.1
    Author:
    Arthur Zimek
    • Constructor Summary

      Constructors 
      Constructor 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.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_SEPARATOR

        public static final java.util.regex.Pattern DEFAULT_SEPARATOR
        The default separator pattern, a point ('.').
      • DEFAULT_SEPARATOR_STRING

        public static final java.lang.String DEFAULT_SEPARATOR_STRING
        The default separator, a point ('.').
        See Also:
        Constant Field Values
      • separatorPattern

        private java.util.regex.Pattern separatorPattern
        Holds the Pattern to separate different levels parsing input.
      • separatorString

        private java.lang.String separatorString
        A String to separate different levels in a String representation of this HierarchicalClassLabel.
      • levelwiseNames

        private java.lang.Comparable<?>[] levelwiseNames
        Holds the names on the different levels.
    • Constructor Detail

      • HierarchicalClassLabel

        public 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.
        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​(java.lang.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 java.lang.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 java.lang.String toString()
        Returns a String representation of this HierarchicalClassLabel using separatorString to separate levels.
        Specified by:
        toString in class ClassLabel
      • toString

        public java.lang.String toString​(int level)
        Create 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