Package org.apache.lucene.util
Class CharsRef
- java.lang.Object
-
- org.apache.lucene.util.CharsRef
-
- All Implemented Interfaces:
CharSequence,Cloneable,Comparable<CharsRef>
public final class CharsRef extends Object implements Comparable<CharsRef>, CharSequence, Cloneable
Represents char[], as a slice (offset + length) into an existing char[]. Thecharsmember should never be null; useEMPTY_CHARSif necessary.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Field Summary
Fields Modifier and Type Field Description char[]charsstatic char[]EMPTY_CHARSintlengthintoffset
-
Constructor Summary
Constructors Constructor Description CharsRef()Creates a newCharsRefinitialized an empty array zero-lengthCharsRef(char[] chars, int offset, int length)Creates a newCharsRefinitialized with the given array, offset and lengthCharsRef(int capacity)Creates a newCharsRefinitialized with an array of the given capacityCharsRef(String string)Creates a newCharsRefinitialized with the given Strings character array
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidappend(char[] otherChars, int otherOffset, int otherLength)Appends the given array to this CharsRefcharcharAt(int index)booleancharsEquals(CharsRef other)CharsRefclone()intcompareTo(CharsRef other)Signed int order comparisonvoidcopyChars(char[] otherChars, int otherOffset, int otherLength)Copies the given array into this CharsRef.voidcopyChars(CharsRef other)Copies the givenCharsRefreferenced content into this instance.static CharsRefdeepCopyOf(CharsRef other)Creates a new CharsRef that points to a copy of the chars fromotherbooleanequals(Object other)static Comparator<CharsRef>getUTF16SortedAsUTF8Comparator()voidgrow(int newLength)Used to grow the reference array.inthashCode()intlength()CharSequencesubSequence(int start, int end)StringtoString()-
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.CharSequence
chars, codePoints
-
-
-
-
Constructor Detail
-
CharsRef
public CharsRef()
Creates a newCharsRefinitialized an empty array zero-length
-
CharsRef
public CharsRef(int capacity)
Creates a newCharsRefinitialized with an array of the given capacity
-
CharsRef
public CharsRef(char[] chars, int offset, int length)Creates a newCharsRefinitialized with the given array, offset and length
-
-
Method Detail
-
charsEquals
public boolean charsEquals(CharsRef other)
-
compareTo
public int compareTo(CharsRef other)
Signed int order comparison- Specified by:
compareToin interfaceComparable<CharsRef>
-
copyChars
public void copyChars(CharsRef other)
Copies the givenCharsRefreferenced content into this instance.- Parameters:
other- theCharsRefto copy
-
grow
public void grow(int newLength)
Used to grow the reference array. In general this should not be used as it does not take the offset into account.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
copyChars
public void copyChars(char[] otherChars, int otherOffset, int otherLength)Copies the given array into this CharsRef.
-
append
public void append(char[] otherChars, int otherOffset, int otherLength)Appends the given array to this CharsRef
-
toString
public String toString()
- Specified by:
toStringin interfaceCharSequence- Overrides:
toStringin classObject
-
length
public int length()
- Specified by:
lengthin interfaceCharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAtin interfaceCharSequence
-
subSequence
public CharSequence subSequence(int start, int end)
- Specified by:
subSequencein interfaceCharSequence
-
getUTF16SortedAsUTF8Comparator
public static Comparator<CharsRef> getUTF16SortedAsUTF8Comparator()
-
-