org.sqlproc.engine.impl
Class SqlMappingRule

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

public class SqlMappingRule
extends java.lang.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 is merge(SqlMappingRule, SqlProcessResult).

Schematically:

 SqlMappingRule = SqlMappingItem+
     SqlMappingItem = dbName$sqlType$javaName^(value(=value2)?)*.javaName...
 


Field Summary
protected static org.slf4j.Logger logger
          The internal slf4j logger.
private  java.util.Map<java.lang.String,SqlMappingItem> mappings
          All sub-elements based on ANTLR grammar defined in SqlMapping.g.
 
Constructor Summary
SqlMappingRule()
          Creates a new instance.
 
Method Summary
(package private)  void addMapping(SqlMappingItem item)
          Adds a new Mapping item, which is a mapping rule for one column.
static SqlMappingRule getInstance(java.lang.String mappingStatement, java.util.Map<java.lang.String,SqlMetaType> metaToTypeMap)
          Simple factory method (design pattern).
(package private)  java.util.Map<java.lang.String,SqlMappingItem> getMappings()
          Returns a collection of all mapping items in this mapping rule.
static SqlMappingResult merge(SqlMappingRule mapping, SqlProcessResult processResult)
          Merge mapping rule for one META SQL query based on SqlMapping.g and SqlStatement.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.slf4j.Logger logger
The internal slf4j logger.


mappings

private java.util.Map<java.lang.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.

Method Detail

getInstance

public static SqlMappingRule getInstance(java.lang.String mappingStatement,
                                         java.util.Map<java.lang.String,SqlMetaType> metaToTypeMap)
                                  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:
mappingStatement - String representation of mapping rule
metaToTypeMap - the map between a String representation of an internal types and an internal type
Returns:
the new instance of precompiled mapping rule
Throws:
SqlEngineException - in the case of ANTRL parsing exception

addMapping

void addMapping(SqlMappingItem item)
Adds a new Mapping item, which is a mapping rule for one column.

Parameters:
item - the mapping item

getMappings

java.util.Map<java.lang.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.g
processResult - contains a mapping rule based on SqlStatement.g
Returns:
the crate for output mapping rule and database row identities


Copyright © 2011. All Rights Reserved.