@@ -166,7 +166,7 @@ public class ADQLQuery implements ADQLObject {
groupBy.clear();
having.clear();
orderBy.clear();
offset=-1;
offset=null;
position=null;
}
@@ -342,40 +342,14 @@ public class ADQLQuery implements ADQLObject {
* Gets the OFFSET value of this query.
*
* @return Its OFFSET value,
* or a negative value if no OFFSET is set.
* or NULL if not OFFSET is set.
*
* @since 2.0
*/
publicfinalintgetOffset(){
publicfinalClauseOffsetgetOffset(){
returnoffset;
}
/**
* Tell whether an OFFSET is set in this query.
*
* @return <code>true</code> if an OFFSET is set,
* <code>false</code> otherwise.
*
* @since 2.0
*/
publicfinalbooleanhasOffset(){
return(offset>-1);
}
/**
* Remove the OFFSET value of this query.
*
* <p><i><b>Note:</b>
* The position of the query is erased.
* </i></p>.
*
* @since 2.0
*/
publicvoidsetNoOffset(){
offset=-1;
position=null;
}
/**
* Replaces its OFFSET value by the given one.
*
@@ -383,13 +357,12 @@ public class ADQLQuery implements ADQLObject {
* The position of the query is erased.
* </i></p>
*
* @param newOffset The new OFFSET value.
* <i><b>Note:</b> a negative value removes the OFFSET from
* this query.</i>
* @param newOffset The new OFFSET value,
* or NULL to remove the current OFFSET.
*
* @since 2.0
*/
publicvoidsetOffset(finalintnewOffset){
publicvoidsetOffset(finalClauseOffsetnewOffset){
offset=newOffset;
position=null;
}
@@ -549,6 +522,9 @@ public class ADQLQuery implements ADQLObject {
case5:
currentClause=orderBy;
break;
case6:
currentClause=null;
returnoffset;
default:
thrownewNoSuchElementException();
}
@@ -557,7 +533,7 @@ public class ADQLQuery implements ADQLObject {
@Override
publicbooleanhasNext(){
returnindex+1<6;
returnindex+1<7;
}
@Override
@@ -606,6 +582,12 @@ public class ADQLQuery implements ADQLObject {
else
thrownewUnsupportedOperationException("Impossible to replace a ClauseADQL ("+orderBy.toADQL()+") by a "+replacer.getClass().getName()+" ("+replacer.toADQL()+")!");
break;
case6:
if(replacerinstanceofClauseOffset)
offset=(ClauseOffset)replacer;
else
thrownewUnsupportedOperationException("Impossible to replace a ClauseOffset ("+offset.toADQL()+") by a "+replacer.getClass().getName()+" ("+replacer.toADQL()+")!");
break;
}
position=null;
}
@@ -618,7 +600,10 @@ public class ADQLQuery implements ADQLObject {
if(index==0||index==1)
thrownewUnsupportedOperationException("Impossible to remove a "+((index==0)?"SELECT":"FROM")+" clause from a query!");
else{
elseif(index==6){
offset=null;
position=null;
}else{
currentClause.clear();
position=null;
}
@@ -643,8 +628,8 @@ public class ADQLQuery implements ADQLObject {
* This clause is special hence the fact it does not extend
* {@link adql.query.ClauseADQL}. It contains only one value: the number of
* rows removed from the query's result head.
* </p>
*
* <p><i><b>Important note:</b>
* The OFFSET value stored in this object MUST always be positive.
* </i></p>
*
* @author Grégory Mantelet (CDS)
* @version 2.0 (08/2019)
* @since 2.0
*/
publicclassClauseOffsetimplementsADQLObject{
/** Description of this ADQL Feature. */
publicstaticfinalLanguageFeatureFEATURE=newLanguageFeature(LanguageFeature.TYPE_ADQL_OFFSET,"OFFSET",true,"Remove the specified number of rows from the head of the query result.");
/** Name of this ADQL object. */
privatestaticfinalStringNAME="OFFSET";
/** Value of the query's OFFSET.
* <p><i><b>Important note:</b>
* This value can never be negative.
* </i></p> */
protectedintvalue;
/** Position of this {@link ClauseOffset} in the original ADQL query
* string. */
privateTextPositionposition=null;
/**
* Create a clause OFFSET with the given offset value.
*
* @param offsetValue Value of the query's result OFFSET.
*
* @throws IndexOutOfBoundsException If the given value is negative.