Package org.sqlproc.engine.impl
Class SqlMetaStatement
- java.lang.Object
-
- org.sqlproc.engine.impl.SqlMetaStatement
-
- All Implemented Interfaces:
SqlMetaElement
public class SqlMetaStatement extends Object implements SqlMetaElement
Precompiled META SQL statement. Instance of this class is created by the ANTLR parser. The grammar is defined in SqlStatement.g. It's based on the Composite (desing pattern). The main contract isSqlMetaElement.process(SqlProcessContext)
Schematically:
SqlMetaStatement SqlMetaText SqlMetaIdent SqlMetaConst { SqlMetaAndOr} {? SqlMetaIf} {& SqlMetaAndOr} {| SqlMetaAndOr} {#DIGIT SqlMetaOrd}
- Author:
- Vladimir Hudec
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SqlMetaStatement.Type
The SQL command type.
-
Field Summary
Fields Modifier and Type Field Description (package private) List<SqlMetaElement>
elements
All sub-elements based on ANTLR grammar defined in SqlStatement.g.(package private) boolean
hasOutputMapping
An indicator for embedded output mappingprotected static org.slf4j.Logger
logger
The internal slf4j logger.(package private) String
raw
A raw representation this META SQL statement-
Fields inherited from interface org.sqlproc.engine.impl.SqlMetaElement
AND_PREFIX, CONST_PREFIX, IDENT_PREFIX, IDENT_SEPARATOR, lCONST_PREFIX, lIDENT_PREFIX, OR_PREFIX, SET_PREFIX, VALUES_PREFIX, WHERE_PREFIX
-
-
Constructor Summary
Constructors Constructor Description SqlMetaStatement()
Creates a new instance.SqlMetaStatement(String raw)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addElement(SqlMetaElement element)
Adds a new sub-element.static SqlMetaStatement
getInstance(String name, String statement, SqlTypeFactory typeFactory)
Simple factory method (design pattern).String
getRaw()
Returns raw representation this META SQL statementboolean
isHasOutputMapping()
Returns the indicator for embedded output mapping.SqlProcessResult
process(SqlMetaStatement.Type sqlStatementType, Object dynamicInputValues, SqlControl sqlControl, SqlEngine sqlEngine)
The main contract for a dynamic ANSI SQL Query generation.SqlProcessResult
process(SqlProcessContext ctx)
The main contract for a dynamic ANSI SQL Query generation.void
setHasOutputMapping(boolean hasOutputMapping)
Sets the indicator for embedded output mapping.
-
-
-
Field Detail
-
logger
protected static org.slf4j.Logger logger
The internal slf4j logger.
-
raw
String raw
A raw representation this META SQL statement
-
elements
List<SqlMetaElement> elements
All sub-elements based on ANTLR grammar defined in SqlStatement.g.
-
hasOutputMapping
boolean hasOutputMapping
An indicator for embedded output mapping
-
-
Constructor Detail
-
SqlMetaStatement
SqlMetaStatement()
Creates a new instance. It's used from inside ANTLR parser.
-
SqlMetaStatement
public SqlMetaStatement(String raw)
Creates a new instance. It's used from inside ANTLR parser.
-
-
Method Detail
-
getInstance
public static SqlMetaStatement getInstance(String name, String statement, SqlTypeFactory typeFactory) throws SqlEngineException
Simple factory method (design pattern). The new instance of precompiled META SQL is created from the String input by the ANTLR parser.- Parameters:
name
- the name of this META SQL query/statementstatement
- String representation of META SQL query/statementtypeFactory
- the factory for the META types construction- Returns:
- new instance of precompiled META SQL query/statement
- Throws:
SqlEngineException
- in the case of ANTLR parsing exception
-
getRaw
public String getRaw()
Returns raw representation this META SQL statement- Returns:
- raw representation this META SQL statement
-
addElement
void addElement(SqlMetaElement element)
Adds a new sub-element. It's used from inside ANTLR parser.- Parameters:
element
- new sub-element, based on ANTLR grammar
-
isHasOutputMapping
public boolean isHasOutputMapping()
Returns the indicator for embedded output mapping.- Returns:
- the indicator for embedded output mapping
-
setHasOutputMapping
public void setHasOutputMapping(boolean hasOutputMapping)
Sets the indicator for embedded output mapping.- Parameters:
hasOutputMapping
- the indicator for embedded output mapping
-
process
public SqlProcessResult process(SqlMetaStatement.Type sqlStatementType, Object dynamicInputValues, SqlControl sqlControl, SqlEngine sqlEngine)
The main contract for a dynamic ANSI SQL Query generation. The ANSI SQL Query creation is based on- META SQL
- dynamic input values
- static input values
- ordering list directive
- optional features
- Parameters:
sqlStatementType
- the SQL command typedynamicInputValues
- the SQL statement dynamic parameters (input values)sqlControl
- The compound parameters controlling the META SQL executionsqlEngine
- the primary SQL Processor class for the META SQL execution- Returns:
- the crate for ANSI SQL and other attributes, which control the SQL statement itself
-
process
public SqlProcessResult process(SqlProcessContext ctx)
The main contract for a dynamic ANSI SQL Query generation. Also known as a META SQL processing. The composite pattern main contract. All ANTLR grammar based elements must implement this contract.- Specified by:
process
in interfaceSqlMetaElement
- Parameters:
ctx
- the crate for all input parameters and the context of processing
-
-