public class StringLabel extends ValueLabel implements HasOffset
StringLabel object acts as a Label by containing a
single String, which it sets or returns in response to requests.
The hashCode() and compareTo() methods for this class assume that this
string value is non-null. equals() is correctly implemented| Constructor and Description |
|---|
StringLabel()
Create a new
StringLabel with a null content (i.e., str). |
StringLabel(Label label)
Create a new
StringLabel with the
value() of another label as its label. |
StringLabel(java.lang.String str)
Create a new
StringLabel with the given content. |
StringLabel(java.lang.String str,
int beginPosition,
int endPosition)
Create a new
StringLabel with the given content. |
| Modifier and Type | Method and Description |
|---|---|
int |
beginPosition()
Return the beginning character offset of the label (or -1 if none).
|
int |
endPosition()
Return the ending character offset of the label (or -1 if none).
|
static LabelFactory |
factory()
Return a factory for this kind of label.
|
LabelFactory |
labelFactory()
Return a factory for this kind of label
(i.e.,
StringLabel). |
void |
setBeginPosition(int beginPosition)
Set the beginning character offset for the label.
|
void |
setEndPosition(int endPosition)
Set the ending character offset of the label (or -1 if none).
|
void |
setFromString(java.lang.String str)
Set the label from a String.
|
void |
setValue(java.lang.String value)
Set the value for the label.
|
java.lang.String |
toString()
Return a string representation of the label.
|
java.lang.String |
value()
Return the word value of the label (or null if none).
|
compareTo, equals, hashCodepublic StringLabel()
StringLabel with a null content (i.e., str).public StringLabel(java.lang.String str)
StringLabel with the given content.str - The new label's contentpublic StringLabel(java.lang.String str,
int beginPosition,
int endPosition)
StringLabel with the given content.str - The new label's contentbeginPosition - Start offset in original textendPosition - End offset in original textpublic StringLabel(Label label)
StringLabel with the
value() of another label as its label.label - The other labelpublic java.lang.String value()
value in interface Labelvalue in class ValueLabelpublic void setValue(java.lang.String value)
setValue in interface LabelsetValue in class ValueLabelvalue - The value for the labelpublic void setFromString(java.lang.String str)
setFromString in interface LabelsetFromString in class ValueLabelstr - The str for the labelpublic java.lang.String toString()
ValueLabelvalue() if it is non-null,
and the empty string otherwise.toString in interface LabeltoString in class ValueLabelpublic LabelFactory labelFactory()
StringLabel).
The factory returned is always the same one (a singleton).labelFactory in interface LabellabelFactory in class ValueLabelpublic static LabelFactory factory()
public int beginPosition()
HasOffsetbeginPosition in interface HasOffsetpublic int endPosition()
HasOffsetendPosition in interface HasOffsetpublic void setBeginPosition(int beginPosition)
HasOffsetsetBeginPosition in interface HasOffsetbeginPosition - The beginning positionpublic void setEndPosition(int endPosition)
HasOffsetsetEndPosition in interface HasOffsetendPosition - The end character offset for the label