Package org.apache.lucene.util
Class CharsRef
- java.lang.Object
-
- org.apache.lucene.util.CharsRef
-
- All Implemented Interfaces:
java.lang.CharSequence
,java.lang.Cloneable
,java.lang.Comparable<CharsRef>
public final class CharsRef extends java.lang.Object implements java.lang.Comparable<CharsRef>, java.lang.CharSequence, java.lang.Cloneable
Represents char[], as a slice (offset + length) into an existing char[]. Thechars
member should never be null; useEMPTY_CHARS
if necessary.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
CharsRef.UTF16SortedAsUTF8Comparator
Deprecated.This comparator is only a transition mechanism
-
Field Summary
Fields Modifier and Type Field Description char[]
chars
The contents of the CharsRef.static char[]
EMPTY_CHARS
An empty character array for convenienceint
length
Length of used characters.int
offset
Offset of first valid character.private static java.util.Comparator<CharsRef>
utf16SortedAsUTF8SortOrder
Deprecated.This comparator is only a transition mechanism
-
Constructor Summary
Constructors Constructor Description CharsRef()
Creates a newCharsRef
initialized an empty array zero-lengthCharsRef(char[] chars, int offset, int length)
Creates a newCharsRef
initialized with the given array, offset and lengthCharsRef(int capacity)
Creates a newCharsRef
initialized with an array of the given capacityCharsRef(java.lang.String string)
Creates a newCharsRef
initialized with the given Strings character array
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description char
charAt(int index)
boolean
charsEquals(CharsRef other)
CharsRef
clone()
Returns a shallow clone of this instance (the underlying characters are not copied and will be shared by both the returned object and this object.int
compareTo(CharsRef other)
Signed int order comparisonstatic CharsRef
deepCopyOf(CharsRef other)
Creates a new CharsRef that points to a copy of the chars fromother
boolean
equals(java.lang.Object other)
static java.util.Comparator<CharsRef>
getUTF16SortedAsUTF8Comparator()
Deprecated.This comparator is only a transition mechanismint
hashCode()
boolean
isValid()
Performs internal consistency checks.int
length()
java.lang.CharSequence
subSequence(int start, int end)
java.lang.String
toString()
-
-
-
Field Detail
-
EMPTY_CHARS
public static final char[] EMPTY_CHARS
An empty character array for convenience
-
chars
public char[] chars
The contents of the CharsRef. Should never benull
.
-
offset
public int offset
Offset of first valid character.
-
length
public int length
Length of used characters.
-
utf16SortedAsUTF8SortOrder
@Deprecated private static final java.util.Comparator<CharsRef> utf16SortedAsUTF8SortOrder
Deprecated.This comparator is only a transition mechanism
-
-
Constructor Detail
-
CharsRef
public CharsRef()
Creates a newCharsRef
initialized an empty array zero-length
-
CharsRef
public CharsRef(int capacity)
Creates a newCharsRef
initialized with an array of the given capacity
-
CharsRef
public CharsRef(char[] chars, int offset, int length)
Creates a newCharsRef
initialized with the given array, offset and length
-
CharsRef
public CharsRef(java.lang.String string)
Creates a newCharsRef
initialized with the given Strings character array
-
-
Method Detail
-
clone
public CharsRef clone()
Returns a shallow clone of this instance (the underlying characters are not copied and will be shared by both the returned object and this object.- Overrides:
clone
in classjava.lang.Object
- See Also:
deepCopyOf(org.apache.lucene.util.CharsRef)
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object other)
- Overrides:
equals
in classjava.lang.Object
-
charsEquals
public boolean charsEquals(CharsRef other)
-
compareTo
public int compareTo(CharsRef other)
Signed int order comparison- Specified by:
compareTo
in interfacejava.lang.Comparable<CharsRef>
-
toString
public java.lang.String toString()
- Specified by:
toString
in interfacejava.lang.CharSequence
- Overrides:
toString
in classjava.lang.Object
-
length
public int length()
- Specified by:
length
in interfacejava.lang.CharSequence
-
charAt
public char charAt(int index)
- Specified by:
charAt
in interfacejava.lang.CharSequence
-
subSequence
public java.lang.CharSequence subSequence(int start, int end)
- Specified by:
subSequence
in interfacejava.lang.CharSequence
-
getUTF16SortedAsUTF8Comparator
@Deprecated public static java.util.Comparator<CharsRef> getUTF16SortedAsUTF8Comparator()
Deprecated.This comparator is only a transition mechanism
-
deepCopyOf
public static CharsRef deepCopyOf(CharsRef other)
Creates a new CharsRef that points to a copy of the chars fromother
The returned CharsRef will have a length of other.length and an offset of zero.
-
isValid
public boolean isValid()
Performs internal consistency checks. Always returns true (or throws IllegalStateException)
-
-