Class DBType
- java.lang.Object
-
- adql.db.DBType
-
public class DBType extends java.lang.ObjectDescribe a full column type as it is described in the IVOA document of TAP. Thus, this object contains 2 attributes:
type(or datatype) andlength(or size).The length/size may be not defined ; in this case, its value is set to
NO_LENGTHor is negative or null.All datatypes declared in the IVOA recommendation document of TAP are listed in an enumeration type:
DBType.DBDatatype. It is used to set the attribute type/datatype of this class.- Since:
- 1.3
- Version:
- 1.4 (07/2016)
- Author:
- Grégory Mantelet (ARI)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDBType.DBDatatypeList of all datatypes declared in the IVOA recommendation of TAP (in the section UPLOAD).
-
Field Summary
Fields Modifier and Type Field Description intlengthThe length parameter (only few datatypes need this parameter: char, varchar, binary and varbinary).static intNO_LENGTHSpecial value in case no length/size is specified.DBType.DBDatatypetypeDatatype of a column.
-
Constructor Summary
Constructors Constructor Description DBType(DBType.DBDatatype datatype)Build a TAP column type by specifying a datatype.DBType(DBType.DBDatatype datatype, int length)Build a TAP column type by specifying a datatype and a length (needed only for datatypes like char, varchar, binary and varbinary).
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisBinary()Tells whether this type is a list of bytes.booleanisCompatible(DBType t)Tell whether thisDBTypeis compatible with the given one.booleanisGeometry()Tells whether this type is a geometrical region.booleanisNumeric()Tells whether this type is a numeric.booleanisString()Tells whether this type is about characters.booleanisUnknown()Tell whether this type has been resolved or not.java.lang.StringtoString()
-
-
-
Field Detail
-
NO_LENGTH
public static final int NO_LENGTH
Special value in case no length/size is specified.- See Also:
- Constant Field Values
-
type
public final DBType.DBDatatype type
Datatype of a column.
-
length
public final int length
The length parameter (only few datatypes need this parameter: char, varchar, binary and varbinary).
-
-
Constructor Detail
-
DBType
public DBType(DBType.DBDatatype datatype)
Build a TAP column type by specifying a datatype.- Parameters:
datatype- Column datatype.
-
DBType
public DBType(DBType.DBDatatype datatype, int length)
Build a TAP column type by specifying a datatype and a length (needed only for datatypes like char, varchar, binary and varbinary).- Parameters:
datatype- Column datatype.length- Length of the column value (needed only for datatypes like char, varchar, binary and varbinary).
-
-
Method Detail
-
isNumeric
public boolean isNumeric()
Tells whether this type is a numeric.
Concerned types:
SMALLINT,INTEGER,BIGINT,REAL,DOUBLE,BINARY,VARBINARYandBLOB.Important note: Since
UNKNOWNis an unresolved type, it can potentially be anything. But, in order to avoid incorrect operation while expecting a numeric although the type is unknown and is in fact not really a numeric, this function will returnfalseif the type isUNKNOWNBUTtrueifUNKNOWN_NUMERIC.- Returns:
trueif this type is a numeric,falseotherwise.
-
isBinary
public boolean isBinary()
Tells whether this type is a list of bytes.
Concerned types:
BINARY,VARBINARYandBLOB.Important note: Since
UNKNOWNis an unresolved type, it can potentially be anything. But, in order to avoid incorrect operation while expecting a binary although the type is unknown and is in fact not really a binary, this function will returnfalseif the type isUNKNOWNorUNKNOWN_NUMERIC.- Returns:
trueif this type is a binary,falseotherwise.
-
isString
public boolean isString()
Tells whether this type is about characters.
Concerned types:
CHAR,VARCHAR,CLOBandTIMESTAMP.Important note: Since
UNKNOWNis an unresolved type, it can potentially be anything. But, in order to avoid incorrect operation while expecting a string although the type is unknown and is in fact not really a string, this function will returnfalseif the type isUNKNOWNorUNKNOWN_NUMERIC- Returns:
trueif this type is a string,falseotherwise.
-
isGeometry
public boolean isGeometry()
Tells whether this type is a geometrical region.
Concerned types:
POINTandREGION.Important note: Since
UNKNOWNis an unresolved type, it can potentially be anything. But, in order to avoid incorrect operation while expecting a geometry although the type is unknown and is in fact not really a geometry, this function will returnfalseif the type isUNKNOWNorUNKNOWN_NUMERIC.- Returns:
trueif this type is a geometry,falseotherwise.
-
isUnknown
public boolean isUnknown()
Tell whether this type has been resolved or not.
Concerned types:
UNKNOWNandUNKNOWN_NUMERIC.- Returns:
trueif this type has NOT been resolved,falseotherwise.- Since:
- 1.4
-
isCompatible
public boolean isCompatible(DBType t)
Tell whether this
DBTypeis compatible with the given one.Two
DBTypes are said compatible if they are both binary, numeric, geometric or string. If one of the two types isunknownorunknown_numeric, this function will consider them as compatible and will returntrue.- Parameters:
t- The type to compare to.- Returns:
trueif this type is compatible with the given one,falseotherwise.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-