public class DefaultValueInfo extends java.lang.Object implements ValueInfo
ValueInfo
interface.
Additionally provides mutator methods for the accessors defined in
ValueInfo
.Constructor and Description |
---|
DefaultValueInfo()
Constructs a new generic
DefaultValueInfo object
without a name. |
DefaultValueInfo(java.lang.String name)
Constructs a new generic
DefaultValueInfo object
with a given name. |
DefaultValueInfo(java.lang.String name,
java.lang.Class<?> contentClass)
Constructs a new
DefaultValueInfo object with a given
name and class. |
DefaultValueInfo(java.lang.String name,
java.lang.Class<?> contentClass,
java.lang.String description)
Constructs a new
DefaultValueInfo object with a given
name, class and description. |
DefaultValueInfo(ValueInfo base)
Constructs a DefaultValueInfo object which is a copy of an existing one.
|
Modifier and Type | Method and Description |
---|---|
static java.lang.String |
formatClass(java.lang.Class<?> clazz)
Returns a human-friendly string indicating the class and shape
of a given class object.
|
static java.lang.String |
formatShape(int[] shape)
Returns a string representing the shape of this object, if it
is array-like.
|
java.lang.String |
formatValue(java.lang.Object value,
int maxLength)
Returns a string representation of a given value described by this
ValueInfo . |
static ValueInfo |
generalise(ValueInfo vi1,
ValueInfo vi2)
Returns a
ValueInfo object which is sufficiently general
to cover every object described by either of two given
ValueInfo objects. |
java.util.List<DescribedValue> |
getAuxData()
Returns a list of auxiliary metadata objects
pertaining to this column.
|
java.lang.Class<?> |
getContentClass()
Returns the java class of the values described by this object.
|
java.lang.String |
getDescription()
Returns a description of the values described by this object.
|
DomainMapper[] |
getDomainMappers()
Returns an array of objects which may be able to convert from the
values described by this info to a particular target value domain.
|
int |
getElementSize()
May indicate the size of a value element stored as the value of
this info.
|
java.lang.String |
getName()
Returns the name of this object.
|
int[] |
getShape()
Returns the shape associated with array value types.
|
java.lang.String |
getUCD()
Returns the Unified Column Descriptor string applying to the
values described by this object.
|
java.lang.String |
getUnitString()
Returns a string representing the units of the values described by
this object.
|
java.lang.String |
getUtype()
Returns the Utype string applying to the values described by
this object.
|
java.lang.String |
getXtype()
Returns the Xtype string applying to the values described by
this object.
|
boolean |
isArray()
Indicates whether the values described by this object are java arrays.
|
boolean |
isNullable()
Indicates whether values returned described by this object may have the
value
null . |
void |
setAuxData(java.util.List<DescribedValue> auxData)
Sets the list of auxiliary metadata items for this column.
|
void |
setContentClass(java.lang.Class<?> contentClass)
Sets the java class of objects contained in this column.
|
void |
setDescription(java.lang.String description)
Sets a textual description of the values described by this object.
|
void |
setDomainMappers(DomainMapper[] domainMappers)
Sets the domain mappers known for this object.
|
void |
setElementSize(int size)
Sets the element size of values described by this object.
|
void |
setName(java.lang.String name)
Sets the name for this object.
|
void |
setNullable(boolean isNullable)
Sets whether values described by this object may have the value
null . |
void |
setShape(int[] shape)
Sets the shape of values described by this object.
|
void |
setUCD(java.lang.String ucd)
Sets the Unified Content Descriptor string applying to values
described by this object.
|
void |
setUnitString(java.lang.String unitString)
Sets the string representing the units for the values described by
this object.
|
void |
setUtype(java.lang.String utype)
Sets the Utype string applying to values described by this object.
|
void |
setXtype(java.lang.String xtype)
Sets the Xtype string applying to values described by this object.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
static int[] |
unformatShape(java.lang.String txt)
Takes a stringified version of the shape and turns it into
an array.
|
java.lang.Object |
unformatString(java.lang.String rep)
Returns an object of the sort described by this
ValueInfo
represented by the given string rep . |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getAuxDatumByName, setAuxDatum
public DefaultValueInfo()
DefaultValueInfo
object
without a name.public DefaultValueInfo(java.lang.String name)
DefaultValueInfo
object
with a given name.name
- the name applying to described valuespublic DefaultValueInfo(java.lang.String name, java.lang.Class<?> contentClass)
DefaultValueInfo
object with a given
name and class.name
- the name applying to described valuescontentClass
- the class of which described values should be
instancespublic DefaultValueInfo(java.lang.String name, java.lang.Class<?> contentClass, java.lang.String description)
DefaultValueInfo
object with a given
name, class and description.name
- the name applying to described valuescontentClass
- the class of which described values should be
instancesdescription
- a textual description of the described valuespublic DefaultValueInfo(ValueInfo base)
base
- the object to copypublic void setName(java.lang.String name)
name
- the namepublic java.lang.String getName()
ValueInfo
public void setUnitString(java.lang.String unitString)
unitString
- a string giving the units, or null
if
units are unknownpublic java.lang.String getUnitString()
ValueInfo
getUnitString
in interface ValueInfo
null
if units are
unknownpublic void setUCD(java.lang.String ucd)
ucd
- the UCD, or null
if none is knownpublic java.lang.String getUCD()
ValueInfo
getUCD
in interface ValueInfo
null
if none is knownUCD
public void setUtype(java.lang.String utype)
utype
- the Utype, or null
if none is knownpublic java.lang.String getUtype()
ValueInfo
public void setXtype(java.lang.String xtype)
xtype
- the Xtype, or null
if none is knownpublic java.lang.String getXtype()
ValueInfo
public void setDescription(java.lang.String description)
description
- a texttual description of this column,
or the empty string "" if there is nothing to be saidpublic java.lang.String getDescription()
ValueInfo
getDescription
in interface ValueInfo
public java.lang.Class<?> getContentClass()
ValueInfo
Object
described by this
ValueInfo
will be an instance of the returned class
or one of its subclasses. Note therefore that it must not
return one of the primitive class objects
(int.class
et al.);
the appropriate wrapper classes must be used instead
(Integer.class
etc).
The class returned should not under normal circumstances be an
array of arrays; to express multidimensionality of arrays you
should store an array of non-array objects or of primitives and
provide shape information via the getShape
method.
There is nothing to stop you describing arrays of arrays with a
ValueInfo
, but some other elements of the tables
infrastructure and applications may work on the assumption that
such objects are not present.
Note that to store sets of more than 231 items it
will be necessary to use some custom object, since java arrays
are indexed by type int
.
getContentClass
in interface ValueInfo
public void setContentClass(java.lang.Class<?> contentClass)
contentClass
- the class of items in this columnjava.lang.IllegalArgumentException
- if contentClass
is primitivepublic boolean isArray()
ValueInfo
getContentClass().getComponentType()!=null
public int[] getShape()
ValueInfo
ValueInfo.getContentClass()
is a java array type,
the return from this method may contain information about
the shape of the rectangular array which this represents.
The dimensions of the array are given in the elements of
the return value of this method, fastest varying first.
All elements of the array should be positive, except that the
last (slowest varying) element may be <=0 (conventionally -1)
to indicate that the number of (shape.length-1)
-dimensional
slices contained in the value is not known.
If nothing is known about the shape of the array values,
then a 1-element array whose only element is <=0 should be returned.
If getContentClass
does not give an array type
(hence isArray
returns false)
the return value for this method is undefined (but should probably
be null
).
public void setShape(int[] shape)
shape
- the shapejava.lang.IllegalArgumentException
- if shape
has elements apart from the last one which are <=0public int getElementSize()
ValueInfo
ValueInfo.getShape()
(or by 1, if getShape
is null).
The exact meaning of the value returned is dependent on this
ValueInfo. This method was introduced to return the maximum
number of characters in a String
-class ValueInfo;
this information is necessary for writing out to certain formats (FITS).
Other ValueInfo types however may use it for their own purposes.
ValueInfo instances which decline to supply this information should return -1 from this method.
getElementSize
in interface ValueInfo
public void setElementSize(int size)
size
- the element sizepublic boolean isNullable()
ValueInfo
null
.
In general this should return true
,
which implies no assertion about the return values (they may or
may not be null
). But if the values are known never to
be null
, it may return false
.isNullable
in interface ValueInfo
false
if values are guaranteed
non-null
public void setNullable(boolean isNullable)
null
.
By setting this to false
you assert that
no null
objects will be returned from this column.isNullable
- false
if objects in this column are
guaranteed non-null
public DomainMapper[] getDomainMappers()
ValueInfo
getDomainMappers
in interface ValueInfo
public void setDomainMappers(DomainMapper[] domainMappers)
domainMappers
- new domain mapper arraypublic java.util.List<DescribedValue> getAuxData()
getAuxData
in interface ValueInfo
DescribedValue
itemspublic void setAuxData(java.util.List<DescribedValue> auxData)
auxData
- a list of DescribedValue
objectspublic static ValueInfo generalise(ValueInfo vi1, ValueInfo vi2)
ValueInfo
object which is sufficiently general
to cover every object described by either of two given
ValueInfo
objects. For most of the info attributes this
entails setting to null any attribute which is not the same for
both, though for contentClass it involves finding the most
specific common ancestor class.vi1
- one ValueInfo
objectvi2
- the other ValueInfo
objectValueInfo
objectpublic java.lang.String formatValue(java.lang.Object value, int maxLength)
ValueInfo
ValueInfo
. The returned string should be
no longer than a given maximum length.formatValue
in interface ValueInfo
value
- the value to representmaxLength
- the maximum number of characters in the returned
stringpublic static java.lang.String formatClass(java.lang.Class<?> clazz)
clazz
- the classclazz
public static java.lang.String formatShape(int[] shape)
shape
- the shape to formatunformatShape(String)
public static int[] unformatShape(java.lang.String txt)
formatShape(int[])
,
so values are comma-separated, and the last one only may be "*".txt
- string representation of value shapejava.lang.IllegalArgumentException
- if the argument is not in a
comprehensible formatformatShape(int[])
public java.lang.Object unformatString(java.lang.String rep)
ValueInfo
ValueInfo
represented by the given string rep
.unformatString
in interface ValueInfo
rep
- the string representation of a value described by
this ValueInfo
rep
; must match
this info's content class (or be null)public java.lang.String toString()
toString
in class java.lang.Object