Class Comparison

  • All Implemented Interfaces:
    ADQLObject, ADQLConstraint

    public class Comparison
    extends java.lang.Object
    implements ADQLConstraint
    Represents a comparison (numeric or not) between two operands.
    Version:
    1.4 (06/2015)
    Author:
    Grégory Mantelet (CDS;ARI)
    See Also:
    ComparisonOperator
    • Constructor Detail

      • Comparison

        public Comparison​(ADQLOperand left,
                          ComparisonOperator comp,
                          ADQLOperand right)
                   throws java.lang.NullPointerException,
                          java.lang.UnsupportedOperationException
        Creates a comparison between two operands.
        Parameters:
        left - The left part.
        comp - The comparison symbol.
        right - The right part.
        Throws:
        java.lang.NullPointerException - If one of the given parameter is null.
        java.lang.UnsupportedOperationException - If the type of operands and of the operator are incompatibles.
        See Also:
        setLeftOperand(ADQLOperand), setRightOperand(ADQLOperand)
      • Comparison

        public Comparison​(Comparison toCopy)
                   throws java.lang.Exception
        Builds a comparison by copying the given one.
        Parameters:
        toCopy - The comparison to copy.
        Throws:
        java.lang.Exception - If there is an error during the copy.
    • Method Detail

      • getLeftOperand

        public final ADQLOperand getLeftOperand()
        Gets the left part of the comparison.
        Returns:
        The left operand.
      • setLeftOperand

        public void setLeftOperand​(ADQLOperand newLeftOperand)
                            throws java.lang.NullPointerException,
                                   java.lang.UnsupportedOperationException
        Changes the left operand of this comparison.
        Parameters:
        newLeftOperand - The new left operand.
        Throws:
        java.lang.NullPointerException - If the given operand is null.
        java.lang.UnsupportedOperationException - If the type of the given operand is incompatible with the right operand and/or with the comparison operator.
      • getOperator

        public ComparisonOperator getOperator()
        Gets the comparison symbol.
        Returns:
        The comparison operator.
      • setOperation

        public void setOperation​(ComparisonOperator newOperation)
                          throws java.lang.NullPointerException,
                                 java.lang.UnsupportedOperationException
        Changes the type of this operation.
        Parameters:
        newOperation - The new operation type.
        Throws:
        java.lang.NullPointerException - If the given type is null.
        java.lang.UnsupportedOperationException - If the given type is incompatible with the two operands.
      • getRightOperand

        public ADQLOperand getRightOperand()
        Gets the right part of the comparison.
        Returns:
        The right operand.
      • setRightOperand

        public void setRightOperand​(ADQLOperand newRightOperand)
                             throws java.lang.NullPointerException,
                                    java.lang.UnsupportedOperationException
        Changes the right operand of this comparison.
        Parameters:
        newRightOperand - The new right operand.
        Throws:
        java.lang.NullPointerException - If the given operand is null.
        java.lang.UnsupportedOperationException - If the type of the given operand is incompatible with the left operand and/or with the comparison operator.
      • getPosition

        public final TextPosition 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 interface ADQLObject
        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

        public final void setPosition​(TextPosition position)
        Set the position of this Comparison in the given ADQL query string.
        Parameters:
        position - New position of this Comparison.
        Since:
        1.4
      • getCopy

        public ADQLObject getCopy()
                           throws java.lang.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:
        java.lang.Exception - If there is any error during the copy.
      • getName

        public java.lang.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.
      • toADQL

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