Select Git revision
WrappedOperand.java
-
gmantele authored
[ADQL,TAP] Add STC-S and UDFs support in the ADQL parser. Now, it is possible to provide a list of allowed UDFs, regions and coordinate systems. The ServiceConnection of TAP is now able to provide these lists and to propagate them to the ADQLExecutor. UDFs and allowed regions are now listed automatically in the /capabilities resource of TAP. The type 'geometry' is now fully supported in ADQL. That's why the new function 'isGeometry()' has been added to all ADQLOperand extensions. Now the DBChecker is also able to check roughly types of columns and UDFs (unknown when parsing syntactically a query). The syntax of STC-S regions (expressed in the REGION function) are now checked by DBChecker. However, for the moment, geometries are not serialized in STC-S in the output....but it should be possible in some way in the next commit(s).
gmantele authored[ADQL,TAP] Add STC-S and UDFs support in the ADQL parser. Now, it is possible to provide a list of allowed UDFs, regions and coordinate systems. The ServiceConnection of TAP is now able to provide these lists and to propagate them to the ADQLExecutor. UDFs and allowed regions are now listed automatically in the /capabilities resource of TAP. The type 'geometry' is now fully supported in ADQL. That's why the new function 'isGeometry()' has been added to all ADQLOperand extensions. Now the DBChecker is also able to check roughly types of columns and UDFs (unknown when parsing syntactically a query). The syntax of STC-S regions (expressed in the REGION function) are now checked by DBChecker. However, for the moment, geometries are not serialized in STC-S in the output....but it should be possible in some way in the next commit(s).
WrappedOperand.java 3.46 KiB
package adql.query.operand;
/*
* This file is part of ADQLLibrary.
*
* ADQLLibrary is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* ADQLLibrary is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with ADQLLibrary. If not, see <http://www.gnu.org/licenses/>.
*
* Copyright 2012,2014 - UDS/Centre de Données astronomiques de Strasbourg (CDS),
* Astronomisches Rechen Institut (ARI)
*/
import java.util.NoSuchElementException;
import adql.query.ADQLIterator;
import adql.query.ADQLObject;
/**
* Lets wrapping an operand by parenthesis.
*
* @author Grégory Mantelet (CDS;ARI)
* @version 1.3 (10/2014)
*/
public class WrappedOperand implements ADQLOperand {
/** The wrapped operand. */
private ADQLOperand operand;
/**
* Wraps the given operand.
*
* @param operand Operand to wrap.
*
* @throws NullPointerException If the given operand is <i>NULL</i>.
*/
public WrappedOperand(ADQLOperand operand) throws NullPointerException{
if (operand == null)
throw new NullPointerException("Impossible to wrap a NULL operand: (NULL) has no sense !");
this.operand = operand;
}
/**
* Gets the wrapped operand.
*
* @return Its operand.
*/
public final ADQLOperand getOperand(){
return operand;
}
@Override
public final boolean isNumeric(){
return operand.isNumeric();
}
@Override
public final boolean isString(){
return operand.isString();
}
@Override
public final boolean isGeometry(){
return operand.isGeometry();
}
@Override
public ADQLObject getCopy() throws Exception{
return new WrappedOperand((ADQLOperand)operand.getCopy());
}
@Override
public String getName(){
return "(" + operand.getName() + ")";
}
@Override
public ADQLIterator adqlIterator(){
return new ADQLIterator(){
private boolean operandGot = (operand == null);
@Override
public ADQLObject next(){
if (operandGot)
throw new NoSuchElementException();
operandGot = true;
return operand;
}
@Override
public boolean hasNext(){
return !operandGot;
}
@Override
public void replace(ADQLObject replacer) throws UnsupportedOperationException, IllegalStateException{
if (!operandGot)
throw new IllegalStateException("replace(ADQLObject) impossible: next() has not yet been called !");
if (replacer == null)
remove();
else if (replacer instanceof ADQLOperand)
operand = (ADQLOperand)replacer;
else
throw new UnsupportedOperationException("Impossible to replace an ADQLOperand (\"" + operand + "\") by a " + replacer.getClass().getName() + " (\"" + replacer.toADQL() + "\") !");
}
@Override
public void remove(){
if (!operandGot)
throw new IllegalStateException("remove() impossible: next() has not yet been called !");
else
throw new UnsupportedOperationException("Impossible to remove the only item of the WrappedOperand \"" + toADQL() + "\": the WrappedOperand would be empty !");
}
};
}
@Override
public String toADQL(){
return "(" + operand.toADQL() + ")";
}
}