|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.jel.DVMap
uk.ac.starlink.ttools.jel.JELRowReader
public abstract class JELRowReader
An object which is able to read cell values by column name or number.
The values are got using the 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).
Field Summary | |
---|---|
static char |
COLUMN_ID_CHAR
Prefix identifying a unique column identifier. |
static 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 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 Summary | |
---|---|
JELRowReader()
Constructor. |
Method Summary | |
---|---|
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(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(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(Character value)
|
protected abstract Class |
getColumnClass(int icol)
Returns the class of values returned by a given column. |
int |
getColumnIndex(String name)
Returns the column index in the table model which corresponds to a given name. |
protected abstract int |
getColumnIndexByName(String name)
Returns the column index of a column in the row given its name. |
protected abstract Constant |
getConstantByName(String name)
Returns a constant value for this reader given its name. |
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(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(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(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(Long value)
|
Number |
getNumberProperty(int id)
|
Object[] |
getObjectArrayProperty(int id)
|
protected abstract Object |
getObjectColumnValue(int icol)
Returns an Object value for a cell of the current row. |
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(Short value)
|
protected Constant |
getSpecialByName(String name)
Returns the a special quantity which corresponds to a given name, or null if it isn't a special. |
String[] |
getStringArrayProperty(int id)
|
String |
getStringProperty(int id)
|
String |
getTypeName(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 String |
stripPrefix(String name,
String prefix)
Takes a token and strips a given prefix from it, returning the remainder. |
Object |
translate(String name)
Turns a value specification into a constant object which can be used at evaluation time to reference a particular quantity to evaluate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String NULL_QUERY_PREFIX
public static final String OBJECT_PREFIX
public static final char COLUMN_ID_CHAR
Constructor Detail |
---|
public JELRowReader()
Method Detail |
---|
public void setFailOnNull(boolean failOnNull)
The default behaviour is false.
failOnNull
- failOnNull flagprotected abstract int getColumnIndexByName(String name)
name
does not refer to any known column, return -1.
name
- column name
protected abstract Constant getConstantByName(String name)
name
- constant name
protected abstract boolean isBlank(int icol)
icol
- column index
protected abstract Class getColumnClass(int icol)
icol
- column index
protected abstract boolean getBooleanColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract byte getByteColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract char getCharColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract short getShortColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract int getIntColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract long getLongColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract float getFloatColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract double getDoubleColumnValue(int icol)
foundNull()
(and return any value) if the result
is null.
icol
- column index
protected abstract Object getObjectColumnValue(int icol)
icol
- column index
protected void foundNull()
getObjectColumnValue
methods
which wants to return a null
but has to return a
primitive instead.
protected Constant getSpecialByName(String name)
The current specials are:
name
- special name
public Object evaluate(gnu.jel.CompiledExpression compEx) throws Throwable
compEx
- compiled expression
Throwable
public double evaluateDouble(gnu.jel.CompiledExpression compEx) throws Throwable
compEx
- numeric-valued compiled expression
Throwable
public String getTypeName(String name)
getTypeName
in class gnu.jel.DVMap
name
- the variable name
public Object translate(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 evaluate
public final int getColumnIndex(String name)
Note this method is only called during expression compilation, so it doesn't need to be particularly efficient.
name
- column identifier
public 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 Object getObjectProperty(int id)
public Number getNumberProperty(int id)
public 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 Object[] getObjectArrayProperty(int id)
public String[] getStringArrayProperty(int id)
public Date[] getDateArrayProperty(int id)
public boolean getBooleanValue(Boolean value)
public byte getByteValue(Byte value)
public char getCharValue(Character value)
public short getShortValue(Short value)
public int getIntValue(Integer value)
public long getLongValue(Long value)
public float getFloatValue(Float value)
public double getDoubleValue(Double value)
public static String stripPrefix(String name, 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
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |