Package adql.query.constraint
Class Comparison
- java.lang.Object
-
- adql.query.constraint.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 Summary
Constructors Constructor Description Comparison(Comparison toCopy)Builds a comparison by copying the given one.Comparison(ADQLOperand left, ComparisonOperator comp, ADQLOperand right)Creates a comparison between two operands.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ADQLIteratoradqlIterator()Gets an iterator on the intern ADQL objects.ADQLObjectgetCopy()Gets a (deep) copy of this ADQL object.ADQLOperandgetLeftOperand()Gets the left part of the comparison.java.lang.StringgetName()Gets the name of this object in ADQL.ComparisonOperatorgetOperator()Gets the comparison symbol.TextPositiongetPosition()Gets the position of this object/token in the ADQL query.ADQLOperandgetRightOperand()Gets the right part of the comparison.voidsetLeftOperand(ADQLOperand newLeftOperand)Changes the left operand of this comparison.voidsetOperation(ComparisonOperator newOperation)Changes the type of this operation.voidsetPosition(TextPosition position)Set the position of thisComparisonin the given ADQL query string.voidsetRightOperand(ADQLOperand newRightOperand)Changes the right operand of this comparison.java.lang.StringtoADQL()Gets the ADQL expression of this object.
-
-
-
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:ADQLObjectGets the position of this object/token in the ADQL query.
By default, no position should be set.
- Specified by:
getPositionin 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
public final void setPosition(TextPosition position)
Set the position of thisComparisonin the given ADQL query string.- Parameters:
position- New position of thisComparison.- Since:
- 1.4
-
getCopy
public ADQLObject getCopy() throws java.lang.Exception
Description copied from interface:ADQLObjectGets a (deep) copy of this ADQL object.- Specified by:
getCopyin interfaceADQLObject- 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:ADQLObjectGets the name of this object in ADQL.- Specified by:
getNamein interfaceADQLObject- Returns:
- The name of this ADQL object.
-
adqlIterator
public ADQLIterator adqlIterator()
Description copied from interface:ADQLObjectGets an iterator on the intern ADQL objects.
Note:The returned iterator is particularly used by a
ISearchHandlerextension to browse a whole ADQL tree.- Specified by:
adqlIteratorin interfaceADQLObject- Returns:
- An ADQL objects iterator.
- See Also:
ADQLIterator,ISearchHandler
-
toADQL
public java.lang.String toADQL()
Description copied from interface:ADQLObjectGets the ADQL expression of this object.- Specified by:
toADQLin interfaceADQLObject- Returns:
- The corresponding ADQL expression.
-
-