Class CastFunction

java.lang.Object
adql.query.operand.function.ADQLFunction
adql.query.operand.function.cast.CastFunction
All Implemented Interfaces:
ADQLObject, ADQLOperand, UnknownType

public class CastFunction extends ADQLFunction implements UnknownType
Object representation of the ADQL CAST function.
Since:
2.0
  • Field Details

    • FEATURE

      public static final LanguageFeature FEATURE
      Description of this ADQL Feature.
    • FCT_NAME

      protected final String FCT_NAME
      Constant name of this function.
      See Also:
    • value

      protected ADQLOperand value
      The value to cast.
    • targetType

      protected TargetType targetType
      The type into which the value must be cast.
    • customTranslation

      protected FunctionTranslator 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

  • Method Details

    • isNumeric

      public boolean isNumeric()
      Description copied from interface: ADQLOperand
      Tell whether this operand is numeric or not.
      Specified by:
      isNumeric in interface ADQLOperand
      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 interface ADQLOperand
      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 interface ADQLOperand
      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 interface UnknownType
      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 interface UnknownType
      Parameters:
      c - Expected type: 'n' or 'N' for numeric, 's' or 'S' for string, 'g' or 'G' for geometry.
    • getName

      public String getName()
      Description copied from interface: ADQLObject
      Gets the name of this object in ADQL.
      Specified by:
      getName in interface ADQLObject
      Returns:
      The name of this ADQL object.
    • getValue

      public ADQLOperand getValue()
    • getReturnType

      public DBType 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

      public final TargetType getTargetType()
      Get the type into which the given value is going to be casted.
      Returns:
      The target type.
    • setTargetType

      protected void setTargetType(TargetType type) throws NullPointerException
      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

      public final FunctionTranslator 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

      public final void setFunctionTranslator(FunctionTranslator customTranslation)
      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

      public LanguageFeature 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 interface ADQLObject
      Returns:
      Description of this ADQL object as an ADQL's feature.
    • getCopy

      public ADQLObject getCopy() throws Exception
      Description copied from interface: ADQLObject
      Gets a (deep) copy of this ADQL object.
      Specified by:
      getCopy in interface ADQLObject
      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 class ADQLFunction
      Returns:
      Number of parameters.
    • getParameters

      public ADQLOperand[] getParameters()
      Description copied from class: ADQLFunction
      Gets the list of all parameters of this function.
      Specified by:
      getParameters in class ADQLFunction
      Returns:
      Its parameters list.
    • getParameter

      public ADQLOperand getParameter(int index) throws ArrayIndexOutOfBoundsException
      Description copied from class: ADQLFunction
      Gets the index-th parameter.
      Specified by:
      getParameter in class ADQLFunction
      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 class ADQLFunction
      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

      public String toADQL()
      Description copied from interface: ADQLObject
      Gets the ADQL expression of this object.
      Specified by:
      toADQL in interface ADQLObject
      Overrides:
      toADQL in class ADQLFunction
      Returns:
      The corresponding ADQL expression.