ResultSetJELRowReader
, StarTableJELRowReader
, TablelessJELRowReader
public abstract class JELRowReader
extends gnu.jel.DVMap
evaluate(gnu.jel.CompiledExpression)
method.
This class currently deals with columns of all the primitive types,
objects of type String
or Date
,
and arrays of any of these.
Anything else is treated as an Object or Object[].
It could be extended to deal with more if necessary.
Expressions of the following types are understood:
Object
.
This can be useful for passing to functions that need to know
whether a null value is present (which cannot be represented
in primitive types).
Modifier and Type | Field | Description |
---|---|---|
static char |
COLUMN_ID_CHAR |
Prefix identifying a unique column identifier.
|
static java.lang.String |
NULL_QUERY_PREFIX |
The string which, when prefixed to a column identifier, indicates
that the null-ness of the column should be queried.
|
static java.lang.String |
OBJECT_PREFIX |
The string which, when prefixed to a column identifier, indicates
that the value is required as an Object not a primitive.
|
Constructor | Description |
---|---|
JELRowReader() |
Constructor.
|
Modifier and Type | Method | Description |
---|---|---|
java.lang.Object |
evaluate(gnu.jel.CompiledExpression compEx) |
Evaluates a given compiled expression at the current row.
|
double |
evaluateDouble(gnu.jel.CompiledExpression compEx) |
Evaluates a given compiled expression at the given row under the
assumption that the expression represents a numeric value.
|
protected void |
foundNull() |
Must be called by any of the
getObjectColumnValue methods
which wants to return a null but has to return a
primitive instead. |
boolean[] |
getBooleanArrayProperty(int id) |
|
protected abstract boolean |
getBooleanColumnValue(int icol) |
Returns a boolean value for a cell of the current row.
|
boolean |
getBooleanProperty(int id) |
|
boolean |
getBooleanProperty(long inul) |
Indicates whether the cell at the current row in a given column
has a blank value.
|
boolean |
getBooleanValue(java.lang.Boolean value) |
|
byte[] |
getByteArrayProperty(int id) |
|
protected abstract byte |
getByteColumnValue(int icol) |
Returns a byte value for a cell of the current row.
|
byte |
getByteProperty(int id) |
|
byte |
getByteValue(java.lang.Byte value) |
|
char[] |
getCharArrayProperty(int id) |
|
protected abstract char |
getCharColumnValue(int icol) |
Returns a char value for a cell of the current row.
|
char |
getCharProperty(int id) |
|
char |
getCharValue(java.lang.Character value) |
|
protected abstract java.lang.Class |
getColumnClass(int icol) |
Returns the class of values returned by a given column.
|
int |
getColumnIndex(java.lang.String name) |
Returns the column index in the table model which corresponds to
a given name.
|
protected abstract int |
getColumnIndexByName(java.lang.String name) |
Returns the column index of a column in the row given its name.
|
protected abstract Constant |
getConstantByName(java.lang.String name) |
Returns a constant value for this reader given its name.
|
java.util.Date[] |
getDateArrayProperty(int id) |
|
double[] |
getDoubleArrayProperty(int id) |
|
protected abstract double |
getDoubleColumnValue(int icol) |
Returns a double value for a cell of the current row.
|
double |
getDoubleProperty(int id) |
|
double |
getDoubleValue(java.lang.Double value) |
|
float[] |
getFloatArrayProperty(int id) |
|
protected abstract float |
getFloatColumnValue(int icol) |
Returns a float value for a cell of the current row.
|
float |
getFloatProperty(int id) |
|
float |
getFloatValue(java.lang.Float value) |
|
int[] |
getIntArrayProperty(int id) |
|
protected abstract int |
getIntColumnValue(int icol) |
Returns a int value for a cell of the current row.
|
int |
getIntProperty(int id) |
|
int |
getIntValue(java.lang.Integer value) |
|
long[] |
getLongArrayProperty(int id) |
|
protected abstract long |
getLongColumnValue(int icol) |
Returns a long value for a cell of the current row.
|
long |
getLongProperty(int id) |
|
long |
getLongValue(java.lang.Long value) |
|
java.lang.Number |
getNumberProperty(int id) |
|
java.lang.Object[] |
getObjectArrayProperty(int id) |
|
protected abstract java.lang.Object |
getObjectColumnValue(int icol) |
Returns an Object value for a cell of the current row.
|
java.lang.Object |
getObjectProperty(int id) |
|
short[] |
getShortArrayProperty(int id) |
|
protected abstract short |
getShortColumnValue(int icol) |
Returns a short value for a cell of the current row.
|
short |
getShortProperty(int id) |
|
short |
getShortValue(java.lang.Short value) |
|
protected Constant |
getSpecialByName(java.lang.String name) |
Returns the a special quantity which corresponds to
a given name, or null if it isn't a special.
|
java.lang.String[] |
getStringArrayProperty(int id) |
|
java.lang.String |
getStringProperty(int id) |
|
java.lang.String |
getTypeName(java.lang.String name) |
Returns the type name of the quantity which is referenced in
expressions with a given name.
|
protected abstract boolean |
isBlank(int icol) |
Indicates whether the value in a given column is null.
|
void |
setFailOnNull(boolean failOnNull) |
Configures the behaviour when a primitive integer or boolean
value passed as an argument to a function for evaluation
is represented by a null value in the column.
|
static java.lang.String |
stripPrefix(java.lang.String name,
java.lang.String prefix) |
Takes a token and strips a given prefix from it, returning the
remainder.
|
java.lang.Object |
translate(java.lang.String name) |
Turns a value specification into a constant object which can be
used at evaluation time to reference a particular quantity to
evaluate.
|
public static final java.lang.String NULL_QUERY_PREFIX
public static final java.lang.String OBJECT_PREFIX
public static final char COLUMN_ID_CHAR
public void setFailOnNull(boolean failOnNull)
The default behaviour is false.
failOnNull
- failOnNull flagprotected abstract int getColumnIndexByName(java.lang.String name)
name
does not refer to any known column, return -1.name
- column nameprotected abstract Constant getConstantByName(java.lang.String name)
name
- constant nameprotected abstract boolean isBlank(int icol)
icol
- column indexprotected abstract java.lang.Class getColumnClass(int icol)
icol
- column indexprotected abstract boolean getBooleanColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract byte getByteColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract char getCharColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract short getShortColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract int getIntColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract long getLongColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract float getFloatColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract double getDoubleColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.icol
- column indexprotected abstract java.lang.Object getObjectColumnValue(int icol)
icol
- column indexprotected void foundNull()
getObjectColumnValue
methods
which wants to return a null
but has to return a
primitive instead.protected Constant getSpecialByName(java.lang.String name)
The current specials are:
name
- special namepublic java.lang.Object evaluate(gnu.jel.CompiledExpression compEx) throws java.lang.Throwable
compEx
- compiled expressionjava.lang.Throwable
public double evaluateDouble(gnu.jel.CompiledExpression compEx) throws java.lang.Throwable
compEx
- numeric-valued compiled expressionjava.lang.Throwable
public java.lang.String getTypeName(java.lang.String name)
getTypeName
in class gnu.jel.DVMap
name
- the variable namepublic java.lang.Object translate(java.lang.String name)
This method is only called at expression compilation time, not evaluation time, so it doesn't need to be particularly fast.
translate
in class gnu.jel.DVMap
name
- the name of the variable-like object to evaluatepublic final int getColumnIndex(java.lang.String name)
Note this method is only called during expression compilation, so it doesn't need to be particularly efficient.
name
- column identifierpublic boolean getBooleanProperty(long inul)
inul
- column index (as a long)public boolean getBooleanProperty(int id)
public byte getByteProperty(int id)
public char getCharProperty(int id)
public short getShortProperty(int id)
public int getIntProperty(int id)
public long getLongProperty(int id)
public float getFloatProperty(int id)
public double getDoubleProperty(int id)
public java.lang.Object getObjectProperty(int id)
public java.lang.Number getNumberProperty(int id)
public java.lang.String getStringProperty(int id)
public boolean[] getBooleanArrayProperty(int id)
public byte[] getByteArrayProperty(int id)
public char[] getCharArrayProperty(int id)
public short[] getShortArrayProperty(int id)
public int[] getIntArrayProperty(int id)
public long[] getLongArrayProperty(int id)
public float[] getFloatArrayProperty(int id)
public double[] getDoubleArrayProperty(int id)
public java.lang.Object[] getObjectArrayProperty(int id)
public java.lang.String[] getStringArrayProperty(int id)
public java.util.Date[] getDateArrayProperty(int id)
public boolean getBooleanValue(java.lang.Boolean value)
public byte getByteValue(java.lang.Byte value)
public char getCharValue(java.lang.Character value)
public short getShortValue(java.lang.Short value)
public int getIntValue(java.lang.Integer value)
public long getLongValue(java.lang.Long value)
public float getFloatValue(java.lang.Float value)
public double getDoubleValue(java.lang.Double value)
public static java.lang.String stripPrefix(java.lang.String name, java.lang.String prefix)
name
does not begin with
prefix
(or if it is exactly equal to it),
then null
is returned.name
- token which may begin with prefix
prefix
- maybe matches the start of name
name
minux prefix
,
or null
NULL_QUERY_PREFIX
Copyright © 2018 Central Laboratory of the Research Councils. All Rights Reserved.