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 ADQLIterator
adqlIterator()
Gets an iterator on the intern ADQL objects.ADQLObject
getCopy()
Gets a (deep) copy of this ADQL object.ADQLOperand
getLeftOperand()
Gets the left part of the comparison.java.lang.String
getName()
Gets the name of this object in ADQL.ComparisonOperator
getOperator()
Gets the comparison symbol.TextPosition
getPosition()
Gets the position of this object/token in the ADQL query.ADQLOperand
getRightOperand()
Gets the right part of the comparison.void
setLeftOperand(ADQLOperand newLeftOperand)
Changes the left operand of this comparison.void
setOperation(ComparisonOperator newOperation)
Changes the type of this operation.void
setPosition(TextPosition position)
Set the position of thisComparison
in the given ADQL query string.void
setRightOperand(ADQLOperand newRightOperand)
Changes the right operand of this comparison.java.lang.String
toADQL()
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: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
public final void setPosition(TextPosition position)
Set the position of thisComparison
in 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:ADQLObject
Gets a (deep) copy of this ADQL object.- Specified by:
getCopy
in 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:ADQLObject
Gets the name of this object in ADQL.- Specified by:
getName
in interfaceADQLObject
- Returns:
- The name of this ADQL object.
-
adqlIterator
public ADQLIterator 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:
ADQLIterator
,ISearchHandler
-
toADQL
public java.lang.String toADQL()
Description copied from interface:ADQLObject
Gets the ADQL expression of this object.- Specified by:
toADQL
in interfaceADQLObject
- Returns:
- The corresponding ADQL expression.
-
-