org.sqlproc.engine.impl
Class SqlProcessContext

java.lang.Object
  extended by org.sqlproc.engine.impl.SqlProcessContext

public class SqlProcessContext
extends Object

The crate (design pattern) for all input parameters for the SqlMetaStatement.process(org.sqlproc.engine.impl.SqlMetaStatement.Type, Object, Object, List, Map, Map, SqlTypeFactory, SqlPluginFactory) Also can work as a context for a dynamic ANSI SQL query generation. This processing is based on the contract SqlMetaElement.process(SqlProcessContext).

Author:
Vladimir Hudec

Field Summary
private static ThreadLocal<Map<String,Object>> currentFeatures
          The thread local holder for the configuration object.
private static ThreadLocal<SqlPluginFactory> currentPluginFactory
          The thread local holder for the factory for the SQL Processor plugins.
private static ThreadLocal<SqlTypeFactory> currentTypeFactory
          The thread local holder for the factory responsible for the META types construction.
(package private)  Object dynamicInputValues
          The SQL statement dynamic parameters.
(package private)  boolean inSqlSetOrInsert
          An indicator, that the processing is inside of the special SQL fragment - SET or VALUES.
(package private)  List<SqlOrder> order
          The list of ordering directives.
(package private)  SqlMetaStatement.Type sqlStatementType
          The SQL command type.
(package private)  Object staticInputValues
          The SQL statement static parameters.
 
Constructor Summary
SqlProcessContext(SqlMetaStatement.Type sqlStatementType, Object dynamicInputValues, Object staticInputValues, List<SqlOrder> order, Map<String,Object> features, Map<String,Object> runtimeFeatures, SqlTypeFactory typeFactory, SqlPluginFactory pluginFactory)
          Creates a new instance.
 
Method Summary
static String getFeature(String name)
          Convenient method to obtain a String feature based on the name.
static Integer getFeatureAsInt(String name)
          Convenient method to obtain an Integer feature based on the name.
static Object getFeatureAsObject(String name)
          Convenient method to obtain an Object feature based on the name.
(package private) static Map<String,Object> getFeatures()
          Returns the features for the current thread.
static String[] getFeatures(String name)
          Convenient method to obtain a String array features based on the name.
(package private)  SqlOrder.Order getOrder(int orderIndex)
          Convenient method to obtain the ordering directive based on the index.
(package private)  int getOrderIndex(int orderId)
          Convenient method to obtain the index of the ordering directive.
static SqlPluginFactory getPluginFactory()
          Returns the factory for the current thread responsible for the SQL Processor plugins.
 SqlMetaStatement.Type getSqlStatementType()
           
static SqlTypeFactory getTypeFactory()
          Returns the factory for the current thread responsible for the META types construction.
static boolean isFeature(String name)
          Convenient method to obtain a boolean feature based on the name.
(package private) static void nullFeatures()
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
(package private) static void nullPluginFactory()
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
(package private) static void nullTypeFactory()
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
(package private) static void setFeatures(Map<String,Object> features, Map<String,Object> runtimeFeatures)
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
(package private) static void setPluginFactory(SqlPluginFactory pluginFactory)
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
(package private) static void setTypeFactory(SqlTypeFactory typeFactory)
          THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

sqlStatementType

SqlMetaStatement.Type sqlStatementType
The SQL command type.


dynamicInputValues

Object dynamicInputValues
The SQL statement dynamic parameters.


staticInputValues

Object staticInputValues
The SQL statement static parameters.


order

List<SqlOrder> order
The list of ordering directives.


inSqlSetOrInsert

boolean inSqlSetOrInsert
An indicator, that the processing is inside of the special SQL fragment - SET or VALUES.


currentFeatures

private static final ThreadLocal<Map<String,Object>> currentFeatures
The thread local holder for the configuration object.


currentTypeFactory

private static final ThreadLocal<SqlTypeFactory> currentTypeFactory
The thread local holder for the factory responsible for the META types construction.


