public final class StringOption extends ValueOption<StringOption>
null
.
The following snippet works well for comparing StringOption
with a constant value:
class Something {
static final StringOption TARGET = new StringOption("something");
void something(Hoge hoge) {
if (hoge.getValueOption().equals(TARGET)) {
....
}
}
}
nullValue
Constructor and Description |
---|
StringOption()
Creates a new instance which represents
null value. |
StringOption(String textOrNull)
Creates a new instance which represents the specified value.
|
Modifier and Type | Method and Description |
---|---|
StringBuilder |
appendTo(StringBuilder buffer)
Appends the text in this object into the given
StringBuilder . |
static int |
compareBytes(byte[] b1,
int s1,
int l1,
byte[] b2,
int s2,
int l2)
Compares between the two objects in serialized form.
|
int |
compareInBytes(byte[] b1,
int o1,
byte[] b2,
int o2)
Compares two objects in bytes.
|
int |
compareTo(WritableRawComparable o) |
boolean |
contains(String sub)
Returns whether or not this text contains the given substring.
|
boolean |
contains(StringOption sub)
Returns whether or not this text contains the given substring.
|
void |
copyFrom(StringOption optionOrNull)
Deprecated.
|
boolean |
endsWith(String suffix)
Returns whether or not this text ends with the given suffix.
|
boolean |
endsWith(StringOption suffix)
Returns whether or not this text ends with the given suffix.
|
boolean |
equals(Object obj) |
org.apache.hadoop.io.Text |
get()
Returns the value which this object represents.
|
String |
getAsString()
Returns the value which this object represents.
|
static int |
getBytesLength(byte[] bytes,
int offset,
int length)
Returns the actual number of bytes from the serialized byte array.
|
int |
getSizeInBytes(byte[] buf,
int offset)
Computes and returns size in bytes.
|
boolean |
has(String other)
Returns whether both this object and the specified value represents an equivalent value or not.
|
boolean |
has(org.apache.hadoop.io.Text other)
Returns whether both this object and the specified value represents an equivalent value or not.
|
int |
hashCode() |
boolean |
isEmpty()
Returns whether or not this text is empty.
|
StringOption |
modify(byte[] utf8,
int offset,
int length)
Deprecated.
Application developer should not use this method directly
|
StringOption |
modify(String newText)
Deprecated.
Application developer should not use this method directly
|
StringOption |
modify(org.apache.hadoop.io.Text newText)
Deprecated.
Application developer should not use this method directly
|
String |
or(String alternate)
Returns the value which this object represents.
|
org.apache.hadoop.io.Text |
or(org.apache.hadoop.io.Text alternate)
Returns the value which this object represents.
|
void |
readFields(DataInput in) |
void |
reset()
Reset this object to an empty character string.
|
int |
restore(byte[] bytes,
int offset,
int limit)
Restores the contents from the slice of the byte array.
|
boolean |
startsWith(String prefix)
Returns whether or not this text starts with the given prefix.
|
boolean |
startsWith(StringOption prefix)
Returns whether or not this text starts with the given prefix.
|
String |
toString() |
void |
write(DataOutput out) |
public StringOption()
null
value.public StringOption(String textOrNull)
textOrNull
- the initial value (nullable)public org.apache.hadoop.io.Text get()
null
NullPointerException
- if this object represents null
public String getAsString()
null
NullPointerException
- if this object represents null
appendTo(StringBuilder)
public StringBuilder appendTo(StringBuilder buffer)
StringBuilder
.buffer
- the destination StringBuilder
StringBuilder
NullPointerException
- if this object represents null
public boolean isEmpty()
true
if this text is empty, or false
if it has any charactersNullPointerException
- if this object represents null
public org.apache.hadoop.io.Text or(org.apache.hadoop.io.Text alternate)
alternate
- the alternative value for null
null
public String or(String alternate)
alternate
- the alternative value for null
null
public void reset()
null
.@Deprecated public StringOption modify(org.apache.hadoop.io.Text newText)
newText
- the value (nullable)@Deprecated public StringOption modify(String newText)
newText
- the value (nullable)@Deprecated public StringOption modify(byte[] utf8, int offset, int length)
utf8
- the UTF-8 encode byte arrayoffset
- the offset in the byte arraylength
- the content length in bytes@Deprecated public void copyFrom(StringOption optionOrNull)
ValueOption
copyFrom
in class ValueOption<StringOption>
optionOrNull
- the source object, or null
to make this value represent null
public boolean has(String other)
other
- the target value (nullable)true
if this object has the specified value, otherwise false
public boolean has(org.apache.hadoop.io.Text other)
other
- the target value (nullable)true
if this object has the specified value, otherwise false
public boolean contains(String sub)
sub
- the substringtrue
if this has the given substring or the substring is empty, otherwise false
NullPointerException
- if this or the substring is null
public boolean contains(StringOption sub)
sub
- the substringtrue
if this has the given substring or the substring is empty, otherwise false
NullPointerException
- if this or the substring is null
public boolean startsWith(String prefix)
prefix
- the prefixtrue
if this has the given prefix or the prefix is empty, otherwise false
NullPointerException
- if this or the prefix is null
public boolean startsWith(StringOption prefix)
prefix
- the prefixtrue
if this has the given prefix or the prefix is empty, otherwise false
NullPointerException
- if this or the prefix is null
public boolean endsWith(String suffix)
suffix
- the suffixtrue
if this has the given suffix or the suffix is empty, otherwise false
NullPointerException
- if this or the suffix is null
public boolean endsWith(StringOption suffix)
suffix
- the suffixtrue
if this has the given suffix or the suffix is empty, otherwise false
NullPointerException
- if this or the suffix is null
public int compareTo(WritableRawComparable o)
public void write(DataOutput out) throws IOException
IOException
public void readFields(DataInput in) throws IOException
IOException
public int restore(byte[] bytes, int offset, int limit) throws IOException
Restorable
bytes
- the byte arrayoffset
- the beginning index in the byte array (inclusive)limit
- the ending index in the byte array (exclusive)IOException
- if failed to restore the contentspublic int getSizeInBytes(byte[] buf, int offset) throws IOException
WritableRawComparable
buf
- bytes arrayoffset
- bytes offsetIOException
- if failed to compute sizepublic int compareInBytes(byte[] b1, int o1, byte[] b2, int o2) throws IOException
WritableRawComparable
b1
- bytes representation of the first objecto1
- offset of the first objectb2
- bytes representation of the second objecto2
- offset of the second objectIOException
- if failed to comparisonpublic static int getBytesLength(byte[] bytes, int offset, int length)
bytes
- the target byte arrayoffset
- the beginning index in the byte array (inclusive)length
- the limit length of the byte arraypublic static int compareBytes(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2)
b1
- the first byte array to be compareds1
- the beginning index in b1
l1
- the limit byte size in b1
b2
- the second byte array to be compareds2
- the beginning index in b2
l2
- the limit byte size in b2
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.