public class ClauseConstraints extends ClauseADQL<ADQLConstraint>
Represents a clause which deals with ADQLConstraint
s (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)
).
ConstraintsGroup
ADQLList.ADQLListIterator
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AND
The logical separator AND.
|
protected java.lang.String |
defaultSeparator
The logical separator used when none is specified during a constraint insertion (by default =
OR ). |
static java.lang.String |
OR
The logical separator OR (By default, the default separator (see
getDefaultSeparator() ) is equals to OR). |
Constructor and Description |
---|
ClauseConstraints(ClauseConstraints toCopy)
Builds a ClauseConstraints by copying the given one.
|
ClauseConstraints(java.lang.String name)
Builds a constraints list with only its name (which will prefix the whole list).
|
ClauseConstraints(java.lang.String name,
java.lang.String logicalSep)
Builds a constraints list with its name and its default separator.
|
Modifier and Type | Method and Description |
---|---|
boolean |
add(ADQLConstraint constraint)
Adds the given item (if not null) at the end of this clause.
|
void |
add(int index,
ADQLConstraint constraint)
Adds the given item (if not null) at the given position into this clause.
|
void |
add(int index,
java.lang.String logicalSep,
ADQLConstraint constraint)
Adds the given constraint with the given separator at the given position in the constraints list.
|
boolean |
add(java.lang.String logicalSep,
ADQLConstraint constraint)
Adds the given constraint with the given separator.
|
static java.lang.String |
checkSeparator(java.lang.String sepToCheck)
Checks/Converts the given separator in one of the two logical separators.
|
void |
clear()
Clears this clause.
|
ADQLObject |
getCopy()
Gets a (deep) copy of this ADQL object.
|
java.lang.String |
getDefaultSeparator()
|
java.lang.String[] |
getPossibleSeparators()
|
java.lang.String |
getSeparator(int index)
Returns always ",", except if the index is incorrect (index <= 0 or index >= size()).
|
ADQLConstraint |
remove(int index)
Removes the specified ADQL item.
|
ADQLConstraint |
set(int index,
ADQLConstraint constraint)
Replaces the specified ADQL item by the given one.
|
ADQLConstraint |
set(int index,
java.lang.String logicalSep,
ADQLConstraint constraint)
Replaces the specified constraint by the given one with the given constraint separator.
|
adqlIterator, get, getName, getPosition, isEmpty, iterator, setPosition, size, toADQL
public static final java.lang.String OR
getDefaultSeparator()
) is equals to OR).public static final java.lang.String AND
protected final java.lang.String defaultSeparator
OR
).public ClauseConstraints(java.lang.String name)
Builds a constraints list with only its name (which will prefix the whole list).
Note: The default separator is automatically set to OR.
name
- The name/prefix of the list.public ClauseConstraints(java.lang.String name, java.lang.String logicalSep)
Builds a constraints list with its name and its default separator.
Note: if the given separator is no AND
or OR
, the default separator is automatically set to OR
.
name
- The name/prefix of the list.logicalSep
- The constraints separator (a logical separator: AND
or OR
).checkSeparator(String)
public ClauseConstraints(ClauseConstraints toCopy) throws java.lang.Exception
Builds a ClauseConstraints by copying the given one.
toCopy
- The ClauseConstraints to copy.java.lang.Exception
- If there is an error during the copy.checkSeparator(String)
public final java.lang.String getDefaultSeparator()
public static final java.lang.String checkSeparator(java.lang.String sepToCheck)
OR
.sepToCheck
- The separator to check/convert.public boolean add(ADQLConstraint constraint) throws java.lang.NullPointerException
ADQLList
add
in class ADQLList<ADQLConstraint>
constraint
- The ADQL item to add to this clause.java.lang.NullPointerException
- If the given item is null.ADQLList.add(adql.query.ADQLObject)
,
add(String, ADQLConstraint)
public void add(int index, ADQLConstraint constraint) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
ADQLList
add
in class ADQLList<ADQLConstraint>
index
- Position at which the given item must be added.constraint
- ADQL item to add to this clause.java.lang.NullPointerException
- If the given item is null.java.lang.ArrayIndexOutOfBoundsException
- If the index is out of range (index < 0 || index > size()).ADQLList.add(int, adql.query.ADQLObject)
,
add(int, String, ADQLConstraint)
public boolean add(java.lang.String logicalSep, ADQLConstraint constraint) throws java.lang.NullPointerException
logicalSep
- The separator to add just before the given constraint.constraint
- The constraint to add.java.lang.NullPointerException
- If the given constraint is null.ADQLList.add(ADQLObject)
,
checkSeparator(String)
public void add(int index, java.lang.String logicalSep, ADQLConstraint constraint) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
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.java.lang.NullPointerException
- If the given constraint is null.java.lang.ArrayIndexOutOfBoundsException
- If the given index is incorrect (index < 0 || index >= size()).ADQLList.add(int, ADQLObject)
,
checkSeparator(String)
public ADQLConstraint set(int index, ADQLConstraint constraint) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
ADQLList
set
in class ADQLList<ADQLConstraint>
index
- Position of the item to replace.constraint
- Replacer of the specified ADQL item.java.lang.NullPointerException
- If the given item is null.java.lang.ArrayIndexOutOfBoundsException
- If the index is out of range (index < 0 || index > size()).ADQLList.set(int, adql.query.ADQLObject)
,
set(int, String, ADQLConstraint)
public ADQLConstraint set(int index, java.lang.String logicalSep, ADQLConstraint constraint) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
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.java.lang.NullPointerException
- If the given constraint is null.java.lang.ArrayIndexOutOfBoundsException
- If the given index is incorrect (index < 0 || index >= size()).ADQLList.set(int, ADQLObject)
public void clear()
ADQLList
clear
in class ADQLList<ADQLConstraint>
public ADQLConstraint remove(int index) throws java.lang.ArrayIndexOutOfBoundsException
ADQLList
remove
in class ADQLList<ADQLConstraint>
index
- Index of the ADQL item to remove.java.lang.ArrayIndexOutOfBoundsException
- If the index is out of range (index < 0 || index > size()).public ADQLObject getCopy() throws java.lang.Exception
ADQLObject
getCopy
in interface ADQLObject
getCopy
in class ClauseADQL<ADQLConstraint>
java.lang.Exception
- If there is any error during the copy.public java.lang.String[] getPossibleSeparators()
getPossibleSeparators
in class ClauseADQL<ADQLConstraint>
ADQLList.getPossibleSeparators()
public java.lang.String getSeparator(int index) throws java.lang.ArrayIndexOutOfBoundsException
ClauseADQL
getSeparator
in class ClauseADQL<ADQLConstraint>
index
- Index of the right list item.java.lang.ArrayIndexOutOfBoundsException
- If the index is less or equal than 0, or is greater or equal than size()
.ADQLList.getSeparator(int)