Package org.sqlproc.engine.impl
Class SqlMappingRule
- java.lang.Object
-
- org.sqlproc.engine.impl.SqlMappingRule
-
public class SqlMappingRule extends Object
The precompiled mapping entity for one external META SQL mapping rule. Instances of this class are created by the ANTLR parser. The grammar itself is defined in SqlMapping.g. The main runtime contracts ismerge(SqlMappingRule, SqlProcessResult)
.Schematically:
SqlMappingRule = SqlMappingItem+ SqlMappingItem = dbName$sqlType$javaName^(value(=value2)?)*.javaName...
- Author:
- Vladimir Hudec
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Logger
logger
The internal slf4j logger.private Map<String,SqlMappingItem>
mappings
All sub-elements based on ANTLR grammar defined in SqlMapping.g.(package private) String
raw
A raw representation this output value mapping
-
Constructor Summary
Constructors Constructor Description SqlMappingRule()
Creates a new instance.SqlMappingRule(String raw)
Creates a new instance.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addMapping(SqlMappingItem item)
Adds a new Mapping item, which is a mapping rule for one column.static SqlMappingRule
getInstance(String name, String mappingStatement, SqlTypeFactory typeFactory)
Simple factory method (design pattern).(package private) Map<String,SqlMappingItem>
getMappings()
Returns a collection of all mapping items in this mapping rule.String
getRaw()
Returns raw representation this output value mappingstatic SqlMappingResult
merge(SqlMappingRule mapping, SqlProcessResult processResult)
Merge mapping rule for one META SQL query based on SqlMapping.g and SqlStatement.g.
-
-
-
Field Detail
-
logger
protected static org.slf4j.Logger logger
The internal slf4j logger.
-
raw
String raw
A raw representation this output value mapping
-
mappings
private Map<String,SqlMappingItem> mappings
All sub-elements based on ANTLR grammar defined in SqlMapping.g. Every sub-element is one mapping item.
-
-
Constructor Detail
-
SqlMappingRule
public SqlMappingRule()
Creates a new instance. It's used from inside ANTLR parser.
-
SqlMappingRule
public SqlMappingRule(String raw)
Creates a new instance. It's used from inside ANTLR parser.
-
-
Method Detail
-
getInstance
public static SqlMappingRule getInstance(String name, String mappingStatement, SqlTypeFactory typeFactory) throws SqlEngineException
Simple factory method (design pattern). The new instance of precompiled mapping rule is created from the String input by the ANTLR parser.- Parameters:
name
- the name of this mapping rulemappingStatement
- String representation of mapping ruletypeFactory
- the factory for the META types construction- Returns:
- the new instance of precompiled mapping rule
- Throws:
SqlEngineException
- in the case of ANTRL parsing exception
-
getRaw
public String getRaw()
Returns raw representation this output value mapping- Returns:
- raw representation this output value mapping
-
addMapping
void addMapping(SqlMappingItem item)
Adds a new Mapping item, which is a mapping rule for one column.- Parameters:
item
- the mapping item
-
getMappings
Map<String,SqlMappingItem> getMappings()
Returns a collection of all mapping items in this mapping rule.- Returns:
- the collection of all mapping items
-
merge
public static SqlMappingResult merge(SqlMappingRule mapping, SqlProcessResult processResult)
Merge mapping rule for one META SQL query based on SqlMapping.g and SqlStatement.g. The mapping rule based on SqlMapping.g has the higher priority compared to mapping rule based on SqlStatement.g. The mapping rule based on SqlStatement.g obtains a list of real output values.- Parameters:
mapping
- the mapping rule based on SqlMapping.gprocessResult
- contains a mapping rule based on SqlStatement.g- Returns:
- the crate for output mapping rule and database row identities
-
-