org.apache.hadoop.hbase.io
Class TextSequence

java.lang.Object
  extended by org.apache.hadoop.io.Text
      extended by org.apache.hadoop.hbase.io.TextSequence
All Implemented Interfaces:
Comparable, org.apache.hadoop.io.Writable, org.apache.hadoop.io.WritableComparable

public class TextSequence
extends org.apache.hadoop.io.Text

As CharSequence is to String, so is TextSequence to Text (except a TextSequence is a Text whereas a String is a CharSequence). Use when you want to conserve on object creation.

Use with care. If danger that the passed in Text instance can change during the life of this TextSequence, concretize this TextSequence by calling toText().

Equals considers a Text equal if the TextSequence brackets the same bytes.

TextSequence will not always work as a Text. For instance, the following fails Text c = new Text(new TextSequence(new Text("some string"))); because the Text constructor accesses private Text data members making the new instance from the passed 'Text'.

TODO: Should this be an Interface as CharSequence is?


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.hadoop.io.Text
org.apache.hadoop.io.Text.Comparator
 
Constructor Summary
TextSequence()
           
TextSequence(org.apache.hadoop.io.Text d)
           
TextSequence(org.apache.hadoop.io.Text d, int s)
           
TextSequence(org.apache.hadoop.io.Text d, int s, int e)
           
 
Method Summary
 int charAt(int position)
           
 int compareTo(Object o)
           
 boolean equals(Object o)
           
 int find(String what)
           
 int find(String what, int s)
           
 byte[] getBytes()
           
 int getLength()
           
 int hashCode()
           
 void readFields(DataInput in)
           
 void set(byte[] utf8)
           
 void set(byte[] utf8, int start, int len)
           
 void set(String string)
           
 void set(org.apache.hadoop.io.Text other)
           
 String toString()
           
 org.apache.hadoop.io.Text toText()
           
 void write(DataOutput out)
           
 
Methods inherited from class org.apache.hadoop.io.Text
append, bytesToCodePoint, clear, decode, decode, decode, encode, encode, readString, skip, utf8Length, validateUTF8, validateUTF8, writeString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TextSequence

public TextSequence()

TextSequence

public TextSequence(org.apache.hadoop.io.Text d)

TextSequence

public TextSequence(org.apache.hadoop.io.Text d,
                    int s)

TextSequence

public TextSequence(org.apache.hadoop.io.Text d,
                    int s,
                    int e)
Method Detail

charAt

public int charAt(int position)
Overrides:
charAt in class org.apache.hadoop.io.Text

compareTo

public int compareTo(Object o)
Specified by:
compareTo in interface Comparable
Overrides:
compareTo in class org.apache.hadoop.io.Text

equals

public boolean equals(Object o)
Overrides:
equals in class org.apache.hadoop.io.Text

find

public int find(String what,
                int s)
Overrides:
find in class org.apache.hadoop.io.Text

find

public int find(String what)
Overrides:
find in class org.apache.hadoop.io.Text

getBytes

public byte[] getBytes()
Overrides:
getBytes in class org.apache.hadoop.io.Text

toText

public org.apache.hadoop.io.Text toText()
Returns:
A new Text instance made from the bytes this TextSequence covers.

getLength

public int getLength()
Overrides:
getLength in class org.apache.hadoop.io.Text

hashCode

public int hashCode()
Overrides:
hashCode in class org.apache.hadoop.io.Text

set

public void set(byte[] utf8,
                int start,
                int len)
Overrides:
set in class org.apache.hadoop.io.Text

set

public void set(byte[] utf8)
Overrides:
set in class org.apache.hadoop.io.Text

set

public void set(String string)
Overrides:
set in class org.apache.hadoop.io.Text

set

public void set(org.apache.hadoop.io.Text other)
Overrides:
set in class org.apache.hadoop.io.Text

toString

public String toString()
Overrides:
toString in class org.apache.hadoop.io.Text

readFields

public void readFields(DataInput in)
                throws IOException
Specified by:
readFields in interface org.apache.hadoop.io.Writable
Overrides:
readFields in class org.apache.hadoop.io.Text
Throws:
IOException

write

public void write(DataOutput out)
           throws IOException
Specified by:
write in interface org.apache.hadoop.io.Writable
Overrides:
write in class org.apache.hadoop.io.Text
Throws:
IOException


Copyright © 2008 The Apache Software Foundation