Package uk.ac.starlink.table
Class DescribedValue
java.lang.Object
uk.ac.starlink.table.DescribedValue
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
ConstructorsConstructorDescriptionDescribedValue
(ValueInfo vinfo) Constructs a new DescribedValue object to hold values described by a given ValueInfo object.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. -
Method Summary
Modifier and TypeMethodDescriptiongetInfo()
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.getValue()
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
setValueFromString
(String sval) Sets the value of this object from a string representation.toString()
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.
-
Constructor Details
-
DescribedValue
Constructs a new DescribedValue object to hold values described by a given ValueInfo object.- Parameters:
vinfo
- the metadata handler for this value
-
DescribedValue
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 valuevalue
- the value of this object- Throws:
IllegalArgumentException
- if value.getClass() is not compatible with vinfo.getContentClass()
-
-
Method Details
-
getInfo
Returns the ValueInfo object which describes the value held by this object.- Returns:
- the metadata describing this object's value
-
setValue
Sets the actual value content of this object.- Parameters:
value
- the value- Throws:
IllegalArgumentException
- if value.getClass() is not compatible with getValueInfo().getContentClass()
-
getValue
Returns the actual value content of this object.- Returns:
- the value
-
getTypedValue
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
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
Sets the value of this object from a string representation.- Parameters:
sval
- string representation of the new value
-
toString
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
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.
-