Package org.apache.lucene.facet.taxonomy
Class CategoryPath
- java.lang.Object
-
- org.apache.lucene.facet.taxonomy.CategoryPath
-
- All Implemented Interfaces:
java.lang.Comparable<CategoryPath>
public class CategoryPath extends java.lang.Object implements java.lang.Comparable<CategoryPath>
Holds a sequence of string components, specifying the hierarchical name of a category.
-
-
Field Summary
Fields Modifier and Type Field Description java.lang.String[]
components
The components of thisCategoryPath
.static CategoryPath
EMPTY
An emptyCategoryPath
int
length
The number of components of thisCategoryPath
.
-
Constructor Summary
Constructors Constructor Description CategoryPath(java.lang.String... components)
Construct from the given path components.CategoryPath(java.lang.String pathString, char delimiter)
Construct from a given path, separating path components withdelimiter
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compareTo(CategoryPath other)
Compares this path with anotherCategoryPath
for lexicographic order.int
copyFullPath(char[] buf, int start, char delimiter)
Copies the path components to the givenchar[]
, starting at indexstart
.boolean
equals(java.lang.Object obj)
int
fullPathLength()
Returns the number of characters needed to represent the path, including delimiter characters, for using withcopyFullPath(char[], int, char)
.int
hashCode()
long
longHashCode()
Calculate a 64-bit hash function for this path.CategoryPath
subpath(int length)
Returns a sub-path of this path up tolength
components.java.lang.String
toString()
Returns a string representation of the path, separating components with '/'.java.lang.String
toString(char delimiter)
Returns a string representation of the path, separating components with the given delimiter.
-
-
-
Field Detail
-
EMPTY
public static final CategoryPath EMPTY
An emptyCategoryPath
-
components
public final java.lang.String[] components
The components of thisCategoryPath
. Note that this array may be shared with otherCategoryPath
instances, e.g. as a result ofsubpath(int)
, therefore you should traverse the array up tolength
for this path's components.
-
length
public final int length
The number of components of thisCategoryPath
.
-
-
Method Detail
-
fullPathLength
public int fullPathLength()
Returns the number of characters needed to represent the path, including delimiter characters, for using withcopyFullPath(char[], int, char)
.
-
compareTo
public int compareTo(CategoryPath other)
Compares this path with anotherCategoryPath
for lexicographic order.- Specified by:
compareTo
in interfacejava.lang.Comparable<CategoryPath>
-
copyFullPath
public int copyFullPath(char[] buf, int start, char delimiter)
Copies the path components to the givenchar[]
, starting at indexstart
.delimiter
is copied between the path components. Returns the number of chars copied.NOTE: this method relies on the array being large enough to hold the components and separators - the amount of needed space can be calculated with
fullPathLength()
.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
longHashCode
public long longHashCode()
Calculate a 64-bit hash function for this path.
-
subpath
public CategoryPath subpath(int length)
Returns a sub-path of this path up tolength
components.
-
toString
public java.lang.String toString()
Returns a string representation of the path, separating components with '/'.- Overrides:
toString
in classjava.lang.Object
- See Also:
toString(char)
-
toString
public java.lang.String toString(char delimiter)
Returns a string representation of the path, separating components with the given delimiter.
-
-