Interface TargetType
- All Known Implementing Classes:
CustomTargetType
,StandardTargetType
Since it can never be an ADQL operand, it does not implements the interface
ADQLOperand
or ADQLObject
. However, it has
numerous functions that are similar in order to easily identify the nature
of the returned value (isNumeric()
, isString()
,
isGeometry()
and getReturnType()
) but also to know how it
is parameterized (getNbParameters()
, getParameters()
,
...). Besides, as any ADQL operand it also provides an information about its
position (getPosition()
).
The target type of the CAST function is an interface in order to easier its customization. By default the ADQL library uses two default implementations:
StandardTargetType
- For any of the ADQL standard type allowed for the CAST function.
CustomTargetType
- For any other type. On the contrary to the other implementation, more than one parameter is allowed and there is no constraint on their type.
- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptiongetCopy()
Create a deep copy of this target type.getName()
Get the type name (as written in ADQL).int
Get the actual number of parameters.getParameter
(int indParam) Get the indParam-th parameter.Get the ordered list of all parameters.Position of the type name (start) and all its parameters (end).Indicate the precise type of the value expected to be returned by the CAST function.boolean
Indicate whether the output of the CAST function is a geometry or not.boolean
Indicate whether the output of the CAST function is numeric or not.boolean
isString()
Indicate whether the output of the CAST function is a character string or not.setParameter
(int indParam, ADQLOperand newParam) Replace the indParam-th parameter.void
setPosition
(TextPosition newPosition) Sets the position at which thisTargetType
has been found in the original ADQL query string.toADQL()
Serialize this type into ADQL.
-
Method Details
-
getName
String getName()Get the type name (as written in ADQL).IMPORTANT: This function MUST never return NULL or an empty string.
- Returns:
- The type name.
-
getPosition
TextPosition getPosition()Position of the type name (start) and all its parameters (end).- Returns:
- Position of this target type in the input ADQL query, or NULL if this piece of information is not available.
-
setPosition
Sets the position at which thisTargetType
has been found in the original ADQL query string.- Parameters:
position
- Position of thisTargetType
.
-
isNumeric
boolean isNumeric()Indicate whether the output of the CAST function is numeric or not.Implementation note: If the return type is unknown, it is a good practice to make
isNumeric()
,isGeometry()
andisString()
to returntrue
. This information is used only by the parser when checking whether the CAST function can be used in some context. So, when the type of an ADQL operand is unknown, it is assumed it could be placed anywhere until its type can be precisely determined or until the query reaches the database.- Returns:
true
if the CAST function returns a numeric,false
otherwise.
-
isString
boolean isString()Indicate whether the output of the CAST function is a character string or not.Implementation note: If the return type is unknown, it is a good practice to make
isNumeric()
,isGeometry()
andisString()
to returntrue
. This information is used only by the parser when checking whether the CAST function can be used in some context. So, when the type of an ADQL operand is unknown, it is assumed it could be placed anywhere until its type can be precisely determined or until the query reaches the database.- Returns:
true
if the CAST function returns a string,false
otherwise.
-
isGeometry
boolean isGeometry()Indicate whether the output of the CAST function is a geometry or not.Implementation note: If the return type is unknown, it is a good practice to make
isNumeric()
,isGeometry()
andisString()
to returntrue
. This information is used only by the parser when checking whether the CAST function can be used in some context. So, when the type of an ADQL operand is unknown, it is assumed it could be placed anywhere until its type can be precisely determined or until the query reaches the database.- Returns:
true
if the CAST function returns a geometry,false
otherwise.
-
getReturnType
DBType getReturnType()Indicate the precise type of the value expected to be returned by the CAST function.This information is used only when the CAST function is used as output column (so, in the SELECT clause). It is a hint when formatting the query result to make the most appropriate conversion.
- Returns:
- The expected type returned by the CAST function, or NULL if unknown.
-
getNbParameters
int getNbParameters()Get the actual number of parameters.- Returns:
- Number of parameters.
-
getParameters
ADQLOperand[] getParameters()Get the ordered list of all parameters.- Returns:
- All type parameters, or an empty array if no parameter.
-
getParameter
Get the indParam-th parameter.- Parameters:
indParam
- Index (≥ 0) of the parameter to get.- Returns:
- The corresponding parameter.
- Throws:
IndexOutOfBoundsException
- If the index is incorrect (i.e. < 0 or ≥getNbParameters()
).
-
setParameter
Replace the indParam-th parameter.- Parameters:
indParam
- Index (≥ 0) of the parameter to replace.newParam
- The operand to set instead of the current indParam-th parameter.- Returns:
- The former indParam-th parameter.
- Throws:
IndexOutOfBoundsException
- If the index is incorrect (i.e. < 0 or ≥getNbParameters()
).
-
toADQL
String toADQL()Serialize this type into ADQL.- Returns:
- Its ADQL serialization.
-
getCopy
Create a deep copy of this target type.- Returns:
- Type copy.
- Throws:
Exception
- If the copy fails.
-