|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.stanford.nlp.ling.ValueLabel
public abstract class ValueLabel
A ValueLabel
object acts as a Label with linguistic
attributes. This is an abstract class, which doesn't actually store
or return anything. It returns null
to any requests. However,
it does
stipulate that equals() and compareTo() are defined solely with respect to
value(); this should not be changed by subclasses.
Other fields of a ValueLabel subclass should be regarded
as secondary facets (it is almost impossible to override equals in
a useful way while observing the contract for equality defined for Object,
in particular, that equality must by symmetric).
This class is designed to be extended.
Constructor Summary | |
---|---|
protected |
ValueLabel()
|
Method Summary | |
---|---|
int |
compareTo(ValueLabel valueLabel)
Orders by value() 's lexicographic ordering. |
boolean |
equals(Object obj)
Equality for ValueLabel s is defined in the first instance
as equality of their String value() . |
int |
hashCode()
Return the hashCode of the String value providing there is one. |
abstract LabelFactory |
labelFactory()
Returns a factory that makes Labels of the appropriate sort. |
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 the value of the label (or null if none). |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
protected ValueLabel()
Method Detail |
---|
public String value()
ValueLabel
is
always null
value
in interface Label
public void setValue(String value)
setValue
in interface Label
value
- - the value for the labelpublic String toString()
value()
if it is non-null
,
and the empty string otherwise.
toString
in interface Label
toString
in class Object
public void setFromString(String labelStr)
Label
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.
setFromString
in interface Label
labelStr
- the String that translates into the content of the
labelpublic boolean equals(Object obj)
ValueLabel
s is defined in the first instance
as equality of their String
value()
.
Now rewritten to correctly enforce the contract of equals in Object.
Equality for a ValueLabel
is determined simply by String
equality of its value()
. Subclasses should not redefine
this to include other aspects of the ValueLabel
, or the
contract for equals()
is broken.
equals
in class Object
obj
- the object against which equality is to be checked
this
and obj
are equalpublic int hashCode()
null
.
hashCode
in class Object
public int compareTo(ValueLabel valueLabel)
value()
's lexicographic ordering.
compareTo
in interface Comparable<ValueLabel>
valueLabel
- object to compare to
public abstract LabelFactory labelFactory()
labelFactory
in interface Label
LabelFactory
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |