| java.lang.Object com.salmonllc.sql.DataStoreEvaluator
DataStoreEvaluator | public class DataStoreEvaluator implements java.io.Serializable(Code) | | This type is used to evaluate java-like expressions using rows in a DataBuffer.
The class needs to be passed a String containing the expression that will be used. This expression will be parsed and evaluated using the evaluate row method.The rules for expressions are as follows:
Column names: Columns in the datastore can be referenced in the same way that they are referenced in the get and set methods in the datastore. Generally this is either by using tablename.columnname or a single intenral name string. Which you can use depends on how the column was added to the datastore.
Comparisons: You can use ==, >=, <=, !=, > or < comparisons in your expressions. Use these to compare the values of Strings, Dates, Numbers or Booleans. (Note: The values of each part of the comparison will be used as opposed to the default java method which will test object references).
Operators: You can use +, -, /, * and ^ (exponent) to perform operations on numeric values. The + operator may also be used to concatinate String values.
In addition the if operator can be used to return a value based on a comparison. The syntax for if is : if(comparison,truevalue,falsevalue)
Literals: String Literals are surrounded by double quotes, Date, DateTime or Time Literals are also surrounded by quotes and in JDBC date escape form YYYY-MM-DD for dates, HH:MM:SS for times and a combination of the two for DateTimes
Nulls: The constant "null" can be used to check for columns values that are filled in. The equals(==) and not equals(!=) comparisons will return valid results when used with null. Every other comparison returns false when used with a null value on either side of the expression.
Several methods are available that can be called on the various columns in the datastore. This is done by placing the method name after the column name followed by any method parameters. ex: table1.column1.substring(0,10). Methods can only be invoked on columns in the datastore, not on literals as in Java. Any method invoked on a null column will itself return null.
Examples:
"table1.column1 == 'xxxx'"
"table1.column1.substring(2,3) + 'xxx'"
String Methods:
String substring(int start, int end): Gets a section of the String starting at start and ending at the character before end.
Integer indexOf(String subString) : Finds the first position of subString in the string or -1 if no occurance is found.
Integer lastIndexOf(String substring) : Finds the last position of subString in the string or -1 if no occurance is found.
Integer length() : Finds the length of the string in characters.
String toUpperCase(): Returns an all upper case version of the string.
String urlEncode(): Replaces ampersand, questionmarks and spaces in a String with URL Encoded Characters
String toLowerCase(): Returns an all lower case version of the string.
String trim(): Returns all leading and trailing spaces from the string.
String charAt(int position): Returns the character at position.
String startsWith(String substring): Returns true if the string starts with the specified substring.
String endsWith(String substring): Returns true if the string ends with the specified substring.
String escape(): Returns a string with quotes and spaces escaped so they work in javascript code.
String tempValue(): Returns a string with the temporary value of the column
Numeric Methods:
Double sqrt(): Returns the square root of the number.
Double round(int places): Returns the number rounded to "places" number of decimal places.
String format(String pattern): Format the value as a string using the specified pattern.
Date Methods:
Integer getMonth(): Returns the month of the given date (January = 0, Dec = 11).
Integer getDate(): Returns the day of the month of the given date.
Integer getDay(): Returns the day of the week of a given date (Sunday = 0, Saturday = 6).
Integer getYear(): Returns the year of the given date.
Integer getHours(): Returns the hours of the given time.
Integer getMinutes(): Returns the Minutes of the given time.
Integer getSeconds(): Returns the Seconds of the given time.
Date toDate(): Returns the Date portion of a DateTime.
Time toTime(): Returns the Time portion of a DateTime.
Date dateAdd(int days): Returns the specified date incremented by "days" number of days.
String format(String pattern): Format the value as a string using the specified pattern.
There are also five constants you can use
null: The value null
$DATE$:todays date as a Date value
$TIME$: todays date and time as Datetime value
$ROWNO$: the number of the row that the evaluator is evaluating
$ROWCOUNT$: the total number of the rows in the datastore
$ROWSTATUS$: the status of the row. See DatastoreBuffer.STATUS constants
$QUOT$: include a single quote in a string
|
Method Summary | |
public Object | evaluateAggregate(int aggregateType) This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. | public Object | evaluateAggregate(int aggregateType, int startRow, int endRow) This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. | public String | evaluateAggregateFormat(int aggregateType) This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. | public String | evaluateAggregateFormat(int aggregateType, int startRow, int endRow) This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. | public Object | evaluateRow() This method evaluates the expression passed in the constructor for the current row in the DataStoreBuffer. | public Object | evaluateRow(int rowNo) This method evaluates the expression passed in the constructor for a particular row in the DataStoreBuffer.
Parameters: rowNo - - row The row to evaluate. | public String | evaluateRowFormat() This method evaluates the expression passed in the constructor for the current row in the DataStoreBuffer. | public String | evaluateRowFormat(int rowNo) This method evaluates the expression passed in the constructor for a particular row in the DataStoreBuffer. | public DataStoreBuffer | getDataStore() | public DataStoreExpression | getDataStoreExpression() This method gets the DataStoreExpression being used for this DataStoreEvaluator. | public String | getExpression() This method returns the original expression that will be evaluated. | public String | getFormat() This method sets the display format for the result of the expression. | public String | getResultBucket() | public static boolean | isBoolean(String token) This method was created in VisualAge. | public static boolean | isDate(String token) This method was created in VisualAge. | public static boolean | isDateTime(String token) This method was created in VisualAge. | public static boolean | isNumber(String token) This method was created in VisualAge. | public static boolean | isString(String token) This method was created in VisualAge. | public static boolean | isTime(String token) This method was created in VisualAge. | public void | setFormat(String format) This method sets the display format for the result of the expression. | public void | setResultBucket(String resultBucket) Parameters: resultBucket - The resultBucket to set. |
AGGREGATE_AVERAGE | final public static int AGGREGATE_AVERAGE(Code) | | |
AGGREGATE_COUNT | final public static int AGGREGATE_COUNT(Code) | | |
AGGREGATE_SUM | final public static int AGGREGATE_SUM(Code) | | |
DataStoreEvaluator | public DataStoreEvaluator(DataStoreBuffer db, DataStoreExpression expression) throws DataStoreException(Code) | | This method will construct a new DataStoreEvaluator using the specified expression.
Parameters: db - The DataStoreBuffer to evaluate. Parameters: expression - The expression to evaluate. |
DataStoreEvaluator | public DataStoreEvaluator(DataStoreBuffer db, String expression) throws DataStoreException(Code) | | This method will construct a new DataStoreEvaluator using the specified expression.
Parameters: db - The DataStoreBuffer to evaluate. Parameters: expression - The expression to evaluate. |
DataStoreEvaluator | public DataStoreEvaluator(DataStoreBuffer db, String expression, String format) throws DataStoreException(Code) | | This method will construct a new DataStoreEvaluator using the specified expression.
Parameters: db - The DataStoreBuffer to evaluate. Parameters: expression - The expression to evaluate. Parameters: format - The pattern for the output. See Also: DataStore.setFormat |
evaluateAggregate | public Object evaluateAggregate(int aggregateType) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer.
A object with the result of the evaluation. Parameters: aggregateType - Valid Values are:AGGREGATE_SUM, AGGREGATE_COUNT |
evaluateAggregate | public Object evaluateAggregate(int aggregateType, int startRow, int endRow) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer.
A object with the result of the evaluation. Parameters: aggregateType - Valid Values are:AGGREGATE_SUM, AGGREGATE_COUNT Parameters: startRow - the first row to evaluate Parameters: endRow - the last row to evaluate |
evaluateAggregateFormat | public String evaluateAggregateFormat(int aggregateType) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. It will format the output according to the parrern specified and return a string version of it.
A object with the result of the evaluation. Parameters: aggregateType - Valid Values are:AGGREGATE_SUM, AGGREGATE_COUNT |
evaluateAggregateFormat | public String evaluateAggregateFormat(int aggregateType, int startRow, int endRow) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for every row in the DataStoreBuffer. It will format the output according to the parrern specified and return a string version of it.
A object with the result of the evaluation. Parameters: aggregateType - Valid Values are:AGGREGATE_SUM, AGGREGATE_COUNT Parameters: startRow - the first row to evaluate Parameters: endRow - the last row to evaluate |
evaluateRow | public Object evaluateRow() throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for the current row in the DataStoreBuffer.
A object with the result of the evaluation. |
evaluateRow | public Object evaluateRow(int rowNo) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for a particular row in the DataStoreBuffer.
Parameters: rowNo - - row The row to evaluate. A object with the result of the evaluation. throws: DataStoreException - |
evaluateRowFormat | public String evaluateRowFormat() throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for the current row in the DataStoreBuffer. It will then format the result using the format pattern and return a String version of the result;
A String representation of the result of the evaluation. |
evaluateRowFormat | public String evaluateRowFormat(int rowNo) throws DataStoreException(Code) | | This method evaluates the expression passed in the constructor for a particular row in the DataStoreBuffer. It will then format the result using the format pattern and return a String version of the result;
A String representation of the result of the evaluation. Parameters: rowNo - The row to evaluate. |
getDataStoreExpression | public DataStoreExpression getDataStoreExpression()(Code) | | This method gets the DataStoreExpression being used for this DataStoreEvaluator.
DataStoreExpression |
getExpression | public String getExpression()(Code) | | This method returns the original expression that will be evaluated.
|
getFormat | public String getFormat()(Code) | | This method sets the display format for the result of the expression.
See Also: DataStore#setFormat(String,String). |
getResultBucket | public String getResultBucket()(Code) | | Returns the resultBucket, a column to place the value of the results of the expression. |
isBoolean | public static boolean isBoolean(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
isDate | public static boolean isDate(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
isDateTime | public static boolean isDateTime(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
isNumber | public static boolean isNumber(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
isString | public static boolean isString(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
isTime | public static boolean isTime(String token)(Code) | | This method was created in VisualAge.
boolean Parameters: token - java.lang.String |
setFormat | public void setFormat(String format)(Code) | | This method sets the display format for the result of the expression.
See Also: DataStore#setFormat(String,String). |
setResultBucket | public void setResultBucket(String resultBucket)(Code) | | Parameters: resultBucket - The resultBucket to set. A column to place the value of the results of the expression |
|
|