Package adql.query.operand
Class NumericConstant
java.lang.Object
adql.query.operand.NumericConstant
- All Implemented Interfaces:
ADQLObject
,ADQLOperand
A numeric (integer, double, ...) constant.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final LanguageFeature
Description of this ADQL Feature.protected TextPosition
Position of this operand.protected String
-
Constructor Summary
ConstructorsConstructorDescriptionNumericConstant
(double val) The numeric value is saved as a string so that the exact user format can be saved.NumericConstant
(long val) The numeric value is saved as a string so that the exact user format can be saved.NumericConstant
(NumericConstant toCopy) Builds a NumericConstant by copying the given one.NumericConstant
(String value) The numeric value is saved as a string so that the exact user format can be saved.NumericConstant
(String value, boolean checkNumeric) The numeric value is saved as a string so that the exact user format can be saved. -
Method Summary
Modifier and TypeMethodDescriptionGets an iterator on the intern ADQL objects.getCopy()
Gets a (deep) copy of this ADQL object.final LanguageFeature
Get the description of this ADQL's Language Feature.getName()
Gets the name of this object in ADQL.double
final TextPosition
Gets the position of this object/token in the ADQL query.getValue()
final boolean
Always returnsfalse
.final boolean
Tell whether this numeric constant is written in an hexadecimal form.protected boolean
isHexadecimal
(String val) Tell whether the given string is an hexadecimal numeric.final boolean
Always returnstrue
.final boolean
isString()
Always returnsfalse
.final void
setPosition
(TextPosition position) Sets the position at which thisNumericConstant
has been found in the original ADQL query string.void
setValue
(double value) Sets the given value.void
setValue
(long value) Sets the given value.void
Sets the given value (it must be convertible in a Double).void
Sets the given value.toADQL()
Gets the ADQL expression of this object.
-
Field Details
-
FEATURE
Description of this ADQL Feature.- Since:
- 2.0
-
value
-
position
Position of this operand.- Since:
- 1.4
-
-
Constructor Details
-
NumericConstant
The numeric value is saved as a string so that the exact user format can be saved. The given string must be convertible in a Double value.- Parameters:
value
- The numeric value (in a String variable).- Throws:
NumberFormatException
- If it is impossible to convert the given value in a Double.- See Also:
-
NumericConstant
public NumericConstant(long val) The numeric value is saved as a string so that the exact user format can be saved.- Parameters:
val
- The numeric value.
-
NumericConstant
public NumericConstant(double val) The numeric value is saved as a string so that the exact user format can be saved.- Parameters:
val
- The numeric value.
-
NumericConstant
The numeric value is saved as a string so that the exact user format can be saved. It is possible to force the value (no check to known whether this value is numeric or not is done) by setting the boolean parameter tofalse
.- Parameters:
value
- The numeric value (in a String variable).checkNumeric
-true
to check whether the given value is numeric,false
otherwise.- Throws:
NumberFormatException
- If it is impossible to convert the given value in a Double.- See Also:
-
NumericConstant
Builds a NumericConstant by copying the given one.- Parameters:
toCopy
- The NumericConstant to copy.
-
-
Method Details
-
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.
-
getValue
-
isHexadecimal
public final boolean isHexadecimal()Tell whether this numeric constant is written in an hexadecimal form.- Returns:
true
if written in hexadecimal,false
otherwise.- Since:
- 2.0
-
isHexadecimal
Tell whether the given string is an hexadecimal numeric.- Parameters:
val
- The string to test.- Returns:
true
if the given string is an hexadecimal value,false
otherwise.- Since:
- 2.0
-
getNumericValue
public double getNumericValue() -
setValue
public void setValue(long value) Sets the given value.- Parameters:
value
- The numeric value.
-
setValue
public void setValue(double value) Sets the given value.- Parameters:
value
- The numeric value.
-
setValue
Sets the given value (it must be convertible in a Double).- Parameters:
value
- The numeric value.- Throws:
NumberFormatException
- If it is impossible to convert the given value in a Double.- See Also:
-
setValue
Sets the given value.It is possible to force the value (no check to known whether this value is numeric or not is done) by setting the boolean parameter to
false
.- Parameters:
value
- The numeric value.checkNumeric
-true
to check whether the given value is numeric,false
otherwise.- Throws:
NumberFormatException
- If the given value can not be converted in a Double.
-
isNumeric
public final boolean isNumeric()Always returnstrue
.- Specified by:
isNumeric
in interfaceADQLOperand
- Returns:
- true if this operand is numeric, false otherwise.
- See Also:
-
isString
public final boolean isString()Always returnsfalse
.- Specified by:
isString
in interfaceADQLOperand
- Returns:
- true if this operand is a string, false otherwise.
- See Also:
-
getPosition
Description copied from interface:ADQLObject
Gets the position of this object/token in the ADQL query.By default, no position should be set.
- Specified by:
getPosition
in interfaceADQLObject
- Returns:
- Position of this ADQL item in the ADQL query, or NULL if not written originally in the query (for example, if added afterwards).
-
setPosition
Sets the position at which thisNumericConstant
has been found in the original ADQL query string.- Parameters:
position
- Position of thisNumericConstant
.- Since:
- 1.4
-
isGeometry
public final boolean isGeometry()Always returnsfalse
.- Specified by:
isGeometry
in interfaceADQLOperand
- Returns:
- true if this operand is a geometry, false otherwise.
- See Also:
-
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.
-
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.
-
adqlIterator
Description copied from interface:ADQLObject
Gets an iterator on the intern ADQL objects.Note: The returned iterator is particularly used by a
ISearchHandler
extension to browse a whole ADQL tree.- Specified by:
adqlIterator
in interfaceADQLObject
- Returns:
- An ADQL objects iterator.
- See Also:
-
toADQL
Description copied from interface:ADQLObject
Gets the ADQL expression of this object.- Specified by:
toADQL
in interfaceADQLObject
- Returns:
- The corresponding ADQL expression.
-