public class OdsxSelectConvert
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected static java.lang.String |
braces |
protected static java.lang.String |
delimiter |
static java.lang.String |
FROM
The keyword for the from clause.
|
protected java.lang.String |
lastToken |
protected static java.util.HashMap |
operatorInvList |
protected static java.util.HashMap |
operatorList |
protected static java.lang.String |
operators |
static java.lang.String |
SELECT
The keyword for the select clause.
|
protected static java.lang.String |
SPACES |
protected java.lang.String |
upperToken |
static java.lang.String |
WHERE
The keyword for the where clause.
|
Constructor and Description |
---|
OdsxSelectConvert()
The constructor.
|
Modifier and Type | Method and Description |
---|---|
protected AIDNameUnitId[] |
getAIDNameUnitId(ApplicationElement[] aeObj,
java.lang.String spec)
Get the AIDNameUnitId structure.
|
protected AIDNameUnitId[] |
getAIDNameUnitId(ApplicationElement[] aeObj,
java.util.Vector colSpec)
Get the AIDNameUnitId structure.
|
protected ApplicationAttribute[] |
getApplicationAttributes(ApplicationElement aeObj,
java.lang.String spec)
Get the application attributes belongs to the given string specification.
|
protected ApplicationElement[] |
getApplicationElements(ApplicationStructure asObj,
java.lang.String spec)
Get the application elements belongs to the given string specification.
|
protected ApplicationAttribute[][] |
getAttributes(ApplicationElement[] aeObj,
java.lang.String spec)
Get the application attributes belongs to the given string specification.
|
protected ApplicationAttribute[][] |
getAttributes(InstanceElement[] ieObj,
java.lang.String spec)
Get the application attributes belongs to the given string specification.
|
java.lang.String |
getConditionString(ApplicationStructure asObj,
SelValue selValue)
Get the string presentation of the given condition.
|
QueryStructure |
getQueryStructure(AoSession session,
java.util.HashMap map)
Get the ods query structure.
|
java.lang.String |
getSelectStatement(AoSession session,
QueryStructure query)
Get the select statement for the given query structure.
|
protected SelValue |
getSelValue(ApplicationElement[] aeObj,
java.lang.String field,
java.lang.String op,
java.lang.String val)
Get the SelValue structure.
|
protected java.util.Vector |
getSelValue(ApplicationElement[] aeObj,
java.util.Vector where,
java.util.Vector selVal,
java.util.Vector selOp)
Get the selection value.
|
protected java.lang.String |
getToken(java.util.StringTokenizer st)
Internal method to get a token.
|
boolean |
handleParsedOperator(java.util.Vector vec,
java.lang.String upperToken)
Handle found operants.
|
static void |
main(java.lang.String[] args)
The main testing method.
|
java.util.HashMap |
parse(java.lang.String statement)
Parse a statement.
|
java.util.Vector |
parseConditions(java.util.StringTokenizer st)
Parse the conditions of a where clause.
|
protected void |
parseFrom(java.util.StringTokenizer st,
java.util.HashMap map)
Parse the from clause.
|
protected void |
parseSelect(java.util.StringTokenizer st,
java.util.HashMap map)
Parse the select clause.
|
protected java.lang.String |
parseString(java.util.StringTokenizer st)
Parse the string literal.
|
protected void |
parseWhere(java.util.StringTokenizer st,
java.util.HashMap map)
Parse the where clause.
|
static void |
printCols(java.io.PrintStream out,
ResultColumn[] cols) |
static void |
printElemResultSet(java.io.PrintStream out,
ElemResultSet[] elemRes)
Print out the selection result.
|
static void |
showElemResultSet(ElemResultSet[] elemRes)
Print the given result sets to the standard output stream.
|
protected static final java.lang.String SPACES
public static final java.lang.String SELECT
public static final java.lang.String FROM
public static final java.lang.String WHERE
protected static final java.lang.String braces
protected static final java.lang.String operators
protected static final java.util.HashMap operatorList
protected static final java.util.HashMap operatorInvList
protected static final java.lang.String delimiter
protected java.lang.String lastToken
protected java.lang.String upperToken
protected java.lang.String getToken(java.util.StringTokenizer st)
public java.util.HashMap parse(java.lang.String statement)
Prefix | Description |
BA. | Request a BaseAttribute. |
BE. | Request a BaseElement. |
AA. | Request a ApplicationAttribute. |
AE. | Request a ApplicationElement. |
Keyword | Datatype | Description |
SELECT | java.util.Vector | The strings describing the elements to be selected. |
FROM | java.util.Vector | The strings describing the elements of the from clause. |
WHERE | java.util.Vector | The strings describing the condition. Each element could be a vector that contains a subcondition. |
Example:
select (BA.Id, Ba.N\\/ame)
from (BE.AoTest, AE.Measurement)
where ((BA.id < 10) && (BA.name == SG*))
statement
- the statement to be parsed.protected void parseSelect(java.util.StringTokenizer st, java.util.HashMap map)
st
- the tokenizer.map
- the parser result map.protected void parseFrom(java.util.StringTokenizer st, java.util.HashMap map)
st
- the tokenizer.map
- the parser result map.protected void parseWhere(java.util.StringTokenizer st, java.util.HashMap map)
st
- the tokenizer.map
- the parser result map.public java.util.Vector parseConditions(java.util.StringTokenizer st)
st
- the tokenizer.protected java.lang.String parseString(java.util.StringTokenizer st)
st
- the tokenizer.public boolean handleParsedOperator(java.util.Vector vec, java.lang.String upperToken)
vec
- the resulting vector.upperToken
- the current operant.public QueryStructure getQueryStructure(AoSession session, java.util.HashMap map) throws AoException
session
- the session to be used for query.map
- the result map of the parserAoException
AoSession
protected java.util.Vector getSelValue(ApplicationElement[] aeObj, java.util.Vector where, java.util.Vector selVal, java.util.Vector selOp)
aeObj
- An array containing the selected application elements.where
- The vector containing the where clause coming from parser.selVal
- The vector into the method can save the result. May be nullselOp
- The operations of the selection.protected SelValue getSelValue(ApplicationElement[] aeObj, java.lang.String field, java.lang.String op, java.lang.String val)
aeObj
- An array containing the application elements.field
- The field name or pattern.op
- the operation string.val
- The value string.protected AIDNameUnitId[] getAIDNameUnitId(ApplicationElement[] aeObj, java.util.Vector colSpec)
aeObj
- An array containing the application elements.colSpec
- The vector containing the column specification from select statement.protected AIDNameUnitId[] getAIDNameUnitId(ApplicationElement[] aeObj, java.lang.String spec)
aeObj
- An array containing the application elements.spec
- The column specification from select statement.protected ApplicationAttribute[][] getAttributes(InstanceElement[] ieObj, java.lang.String spec) throws AoException
ieObj
- the instance elements.spec
- The string specification.AoException
protected ApplicationAttribute[][] getAttributes(ApplicationElement[] aeObj, java.lang.String spec) throws AoException
aeObj
- the application elements.spec
- The string specification.AoException
protected ApplicationAttribute[] getApplicationAttributes(ApplicationElement aeObj, java.lang.String spec) throws AoException
aeObj
- the application element.spec
- The string specification.AoException
protected ApplicationElement[] getApplicationElements(ApplicationStructure asObj, java.lang.String spec) throws AoException
asObj
- the application structure.spec
- The string specification.AoException
public java.lang.String getSelectStatement(AoSession session, QueryStructure query) throws AoException
session
- The session to be used.query
- The query structure.AoException
AoSession
public java.lang.String getConditionString(ApplicationStructure asObj, SelValue selValue)
public static void printElemResultSet(java.io.PrintStream out, ElemResultSet[] elemRes)
out
- the the print stream to use.elemRes
- An array containing the result sets.org.asam.ods.ElemResultSet
- public static void showElemResultSet(ElemResultSet[] elemRes)
elemRes
- An array containing the result set.ElemResultSet
public static void printCols(java.io.PrintStream out, ResultColumn[] cols)
public static void main(java.lang.String[] args)