|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Something that implements the Label
interface can act as a
constituent, node, or word label with linguistic attributes.
A Label
is expected to have a "primary" String
value()
(although this may be null). This is referred to as
its
value
. Equality of Labels is standardly defined by the
String equality of its value.
Implementors notes:
In general, you should live with the definition of equality, and see
other fields
of a Label subclass as secondary facets (in theory subclasses may override
this behavior, but in practice it is almost impossible to do this in
a useful way while observing the contract for equality defined for Object,
in particular, that equality must by symmetric).
A subclass that extends another Label class should override
the definition of labelFactory()
, since the contract for
this method is that it should return a factory for labels of the
exact same object type.
Method Summary | |
int |
compareTo(Object obj)
Implementation of comparison for Label . |
LabelFactory |
labelFactory()
Returns a factory that makes labels of the same type as this one. |
void |
setFromString(String labelStr)
Set the contents of this label to this String
representing the
complete contents of the label. |
void |
setValue(String value)
Set the value for the label (if one is stored). |
String |
toString()
Return a String representation of the label. |
String |
value()
Return a String representation of just the "main" value of this label. |
Method Detail |
public String value()
public void setValue(String value)
value
- - the value for the labelpublic String toString()
toString()
method
causes a label to spill its guts. It should always return an
empty string rather than null
if there is no value.
public void setFromString(String labelStr)
String
representing the
complete contents of the label. A class implementing label may
throw an UnsupportedOperationException
for this
method (only). Typically, this method would do
some appropriate decoding of the string in a way that sets
multiple fields in an inverse of the toString()
method.
labelStr
- the String that translates into the content of the
labelpublic int compareTo(Object obj)
Label
.
By default this orders by value's string lexicographic ordering.
compareTo
in interface Comparable
obj
- object to compare to
this
is greater than
obj
, 0 if equal, negative otherwise)public LabelFactory labelFactory()
null
if no appropriate factory is known.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |