Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## edu.stanford.nlp.ling
Class ValueLabel

    java.lang.Object
      edu.stanford.nlp.ling.ValueLabel

All Implemented Interfaces:
  Label, Serializable, Comparable<ValueLabel>

Direct Known Subclasses:
  StringLabel

    public abstract class ValueLabel

extends Object
implements Label, Comparable<ValueLabel>, Serializable

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.

Author:
  Christopher Manning
See Also:
  Serialized Form

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

### ValueLabel

    protected ValueLabel()

Method Detail

### value

    public String value()

  Return the value of the label (or null if none). The default value returned by an `ValueLabel` is always `null`

  Specified by:
    `value` in interface `Label`
  Returns:
    the value for the label

### setValue

    public void setValue(String value)

  Set the value for the label (if one is stored).

  Specified by:
    `setValue` in interface `Label`
  Parameters:
    `value` - - the value for the label

### toString

    public String toString()

  Return a string representation of the label. This will just be the `value()` if it is non-`null`, and the empty string otherwise.

  Specified by:
    `toString` in interface `Label`
  Overrides:
    `toString` in class `Object`
  Returns:
    The string representation

### setFromString

    public void setFromString(String labelStr)

  Description copied from interface: `Label`
  Set the contents of this label to this `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.

  Specified by:
    `setFromString` in interface `Label`
  Parameters:
    `labelStr` - the String that translates into the content of the label

### equals

    public boolean equals(Object obj)

  Equality for `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.

  Overrides:
    `equals` in class `Object`
  Parameters:
    `obj` - the object against which equality is to be checked
  Returns:
    true if `this` and `obj` are equal

### hashCode

    public int hashCode()

  Return the hashCode of the String value providing there is one. Otherwise, returns an arbitrary constant for the case of `null`.

  Overrides:
    `hashCode` in class `Object`

### compareTo

    public int compareTo(ValueLabel valueLabel)

  Orders by `value()`'s lexicographic ordering.

  Specified by:
    `compareTo` in interface `Comparable<ValueLabel>`
  Parameters:
    `valueLabel` - object to compare to
  Returns:
    result (positive if this is greater than obj)

### labelFactory

    public abstract LabelFactory labelFactory()

  Returns a factory that makes Labels of the appropriate sort.

  Specified by:
    `labelFactory` in interface `Label`
  Returns:
    the `LabelFactory`

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Stanford NLP Group