Class DescribedValue

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

public class DescribedValue extends 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).
Author:
Mark Taylor (Starlink)
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs a new DescribedValue object to hold values described by a given ValueInfo object.
    Constructs a new DescribedValue object to hold values described by a given ValueInfo object and with a given initial value.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the ValueInfo object which describes the value held by this object.
    <T> T
    getTypedValue(Class<T> clazz)
    Returns the value content of this object as a specified type.
    Returns the actual value content of this object.
    getValueAsString(int maxLength)
    Returns a string representation of the value of this object, no longer than a given maximum length.
    void
    Sets the actual value content of this object.
    void
    Sets the value of this object from a string representation.
    Returns a string representation of this object no longer than a default maximum length.
    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 Details

    • 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, 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:
      IllegalArgumentException - if value.getClass() is not compatible with vinfo.getContentClass()
  • Method Details

    • 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(Object value)
      Sets the actual value content of this object.
      Parameters:
      value - the value
      Throws:
      IllegalArgumentException - if value.getClass() is not compatible with getValueInfo().getContentClass()
    • getValue

      public Object getValue()
      Returns the actual value content of this object.
      Returns:
      the value
    • getTypedValue

      public <T> T getTypedValue(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 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(String sval)
      Sets the value of this object from a string representation.
      Parameters:
      sval - string representation of the new value
    • toString

      public 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 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 Object
      Returns:
      a string representation of this object