uk.ac.starlink.table

## Class DescribedValue

- java.lang.Object
- - uk.ac.starlink.table.DescribedValue

-     public class DescribedValue
      extends java.lang.Object

  Contains a value (an `Object`) as well as a `ValueInfo` object which provides metadata about that value (name, class, shape, units and so on).

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DescribedValue(ValueInfo vinfo)` Constructs a new `DescribedValue` object to hold values described by a given `ValueInfo` object.
    `DescribedValue(ValueInfo vinfo, java.lang.Object value)` Constructs a new `DescribedValue` object to hold values described by a given `ValueInfo` object and with a given initial value.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `ValueInfo` | `getInfo()` Returns the `ValueInfo` object which describes the value held by this object.
    `<T> T` | `getTypedValue(java.lang.Class<T> clazz)` Returns the value content of this object as a specified type.
    `java.lang.Object` | `getValue()` Returns the actual value content of this object.
    `java.lang.String` | `getValueAsString(int maxLength)` Returns a string representation of the value of this object, no longer than a given maximum length.
    `void` | `setValue(java.lang.Object value)` Sets the actual value content of this object.
    `void` | `setValueFromString(java.lang.String sval)` Sets the value of this object from a string representation.
    `java.lang.String` | `toString()` Returns a string representation of this object no longer than a default maximum length.
    `java.lang.String` | `toString(int maxLength)` Returns a string representation of this object, no longer than a given maximum length.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### DescribedValue

          public DescribedValue(ValueInfo vinfo)

      Constructs a new `DescribedValue` object to hold values described by a given `ValueInfo` object.
      Parameters:
        `vinfo` - the metadata handler for this value

    - #### DescribedValue

          public DescribedValue(ValueInfo vinfo,
                                java.lang.Object value)

      Constructs a new `DescribedValue` object to hold values described by a given `ValueInfo` object and with a given initial value.
      Parameters:
        `vinfo` - the metadata describing this object's value
        `value` - the value of this object
      Throws:
        `java.lang.IllegalArgumentException` - if `value.getClass()` is not compatible with `vinfo.getContentClass()`

  - ### Method Detail

    - #### getInfo

          public ValueInfo getInfo()

      Returns the `ValueInfo` object which describes the value held by this object.
      Returns:
        the metadata describing this object's value

    - #### setValue

          public void setValue(java.lang.Object value)

      Sets the actual value content of this object.
      Parameters:
        `value` - the value
      Throws:
        `java.lang.IllegalArgumentException` - if `value.getClass()` is not compatible with `getValueInfo().getContentClass()`

    - #### getValue

          public java.lang.Object getValue()

      Returns the actual value content of this object.
      Returns:
        the value

    - #### getTypedValue

          public <T> T getTypedValue(java.lang.Class<T> clazz)

      Returns the value content of this object as a specified type. If the value is an instance of the supplied class, it is returned; otherwise, null is returned.
      Parameters:
        `clazz` - required return type
      Returns:
        value as required type, or null

    - #### getValueAsString

          public java.lang.String getValueAsString(int maxLength)

      Returns a string representation of the value of this object, no longer than a given maximum length.
      Parameters:
        `maxLength` - the maximum number of characters in the returned string

    - #### setValueFromString

          public void setValueFromString(java.lang.String sval)

      Sets the value of this object from a string representation.
      Parameters:
        `sval` - string representation of the new value

    - #### toString

          public java.lang.String toString(int maxLength)

      Returns a string representation of this object, no longer than a given maximum length. The result indicates the object's name, class, shape and value.
      Parameters:
        `maxLength` - the maximum number of characters in the returned string
      Returns:
        a string representation of this object

    - #### toString

          public java.lang.String toString()

      Returns a string representation of this object no longer than a default maximum length. The result indictes the object's name, class, shape and value.
      Overrides:
        `toString` in class `java.lang.Object`
      Returns:
        a string representation of this object