Class In

  • All Implemented Interfaces:
    ADQLObject, ADQLConstraint

    public class In
    extends java.lang.Object
    implements ADQLConstraint

    It represents the IN predicate of SQL and ADQL.

    This predicate returns true if the value of the given operand is either in the given values list or in the results of the given sub-query, else it returns false.

    Version:
    1.4 (06/2015)
    Author:
    Grégory Mantelet (CDS;ARI)
    • Constructor Detail

      • In

        public In​(ADQLOperand op,
                  ADQLQuery query)
           throws java.lang.NullPointerException
        Builds an IN constraint with a sub-query.
        Parameters:
        op - The operand whose the value must be in the results of the given sub-query.
        query - A sub-query.
        Throws:
        java.lang.NullPointerException - If the given operand and/or the given sub-query is null.
      • In

        public In​(ADQLOperand op,
                  ADQLQuery query,
                  boolean notIn)
           throws java.lang.NullPointerException
        Builds an IN constraint with a sub-query.
        Parameters:
        op - The operand whose the value must be in the results of the given sub-query.
        query - A sub-query.
        notIn - true for NOT IN, false for IN.
        Throws:
        java.lang.NullPointerException - If the given operand and/or the given sub-query is null.
      • In

        public In​(ADQLOperand op,
                  ADQLOperand[] valuesList)
           throws java.lang.NullPointerException
        Builds an IN constraint with a values list.
        Parameters:
        op - The operand whose the value must be in the given values list.
        valuesList - The values list.
        Throws:
        java.lang.NullPointerException - If the given operand is null and/or the given list is null or empty.
      • In

        public In​(ADQLOperand op,
                  ADQLOperand[] valuesList,
                  boolean notIn)
           throws java.lang.NullPointerException
        Builds an IN constraint with a values list.
        Parameters:
        op - The operand whose the value must be in the given values list.
        valuesList - The values list.
        notIn - true for NOT IN, false for IN.
        Throws:
        java.lang.NullPointerException - If the given operand is null and/or the given list is null or empty.
      • In

        public In​(ADQLOperand op,
                  ADQLList<ADQLOperand> valuesList)
           throws java.lang.NullPointerException
        Builds an IN constraint with a values list.
        Parameters:
        op - The operand whose the value must be in the given values list.
        valuesList - The values list.
        Throws:
        java.lang.NullPointerException - If the given operand is null and/or the given list is null or empty.
      • In

        public In​(ADQLOperand op,
                  ADQLList<ADQLOperand> valuesList,
                  boolean notIn)
           throws java.lang.NullPointerException
        Builds an IN constraint with a values list.
        Parameters:
        op - The operand whose the value must be in the given values list.
        valuesList - The values list.
        notIn - true for NOT IN, false for IN.
        Throws:
        java.lang.NullPointerException - If the given operand is null and/or the given list is null or empty.
      • In

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

      • getOperand

        public final ADQLOperand getOperand()
        Gets the left operand of this IN constraint.
        Returns:
        Its left operand.
      • setOperand

        public void setOperand​(ADQLOperand newLeftOp)
                        throws java.lang.NullPointerException
        Replaces the left operand of this IN constraint.
        Parameters:
        newLeftOp - Its new left operand.
        Throws:
        java.lang.NullPointerException - If the given operand is null.
      • getSubQuery

        public final ADQLQuery getSubQuery()
        Gets the sub-query (right operand) of this IN constraint.
        Returns:
        Its sub-query.
      • hasSubQuery

        public final boolean hasSubQuery()
        Tells whether the right operand of this IN constraint is a sub-query or a values list.
        Returns:
        true if the right operand is a sub-query, false for a values list (even empty).
      • setSubQuery

        public void setSubQuery​(ADQLQuery newSubQuery)
                         throws java.lang.NullPointerException
        Replaces the sub-query (right operand) of this IN constraint.
        Parameters:
        newSubQuery - Its new sub-query.
        Throws:
        java.lang.NullPointerException - If the given sub-query is null.
      • getValuesList

        public final ADQLList<ADQLOperand> getValuesList()
        Gets the values list (right operand) of this IN constraint.
        Returns:
        Its values list.
      • setValuesList

        public void setValuesList​(ADQLOperand[] valuesList)
                           throws java.lang.NullPointerException
        Replaces the values list (right operand) of this IN constraint.
        Parameters:
        valuesList - Its new values list.
        Throws:
        java.lang.NullPointerException - If the given list is null.
      • setValuesList

        public void setValuesList​(ADQLList<ADQLOperand> valuesList)
                           throws java.lang.NullPointerException
        Replaces the values list (right operand) of this IN constraint.
        Parameters:
        valuesList - Its new values list.
        Throws:
        java.lang.NullPointerException - If the given list is null.
      • isNotIn

        public final boolean isNotIn()
        Tells whether this predicate is IN or NOT IN.
        Returns:
        true for NOT IN, false for IN.
      • setNotIn

        public void setNotIn​(boolean notIn)
        Lets telling whether this predicate must be IN or NOT IN.
        Parameters:
        notIn - true for NOT IN, false for IN.
      • 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 In in the given ADQL query string.
        Parameters:
        position - New position of this In.
        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.