Package adql.query
Class ClauseConstraints
- All Implemented Interfaces:
ADQLObject,Iterable<ADQLConstraint>
- Direct Known Subclasses:
ConstraintsGroup
Represents a clause which deals with
ADQLConstraints
(i.e. WHERE, HAVING).
The logical operators AND (see AND) and OR
(see OR) are managed in a separated list by this
class. To add a constraint you can use the default add functions or use the
one defined by this class:
add(String, ADQLConstraint: which lets you specify the logical operator between the added constraint (index=size()) and the previous one (index=size()-1) in the list.add(int, String, ADQLConstraint: which lets you specify the logical operator between the added constraint (index) and the previous one (index-1) in the list.
If no logical separator is specified the default one is used
(see getDefaultSeparator()).
The only way to set this default separator is during the
ClauseConstraints creation (see
ClauseConstraints(String, String)).
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class adql.query.ADQLList
ADQLList.ADQLListIterator -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe logical separator AND.protected final StringThe logical separator used when none is specified during a constraint insertion (by default =OR).static final StringThe logical separator OR (By default, the default separator (seegetDefaultSeparator()) is equals to OR). -
Constructor Summary
ConstructorsConstructorDescriptionClauseConstraints(ClauseConstraints toCopy) Builds a ClauseConstraints by copying the given one.ClauseConstraints(String name) Builds a constraints list with only its name (which will prefix the whole list).ClauseConstraints(String name, String logicalSep) Builds a constraints list with its name and its default separator. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, ADQLConstraint constraint) Adds the given item (if not NULL) at the given position into this clause.voidadd(int index, String logicalSep, ADQLConstraint constraint) Adds the given constraint with the given separator at the given position in the constraints list.booleanadd(ADQLConstraint constraint) Adds the given item (if not NULL) at the end of this clause.booleanadd(String logicalSep, ADQLConstraint constraint) Adds the given constraint with the given separator.static final StringcheckSeparator(String sepToCheck) Checks/Converts the given separator in one of the two logical separators.voidclear()Clears this clause.getCopy()Gets a (deep) copy of this ADQL object.final StringString[]getSeparator(int index) Returns always ",", except if the index is incorrect (index invalid input: '<'= 0 or index >= size()).remove(int index) Removes the specified ADQL item.set(int index, ADQLConstraint constraint) Replaces the specified ADQL item by the given one.set(int index, String logicalSep, ADQLConstraint constraint) Replaces the specified constraint by the given one with the given constraint separator.Methods inherited from class adql.query.ADQLList
adqlIterator, get, getFeatureDescription, getName, getPosition, isEmpty, iterator, setPosition, size, toADQLMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
OR
The logical separator OR (By default, the default separator (seegetDefaultSeparator()) is equals to OR).- See Also:
-
AND
The logical separator AND.- See Also:
-
defaultSeparator
The logical separator used when none is specified during a constraint insertion (by default =OR).
-
-
Constructor Details
-
ClauseConstraints
Builds a constraints list with only its name (which will prefix the whole list).Note: The default separator is automatically set to OR.
- Parameters:
name- The name/prefix of the list.
-
ClauseConstraints
-
ClauseConstraints
Builds a ClauseConstraints by copying the given one.- Parameters:
toCopy- The ClauseConstraints to copy.- Throws:
Exception- If there is an error during the copy.- See Also:
-
-
Method Details
-
getDefaultSeparator
- Returns:
- The default separator.
-
checkSeparator
Checks/Converts the given separator in one of the two logical separators. If the given separator is neither AND nor OR, then the returned separator isOR.- Parameters:
sepToCheck- The separator to check/convert.- Returns:
- The understood separator (OR if neither AND nor OR).
-
add
Description copied from class:ADQLListAdds the given item (if not NULL) at the end of this clause.- Overrides:
addin classADQLList<ADQLConstraint>- Parameters:
constraint- The ADQL item to add to this clause.- Returns:
trueif the given item has been successfully added,falseotherwise.- Throws:
NullPointerException- If the given item is NULL.- See Also:
-
add
public void add(int index, ADQLConstraint constraint) throws NullPointerException, ArrayIndexOutOfBoundsException Description copied from class:ADQLListAdds the given item (if not NULL) at the given position into this clause.- Overrides:
addin classADQLList<ADQLConstraint>- Parameters:
index- Position at which the given item must be added.constraint- ADQL item to add to this clause.- Throws:
NullPointerException- If the given item is NULL.ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).- See Also:
-
add
Adds the given constraint with the given separator. The separator is added just before the added constraint, that is to say between the last constraint of the list and the added one.- Parameters:
logicalSep- The separator to add just before the given constraint.constraint- The constraint to add.- Returns:
trueif the constraint has been successfully added,falseotherwise.- Throws:
NullPointerException- If the given constraint is NULL.- See Also:
-
add
public void add(int index, String logicalSep, ADQLConstraint constraint) throws NullPointerException, ArrayIndexOutOfBoundsException Adds the given constraint with the given separator at the given position in the constraints list. The separator is added just before the added constraint, that is to say between the (index-1)-th constraint of the list and the added one (at the index position).- Parameters:
index- Position at which the given constraint must be added.logicalSep- The constraints separator to add just before the given constraint.constraint- The constraint to add.- Throws:
NullPointerException- If the given constraint is NULL.ArrayIndexOutOfBoundsException- If the given index is incorrect (index invalid input: '<' 0 || index >= size()).- See Also:
-
set
public ADQLConstraint set(int index, ADQLConstraint constraint) throws NullPointerException, ArrayIndexOutOfBoundsException Description copied from class:ADQLListReplaces the specified ADQL item by the given one.- Overrides:
setin classADQLList<ADQLConstraint>- Parameters:
index- Position of the item to replace.constraint- Replacer of the specified ADQL item.- Returns:
- The replaced ADQL item.
- Throws:
NullPointerException- If the given item is NULL.ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).- See Also:
-
set
public ADQLConstraint set(int index, String logicalSep, ADQLConstraint constraint) throws NullPointerException, ArrayIndexOutOfBoundsException Replaces the specified constraint by the given one with the given constraint separator. The separator is added just before the added constraint, that is to say between the (index-1)-th constraint of the list and the added one (at the index position).- Parameters:
index- Position of the constraint to replace.logicalSep- The separator to insert just before the given constraint (if NULL, the previous separator is kept).constraint- The replacer.- Returns:
- The replaced constraint.
- Throws:
NullPointerException- If the given constraint is NULL.ArrayIndexOutOfBoundsException- If the given index is incorrect (index invalid input: '<' 0 || index >= size()).- See Also:
-
clear
public void clear()Description copied from class:ADQLListClears this clause.- Overrides:
clearin classADQLList<ADQLConstraint>
-
remove
Description copied from class:ADQLListRemoves the specified ADQL item.- Overrides:
removein classADQLList<ADQLConstraint>- Parameters:
index- Index of the ADQL item to remove.- Returns:
- The removed ADQL item.
- Throws:
ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).
-
getCopy
Description copied from interface:ADQLObjectGets a (deep) copy of this ADQL object.- Specified by:
getCopyin interfaceADQLObject- Overrides:
getCopyin classClauseADQL<ADQLConstraint>- Returns:
- The copy of this ADQL object.
- Throws:
Exception- If there is any error during the copy.
-
getPossibleSeparators
- Overrides:
getPossibleSeparatorsin classClauseADQL<ADQLConstraint>- Returns:
- Possible separators.
- See Also:
-
getSeparator
Description copied from class:ClauseADQLReturns always ",", except if the index is incorrect (index invalid input: '<'= 0 or index >= size()).- Overrides:
getSeparatorin classClauseADQL<ADQLConstraint>- Parameters:
index- Index of the right list item.- Returns:
- The corresponding separator.
- Throws:
ArrayIndexOutOfBoundsException- If the index is less or equal than 0, or is greater or equal thansize().- See Also:
-