Class CastFunction
- All Implemented Interfaces:
ADQLObject
,ADQLOperand
,UnknownType
- Since:
- 2.0
-
Nested Class Summary
Nested classes/interfaces inherited from class adql.query.operand.function.ADQLFunction
ADQLFunction.ParameterIterator
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected FunctionTranslator
How to translate this CAST function.protected final String
Constant name of this function.static final LanguageFeature
Description of this ADQL Feature.protected TargetType
The type into which the value must be cast.protected ADQLOperand
The value to cast. -
Constructor Summary
ConstructorsConstructorDescriptionCastFunction
(ADQLOperand value, TargetType type) CastFunction
(CastFunction toCopy) -
Method Summary
Modifier and TypeMethodDescriptiongetCopy()
Gets a (deep) copy of this ADQL object.char
Get the type expected by the syntactic parser according to the context.Get the description of this ADQL's Language Feature.final FunctionTranslator
Get the specialized translator to translate this CAST function.getName()
Gets the name of this object in ADQL.int
Gets the number of parameters this function has.getParameter
(int index) Gets the index-th parameter.Gets the list of all parameters of this function.Get the database type actually returned by this function.final TargetType
Get the type into which the given value is going to be casted.getValue()
boolean
Tell whether this operand is a geometrical region or not.boolean
Tell whether this operand is numeric or not.boolean
isString()
Tell whether this operand is a string or not.void
setExpectedType
(char c) Set the type expected for this operand.final void
setFunctionTranslator
(FunctionTranslator customTranslation) Set a specialized translator to translate this CAST function.setParameter
(int index, ADQLOperand replacer) Replaces the index-th parameter by the given one.protected void
setTargetType
(TargetType type) Set the type into which the given value must be casted.toADQL()
Gets the ADQL expression of this object.Methods inherited from class adql.query.operand.function.ADQLFunction
adqlIterator, getPosition, paramIterator, setPosition
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface adql.query.ADQLObject
adqlIterator, getPosition
-
Field Details
-
FEATURE
Description of this ADQL Feature. -
FCT_NAME
Constant name of this function.- See Also:
-
value
The value to cast. -
targetType
The type into which the value must be cast. -
customTranslation
How to translate this CAST function.This is by default NULL. It is useful when the target type is not a standard one.
-
-
Constructor Details
-
CastFunction
-
CastFunction
- Throws:
Exception
-
-
Method Details
-
isNumeric
public boolean isNumeric()Description copied from interface:ADQLOperand
Tell whether this operand is numeric or not.- Specified by:
isNumeric
in interfaceADQLOperand
- Returns:
- true if this operand is numeric, false otherwise.
-
isString
public boolean isString()Description copied from interface:ADQLOperand
Tell whether this operand is a string or not.- Specified by:
isString
in interfaceADQLOperand
- Returns:
- true if this operand is a string, false otherwise.
-
isGeometry
public boolean isGeometry()Description copied from interface:ADQLOperand
Tell whether this operand is a geometrical region or not.- Specified by:
isGeometry
in interfaceADQLOperand
- Returns:
- true if this operand is a geometry, false otherwise.
-
getExpectedType
public char getExpectedType()Description copied from interface:UnknownType
Get the type expected by the syntactic parser according to the context.- Specified by:
getExpectedType
in interfaceUnknownType
- Returns:
- Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.
-
setExpectedType
public void setExpectedType(char c) Description copied from interface:UnknownType
Set the type expected for this operand.- Specified by:
setExpectedType
in interfaceUnknownType
- Parameters:
c
- Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.
-
getName
Description copied from interface:ADQLObject
Gets the name of this object in ADQL.- Specified by:
getName
in interfaceADQLObject
- Returns:
- The name of this ADQL object.
-
getValue
-
getReturnType
Get the database type actually returned by this function.Implementation note: This function is just a convenient access to
getTargetType()
.getReturnType()
.- Returns:
- Type returned by this function.
- See Also:
-
getTargetType
Get the type into which the given value is going to be casted.- Returns:
- The target type.
-
setTargetType
Set the type into which the given value must be casted.Note: If the given target type is custom (i.e. not a
StandardTargetType
), it may be useful to provide a specific translation. In such case,setFunctionTranslator(FunctionTranslator)
should be used.- Parameters:
type
- The new target type.- Throws:
NullPointerException
- If the given type is NULL.
-
getFunctionTranslator
Get the specialized translator to translate this CAST function.Note: It is generally useful to give a such translator when the target type is not a standard one.
- Returns:
- The function translator to use,
or NULL for the default
CastFunction
translation.
-
setFunctionTranslator
Set a specialized translator to translate this CAST function.Note: It is generally useful to give a such translator when the target type is not a standard one.
- Parameters:
customTranslation
- The new translator to use, or NULL for the default translation.
-
getFeatureDescription
Description copied from interface:ADQLObject
Get the description of this ADQL's Language Feature.Note: Getting this description is generally only useful when discovery optional features so that determining if they are allowed to be used in ADQL queries.
- Specified by:
getFeatureDescription
in interfaceADQLObject
- Returns:
- Description of this ADQL object as an ADQL's feature.
-
getCopy
Description copied from interface:ADQLObject
Gets a (deep) copy of this ADQL object.- Specified by:
getCopy
in interfaceADQLObject
- Returns:
- The copy of this ADQL object.
- Throws:
Exception
- If there is any error during the copy.
-
getNbParameters
public int getNbParameters()Description copied from class:ADQLFunction
Gets the number of parameters this function has.- Specified by:
getNbParameters
in classADQLFunction
- Returns:
- Number of parameters.
-
getParameters
Description copied from class:ADQLFunction
Gets the list of all parameters of this function.- Specified by:
getParameters
in classADQLFunction
- Returns:
- Its parameters list.
-
getParameter
Description copied from class:ADQLFunction
Gets the index-th parameter.- Specified by:
getParameter
in classADQLFunction
- Parameters:
index
- Parameter number.- Returns:
- The corresponding parameter.
- Throws:
ArrayIndexOutOfBoundsException
- If the index is incorrect (index < 0 || index >= getNbParameters()).
-
setParameter
public ADQLOperand setParameter(int index, ADQLOperand replacer) throws ArrayIndexOutOfBoundsException, NullPointerException, Exception Description copied from class:ADQLFunction
Replaces the index-th parameter by the given one.- Specified by:
setParameter
in classADQLFunction
- Parameters:
index
- Index of the parameter to replace.replacer
- The replacer.- Returns:
- The replaced parameter.
- Throws:
ArrayIndexOutOfBoundsException
- If the index is incorrect (index < 0 || index >= getNbParameters()).NullPointerException
- If a required parameter must be replaced by a NULL object.Exception
- If another error occurs.
-
toADQL
Description copied from interface:ADQLObject
Gets the ADQL expression of this object.- Specified by:
toADQL
in interfaceADQLObject
- Overrides:
toADQL
in classADQLFunction
- Returns:
- The corresponding ADQL expression.
-