Package opendap.servers
Class CEEvaluator
java.lang.Object
opendap.servers.CEEvaluator
This class is used to parse and evaluate a constraint expression. When
constructed it must be passed a valid DDS along with the expression. This
DDS will be used as the environment (collection of variables and
functions) during the parse and evaluation of the constraint expression.
A server (servlet, CGI, ...) must first instantiate the DDS (possibly
reading it from a cache) and then create and instance of this class. Once
created, the constraint may be parsed and then evaluated. The class
supports sending data based on the results of CE evaluation. That is, the
send() method of the class combines both the evaluation of the constraint
and the output of data values so that the server can return data using a
single method call.
Custom parsing The CEEvaluator parses constraint expressions into Clause objects using a ClauseFactory. Customized behavior during parsing can be achieved by passing a customized ClauseFactory into the CEEvaluator.
Support for server side functions Server side functions are supported via the FunctionLibrary class. Custom server side function support is achieved by using a customized ClauseFactory which in turn contains a customized FunctionLibrary.
More details are found in the documentation for the respective classes.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCEEvaluator(ServerDDS dds) Construct a newCEEvaluatorwithddsas the DDS object with which to resolve all variable and function names.CEEvaluator(ServerDDS dds, ClauseFactory clauseFactory) Construct a newCEEvaluatorwithddsas the DDS object with which to resolve all variable and function names, andclauseFactoryas a source of Clause objects . -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a clause to the constraint expression.booleanevalClauses(Object specialO) Evaluate all of the Clauses in the Clause vector.final EnumerationGet access to the list of clauses built by parsing the selection part of the constraint expression.getDDS()Return a reference to the CEEvaluator's DDS object.voidmarkAll(boolean state) Mark all the variables in the DDS either as part of the current projection (whenstateis true) or not (stateis false).voidparseConstraint(String constraint, String urlencoded) Parse a constraint expression.voidConvenience wrapper for parseConstraint.voidPrint all of the Clauses in the Clause vector.booleanRemove a clause from the constraint expression.voidsend(String dataset, OutputStream sink, Object specialO) This function sends the variables described in the constrained DDS to the output described bysink.
-
Constructor Details
-
CEEvaluator
Construct a newCEEvaluatorwithddsas the DDS object with which to resolve all variable and function names.- Parameters:
dds- DDS object describing the dataset targeted by this constraint.
-
CEEvaluator
Construct a newCEEvaluatorwithddsas the DDS object with which to resolve all variable and function names, andclauseFactoryas a source of Clause objects .- Parameters:
clauseFactory- The factory which will be used by the parser to construct the clause tree. This allows servers to pass in a factory which creates custom clause objects.dds- DDS object describing the dataset targeted by this constraint.
-
-
Method Details
-
getDDS
Return a reference to the CEEvaluator's DDS object. -
parseConstraint
public void parseConstraint(String constraint, String urlencoded) throws opendap.dap.parsers.ParseException, opendap.dap.DAP2Exception, opendap.dap.NoSuchVariableException, opendap.dap.NoSuchFunctionException, InvalidOperatorException, InvalidParameterException, SBHException, WrongTypeException Parse a constraint expression. Variables in the projection are marked as such in the CEEvaluator's ServerDDS instance. The selection subexpression is then parsed and a list of Clause objects is built. The parser is located in opendap.servers.parsers.CeParser.- Parameters:
constraint- The constraint expression to parse.- Throws:
opendap.dap.parsers.ParseExceptionopendap.dap.NoSuchVariableExceptionopendap.dap.NoSuchFunctionExceptionInvalidOperatorExceptionInvalidParameterExceptionSBHExceptionopendap.dap.DAP2ExceptionWrongTypeException
-
parseConstraint
public void parseConstraint(ReqState rs) throws opendap.dap.parsers.ParseException, opendap.dap.DAP2Exception, opendap.dap.NoSuchVariableException, opendap.dap.NoSuchFunctionException, InvalidOperatorException, InvalidParameterException, SBHException, WrongTypeException Convenience wrapper for parseConstraint.- Parameters:
rs-- Throws:
opendap.dap.parsers.ParseExceptionopendap.dap.DAP2Exceptionopendap.dap.NoSuchVariableExceptionopendap.dap.NoSuchFunctionExceptionInvalidOperatorExceptionInvalidParameterExceptionSBHExceptionWrongTypeException
-
appendClause
Add a clause to the constraint expression.- Parameters:
c- The Clause to append.
-
removeClause
Remove a clause from the constraint expression. This will will remove the first occurence of the passed clause from the constraint expression. This is done be reference, so if the passed Clause object is NOT already in the constraint expression then nothing happens. And, if it should appear more than once (which I don't think is possible) only the first occurence will be removed.- Parameters:
c- The Clause to append.- Returns:
- True if constraint expression contained the passed Clause object and it was successfully removed.
-
getClauses
Get access to the list of clauses built by parsing the selection part of the constraint expression. NB: This is not valid until the CE has been parsed! -
send
public void send(String dataset, OutputStream sink, Object specialO) throws opendap.dap.NoSuchVariableException, DAP2ServerSideException, IOException This function sends the variables described in the constrained DDS to the output described bysink. This function callsparse_constraint(),BaseType::read(), andServerIO::serialize().- Parameters:
dataset- The name of the dataset to send.sink- A pointer to the output buffer for the data.specialO- AnObjectpassed by the server. This is typically used by server implementations to deliver needed functionaliy or information to the read methods of eachBaseType.- Throws:
opendap.dap.NoSuchVariableExceptionDAP2ServerSideExceptionIOException- See Also:
-
evalClauses
public boolean evalClauses(Object specialO) throws opendap.dap.NoSuchVariableException, DAP2ServerSideException, IOException Evaluate all of the Clauses in the Clause vector.- Parameters:
specialO- That special Object that can be passed down through theDDS.send()method.- Returns:
- True if all the Clauses evaluate to true, false otherwise.
- Throws:
opendap.dap.NoSuchVariableExceptionDAP2ServerSideExceptionIOException
-
markAll
public void markAll(boolean state) throws opendap.dap.DAP2Exception, opendap.dap.NoSuchVariableException, SBHException Mark all the variables in the DDS either as part of the current projection (whenstateis true) or not (stateis false). This is a convenience function that provides a way to clear or set an entire dataset described by a DDS with respect to its projection.- Parameters:
state- true if the variables should all be projected, false is no variable should be projected.- Throws:
opendap.dap.DAP2Exceptionopendap.dap.NoSuchVariableExceptionSBHException
-
printConstraint
Print all of the Clauses in the Clause vector.
-