currentPluginFactory

private static final ThreadLocal<SqlPluginFactory> currentPluginFactory
The thread local holder for the factory for the SQL Processor plugins. This is the basic facility to alter the SQL Processor processing.

Constructor Detail

SqlProcessContext

SqlProcessContext(SqlMetaStatement.Type sqlStatementType,
                  Object dynamicInputValues,
                  Object staticInputValues,
                  List<SqlOrder> order,
                  Map<String,Object> features,
                  Map<String,Object> runtimeFeatures,
                  SqlTypeFactory typeFactory,
                  SqlPluginFactory pluginFactory)
Creates a new instance.

Parameters:
sqlStatementType - the type of the SQL command
dynamicInputValues - the dynamic input parameters
staticInputValues - the static input parameters
order - the list of ordering directives
features - the optional features in the statement/global scope
runtimeFeatures - the optional features in the statement's exection scope
typeFactory - the factory for the META types construction
pluginFactory - the factory for the SQL Processor plugins
Method Detail

getSqlStatementType

public SqlMetaStatement.Type getSqlStatementType()

getFeature

public static String getFeature(String name)
Convenient method to obtain a String feature based on the name.

Parameters:
name - name of the feature
Returns:
value of the feature

getFeatures

public static String[] getFeatures(String name)
Convenient method to obtain a String array features based on the name.

Parameters:
name - name of the feature
Returns:
the array of the feature values

isFeature

public static boolean isFeature(String name)
Convenient method to obtain a boolean feature based on the name.

Parameters:
name - name of the feature
Returns:
value of the feature

getFeatureAsInt

public static Integer getFeatureAsInt(String name)
Convenient method to obtain an Integer feature based on the name.

Parameters:
name - name of the feature
Returns:
value of the feature

getFeatureAsObject

public static Object getFeatureAsObject(String name)
Convenient method to obtain an Object feature based on the name.

Parameters:
name - name of the feature
Returns:
value of the feature

getOrderIndex

int getOrderIndex(int orderId)
Convenient method to obtain the index of the ordering directive.

Parameters:
orderId - the order number
Returns:
the index of the ordering directive

getOrder

SqlOrder.Order getOrder(int orderIndex)
Convenient method to obtain the ordering directive based on the index.

Parameters:
orderIndex - the index of the ordering rule
Returns:
the ordering directive

getFeatures

static Map<String,Object> getFeatures()
Returns the features for the current thread.

Returns:
the current thread's features

setFeatures

static void setFeatures(Map<String,Object> features,
                        Map<String,Object> runtimeFeatures)
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT.

Parameters:
features - the optional features in the statement/global scope
runtimeFeatures - the optional features in the statement's exection scope

nullFeatures

static void nullFeatures()
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT. IT'S USED ONLY FROM JUNIT TESTS.


getTypeFactory

public static SqlTypeFactory getTypeFactory()
Returns the factory for the current thread responsible for the META types construction.

Returns:
the current thread's factory for the META types construction

setTypeFactory

static void setTypeFactory(SqlTypeFactory typeFactory)
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT.

Parameters:
typeFactory - the factory for the META types construction

nullTypeFactory

static void nullTypeFactory()
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT. IT'S USED ONLY FROM JUNIT TESTS.


getPluginFactory

public static SqlPluginFactory getPluginFactory()
Returns the factory for the current thread responsible for the SQL Processor plugins.

Returns:
the current thread's factory for the SQL Processor plugins

setPluginFactory

static void setPluginFactory(SqlPluginFactory pluginFactory)
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT.

Parameters:
pluginFactory - the factory for the SQL Processor plugins

nullPluginFactory

static void nullPluginFactory()
THIS METHOD IS NOT PART OF THE SQL PROCESSOR PUBLIC API. DO NOT USE IT. IT'S USED ONLY FROM JUNIT TESTS.



Copyright © 2014. All rights reserved.