|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectscriptella.driver.janino.JaninoScript
scriptella.driver.janino.JaninoQuery
public abstract class JaninoQuery
A base class for Janino <query> elements.
This class exposes a simplified query API. The concept of this API is the following:
set(String, Object)
for each virtual column.
next() is called to process this row by nested scripting elements.
helper method exists to make iterating even simpler.
Virtual rows may also be constructed from Map or Properties.
Public members of this class are available in Janino scripting elements.
Examples:
The following query produces two virtual rows:
| id | name | age |
|---|---|---|
| 123 | John | 20 |
| 200 | Mary |
<query>
set("id", "123"); //set row column
set("name", "John");
set("age", new Integer(20));
next();//sends a virtual row for processing
set("id", "200");
set("name", "Mary");
next();
</query>
The same effect may achieved using the following code:
<query>
String[] names = new String[] {"id", "name", "age"};
next(names, new Object[] {"123", "John", new Integer(20)};
next(names, new Object[] {"200", "Mary", null)};
</query>
Assume you have a map(or Properties) with the following mapping:
id->123, name->John, age->20
A virtual row is produced using this code:
<query>
//fill a map or load properties file
next(map};
</query>
| Constructor Summary | |
|---|---|
JaninoQuery()
|
|
| Method Summary | |
|---|---|
java.lang.Object |
getParameter(java.lang.String name)
|
scriptella.spi.QueryCallback |
getQueryCallback()
|
void |
next()
Moves to the next virtual row. |
void |
next(java.util.Map<java.lang.String,?> parametersMap)
Produces a virtual row based on the specified columns. |
void |
next(java.lang.String[] parameterNames,
java.lang.Object[] values)
Produces a virtual row based on the specified columns. |
void |
set(java.util.Map<java.lang.String,?> parametersMap)
Fills the virtual row using parameters from specified map. |
void |
set(java.lang.String name,
java.lang.Object value)
Sets a value for specified parameter name. |
java.lang.String |
toString()
|
| Methods inherited from class scriptella.driver.janino.JaninoScript |
|---|
execute, get, getParametersCallback |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public JaninoQuery()
| Method Detail |
|---|
public final scriptella.spi.QueryCallback getQueryCallback()
public final java.lang.Object getParameter(java.lang.String name)
getParameter in interface scriptella.spi.ParametersCallback
public final void set(java.lang.String name,
java.lang.Object value)
This parameter becomes visible to nested scripting elements
after next() method is called.
This method is available inside Janino <query> element.
name - parameter namevalue - parameter value.public final void set(java.util.Map<java.lang.String,?> parametersMap)
This method is available inside Janino <query> element.
parametersMap - map of parameters, where key is a variable namepublic final void next()
Nested scripting elements are evaluated and
the parameters set by set(String, Object) method are available to them.
Note: The values of all parameters set via set(String, Object) method are
cleared(or restored).
This method is available inside Janino <query> element.
public final void next(java.lang.String[] parameterNames,
java.lang.Object[] values)
A serie of parameter setters is performed.
After parameters for the current row have been set, next() method is invoked.
This method is available inside Janino <query> element.
parameterNames - array of parameter names.values - array of parameter values, i.e. value[i] specifies a value for parameter[i].public final void next(java.util.Map<java.lang.String,?> parametersMap)
Parameters are set via set(java.util.Map) method.
After parameters for the current row have been set, next() method is invoked.
This method is available inside Janino <query> element.
parametersMap - map of parameters.public java.lang.String toString()
toString in class java.lang.Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||