Class DefaultValueInfo
- All Implemented Interfaces:
ValueInfo
- Direct Known Subclasses:
ColumnInfo
ValueInfo interface.
Additionally provides mutator methods for the accessors defined in
ValueInfo.- Author:
- Mark Taylor (Starlink)
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new genericDefaultValueInfoobject without a name.DefaultValueInfo(String name) Constructs a new genericDefaultValueInfoobject with a given name.DefaultValueInfo(String name, Class<?> contentClass) Constructs a newDefaultValueInfoobject with a given name and class.DefaultValueInfo(String name, Class<?> contentClass, String description) Constructs a newDefaultValueInfoobject with a given name, class and description.DefaultValueInfo(ValueInfo base) Constructs a DefaultValueInfo object which is a copy of an existing one. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatClass(Class<?> clazz) Returns a human-friendly string indicating the class and shape of a given class object.static StringformatShape(int[] shape) Returns a string representing the shape of this object, if it is array-like.formatValue(Object value, int maxLength) Returns a string representation of a given value described by thisValueInfo.static ValueInfogeneralise(ValueInfo vi1, ValueInfo vi2) Returns aValueInfoobject which is sufficiently general to cover every object described by either of two givenValueInfoobjects.Returns a list of auxiliary metadata objects pertaining to this column.Class<?> Returns the java class of the values described by this object.Returns a description of the values described by this object.Returns an array of objects which may be able to convert from the values described by this info to a particular target value domain.intMay indicate the size of a value element stored as the value of this info.getName()Returns the name of this object.int[]getShape()Returns the shape associated with array value types.getUCD()Returns the Unified Column Descriptor string applying to the values described by this object.Returns a string representing the units of the values described by this object.getUtype()Returns the Utype string applying to the values described by this object.getXtype()Returns the Xtype string applying to the values described by this object.booleanisArray()Indicates whether the values described by this object are java arrays.booleanIndicates whether values returned described by this object may have the valuenull.voidsetAuxData(List<DescribedValue> auxData) Sets the list of auxiliary metadata items for this column.voidsetContentClass(Class<?> contentClass) Sets the java class of objects contained in this column.voidsetDescription(String description) Sets a textual description of the values described by this object.voidsetDomainMappers(DomainMapper[] domainMappers) Sets the domain mappers known for this object.voidsetElementSize(int size) Sets the element size of values described by this object.voidSets the name for this object.voidsetNullable(boolean isNullable) Sets whether values described by this object may have the valuenull.voidsetShape(int[] shape) Sets the shape of values described by this object.voidSets the Unified Content Descriptor string applying to values described by this object.voidsetUnitString(String unitString) Sets the string representing the units for the values described by this object.voidSets the Utype string applying to values described by this object.voidSets the Xtype string applying to values described by this object.toString()Returns a string representation of this object.static int[]unformatShape(String txt) Takes a stringified version of the shape and turns it into an array.unformatString(String rep) Returns an object of the sort described by thisValueInforepresented by the given stringrep.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface uk.ac.starlink.table.ValueInfo
getAuxDatumByName, setAuxDatum
-
Constructor Details
-
DefaultValueInfo
public DefaultValueInfo()Constructs a new genericDefaultValueInfoobject without a name. -
DefaultValueInfo
Constructs a new genericDefaultValueInfoobject with a given name.- Parameters:
name- the name applying to described values
-
DefaultValueInfo
Constructs a newDefaultValueInfoobject with a given name and class.- Parameters:
name- the name applying to described valuescontentClass- the class of which described values should be instances
-
DefaultValueInfo
Constructs a newDefaultValueInfoobject with a given name, class and description.- Parameters:
name- the name applying to described valuescontentClass- the class of which described values should be instancesdescription- a textual description of the described values
-
DefaultValueInfo
Constructs a DefaultValueInfo object which is a copy of an existing one. The fields of the new object are copies (where possible not references to) those of the base one.- Parameters:
base- the object to copy
-
-
Method Details
-
setName
Sets the name for this object.- Parameters:
name- the name
-
getName
Description copied from interface:ValueInfoReturns the name of this object. -
setUnitString
Sets the string representing the units for the values described by this object.- Parameters:
unitString- a string giving the units, ornullif units are unknown
-
getUnitString
Description copied from interface:ValueInfoReturns a string representing the units of the values described by this object. The syntax and conventions should ideally match those adopted by VOTable, as defined by CDS.- Specified by:
getUnitStringin interfaceValueInfo- Returns:
- a string giving the units, or
nullif units are unknown - See Also:
-
setUCD
Sets the Unified Content Descriptor string applying to values described by this object.- Parameters:
ucd- the UCD, ornullif none is known
-
getUCD
Description copied from interface:ValueInfoReturns the Unified Column Descriptor string applying to the values described by this object. -
setUtype
Sets the Utype string applying to values described by this object.- Parameters:
utype- the Utype, ornullif none is known
-
getUtype
Description copied from interface:ValueInfoReturns the Utype string applying to the values described by this object. Utype is a string which references a data model. It is used pervasively within IVOA standards; probably an official IVOA definition of Utype syntax and semantics will arise one day. -
setXtype
Sets the Xtype string applying to values described by this object.- Parameters:
xtype- the Xtype, ornullif none is known
-
getXtype
Description copied from interface:ValueInfoReturns the Xtype string applying to the values described by this object. The Xtype string is the 'extended type' information characterising the data type beyond the primitive data type. It is used within IVOA standards, and a number of standard values are defined within the DALI standard. -
setDescription
Sets a textual description of the values described by this object.- Parameters:
description- a texttual description of this column, or the empty string "" if there is nothing to be said
-
getDescription
Description copied from interface:ValueInfoReturns a description of the values described by this object. It may contain a short or long textual description of the kind of information represented by the value.- Specified by:
getDescriptionin interfaceValueInfo- Returns:
- a textual description, or the empty string "" if there is nothing to be said
-
getContentClass
Description copied from interface:ValueInfoReturns the java class of the values described by this object. The intention is that anyObjectdescribed by thisValueInfowill 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.classet al.); the appropriate wrapper classes must be used instead (Integer.classetc).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
getShapemethod. There is nothing to stop you describing arrays of arrays with aValueInfo, 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.- Specified by:
getContentClassin interfaceValueInfo- Returns:
- the java class
-
setContentClass
Sets the java class of objects contained in this column.- Parameters:
contentClass- the class of items in this column- Throws:
IllegalArgumentException- ifcontentClassis primitive
-
isArray
public boolean isArray()Description copied from interface:ValueInfoIndicates whether the values described by this object are java arrays. This convenience method should return the same asgetContentClass().getComponentType()!=null -
getShape
public int[] getShape()Description copied from interface:ValueInfoReturns the shape associated with array value types. If the class returned byValueInfo.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
getContentClassdoes not give an array type (henceisArrayreturns false) the return value for this method is undefined (but should probably benull). -
setShape
public void setShape(int[] shape) Sets the shape of values described by this object.- Parameters:
shape- the shape- Throws:
IllegalArgumentException- ifshapehas elements apart from the last one which are <=0
-
getElementSize
public int getElementSize()Description copied from interface:ValueInfoMay indicate the size of a value element stored as the value of this info. The total size of the value will in this case be the return value of this method multiplied by the number of elements, as indicated byValueInfo.getShape()(or by 1, ifgetShapeis 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.
- Specified by:
getElementSizein interfaceValueInfo- Returns:
- notional size of each element an array of values described by this info
-
setElementSize
public void setElementSize(int size) Sets the element size of values described by this object.- Parameters:
size- the element size
-
isNullable
public boolean isNullable()Description copied from interface:ValueInfoIndicates whether values returned described by this object may have the valuenull. In general this should returntrue, which implies no assertion about the return values (they may or may not benull). But if the values are known never to benull, it may returnfalse.- Specified by:
isNullablein interfaceValueInfo- Returns:
falseif values are guaranteed non-null
-
setNullable
public void setNullable(boolean isNullable) Sets whether values described by this object may have the valuenull. By setting this tofalseyou assert that nonullobjects will be returned from this column.- Parameters:
isNullable-falseif objects in this column are guaranteed non-null
-
getDomainMappers
Description copied from interface:ValueInfoReturns an array of objects which may be able to convert from the values described by this info to a particular target value domain. This can used for non-obvious representations of certain coordinates such as time and angular position. In most cases the returned array will be empty, since the target domain is obvious (e.g. numeric values). In the (unusual) case that the returned array contains multiple entries, it should have no more than one for any given target domain, and the first entry may be considered "primary" in some sense. Absence of a mapper for a given target domain does not necessarily indicate that the described values cannot be used in that domain.- Specified by:
getDomainMappersin interfaceValueInfo- Returns:
- array of domain mappers for the values described by this info
-
setDomainMappers
Sets the domain mappers known for this object.- Parameters:
domainMappers- new domain mapper array
-
getAuxData
Returns a list of auxiliary metadata objects pertaining to this column. The returned value may, if mutable, be modified to change the aux data of this object.- Specified by:
getAuxDatain interfaceValueInfo- Returns:
- a List of
DescribedValueitems
-
setAuxData
Sets the list of auxiliary metadata items for this column.- Parameters:
auxData- a list ofDescribedValueobjects
-
generalise
Returns aValueInfoobject which is sufficiently general to cover every object described by either of two givenValueInfoobjects. 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.- Parameters:
vi1- oneValueInfoobjectvi2- the otherValueInfoobject- Returns:
- a generalised
ValueInfoobject
-
formatValue
Description copied from interface:ValueInfoReturns a string representation of a given value described by thisValueInfo. The returned string should be no longer than a given maximum length.- Specified by:
formatValuein interfaceValueInfo- Parameters:
value- the value to representmaxLength- the maximum number of characters in the returned string
-
formatClass
Returns a human-friendly string indicating the class and shape of a given class object. This will read something like "Integer" or "byte[][]" or "uk.ac.starlink.FrameSet".- Parameters:
clazz- the class- Returns:
- a string showing the class and shape of
clazz
-
formatShape
Returns a string representing the shape of this object, if it is array-like. This will look something like "1024,1024,3" or "2,*".- Parameters:
shape- the shape to format- Returns:
- a human-readable representation of the value shape
- See Also:
-
unformatShape
Takes a stringified version of the shape and turns it into an array. This performs the opposite offormatShape(int[]), so values are comma-separated, and the last one only may be "*".- Parameters:
txt- string representation of value shape- Returns:
- array representation of value shape
- Throws:
IllegalArgumentException- if the argument is not in a comprehensible format- See Also:
-
unformatString
Description copied from interface:ValueInfoReturns an object of the sort described by thisValueInforepresented by the given stringrep.- Specified by:
unformatStringin interfaceValueInfo- Parameters:
rep- the string representation of a value described by thisValueInfo- Returns:
- the Object value represented by
rep; must match this info's content class (or be null)
-
toString
Returns a string representation of this object. The result indicates the object's name, class and shape.
-