org.apache.lucene.util
Class CharsRef

java.lang.Object
  extended by org.apache.lucene.util.CharsRef
All Implemented Interfaces:
CharSequence, Comparable<CharsRef>

public final class CharsRef
extends Object
implements Comparable<CharsRef>, CharSequence

Represents char[], as a slice (offset + length) into an existing char[]. The chars member should never be null; use EMPTY_ARRAY if necessary.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

Field Summary
 char[] chars
           
 int length
           
 int offset
           
 
Constructor Summary
CharsRef()
          Creates a new CharsRef initialized an empty array zero-length
CharsRef(char[] chars, int offset, int length)
          Creates a new CharsRef initialized with the given array, offset and length
CharsRef(CharsRef other)
          Creates a new CharsRef and copies the contents of the source into the new instance.
CharsRef(int capacity)
          Creates a new CharsRef initialized with an array of the given capacity
CharsRef(String string)
          Creates a new CharsRef initialized with the given Strings character array
 
Method Summary
 void append(char[] otherChars, int otherOffset, int otherLength)
          Appends the given array to this CharsRef starting at the current offset
 char charAt(int index)
           
 boolean charsEquals(CharsRef other)
           
 Object clone()
           
 int compareTo(CharsRef other)
          Signed int order comparison
 void copy(char[] otherChars, int otherOffset, int otherLength)
          Copies the given array into this CharsRef starting at offset 0
 void copy(CharsRef other)
          Copies the given CharsRef referenced content into this instance starting at offset 0.
 boolean equals(Object other)
           
static Comparator<CharsRef> getUTF16SortedAsUTF8Comparator()
           
 void grow(int newLength)
           
 int hashCode()
           
 int length()
           
 CharSequence subSequence(int start, int end)
           
 String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

chars

public char[] chars

offset

public int offset

length

public int length
Constructor Detail

CharsRef

public CharsRef()
Creates a new CharsRef initialized an empty array zero-length


CharsRef

public CharsRef(int capacity)
Creates a new CharsRef initialized with an array of the given capacity


CharsRef

public CharsRef(char[] chars,
                int offset,
                int length)
Creates a new CharsRef initialized with the given array, offset and length


CharsRef

public CharsRef(String string)
Creates a new CharsRef initialized with the given Strings character array


CharsRef

public CharsRef(CharsRef other)
Creates a new CharsRef and copies the contents of the source into the new instance.

See Also:
copy(CharsRef)
Method Detail

clone

public Object clone()
Overrides:
clone in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

equals

public boolean equals(Object other)
Overrides:
equals in class Object

charsEquals

public boolean charsEquals(CharsRef other)

compareTo

public int compareTo(CharsRef other)
Signed int order comparison

Specified by:
compareTo in interface Comparable<CharsRef>

copy

public void copy(CharsRef other)
Copies the given CharsRef referenced content into this instance starting at offset 0.

Parameters:
other - the CharsRef to copy

grow

public void grow(int newLength)

copy

public void copy(char[] otherChars,
                 int otherOffset,
                 int otherLength)
Copies the given array into this CharsRef starting at offset 0


append

public void append(char[] otherChars,
                   int otherOffset,
                   int otherLength)
Appends the given array to this CharsRef starting at the current offset


toString

public String toString()
Specified by:
toString in interface CharSequence
Overrides:
toString in class Object

length

public int length()
Specified by:
length in interface CharSequence

charAt

public char charAt(int index)
Specified by:
charAt in interface CharSequence

subSequence

public CharSequence subSequence(int start,
                                int end)
Specified by:
subSequence in interface CharSequence

getUTF16SortedAsUTF8Comparator

public static Comparator<CharsRef> getUTF16SortedAsUTF8Comparator()


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.