velosurf.sql
Class ConfigLoader

java.lang.Object
  extended by velosurf.sql.ConfigLoader

public class ConfigLoader
extends java.lang.Object

A model configuration loader for the Database object.

Author:
Claude Brisson

Field Summary
private static java.util.regex.Pattern attributeResultSyntax
          Syntax checker pattern for the result attribute of <attribute> tags.
private  Database database
          Database.
private  boolean warnedAboutAttributeTagDeprecation
           
private  XIncludeResolver xincludeResolver
          <xi:include> tag resolver.
 
Constructor Summary
ConfigLoader(Database db)
          Constructor.
ConfigLoader(Database db, XIncludeResolver xincludeResolver)
          Constructor.
 
Method Summary
private  java.lang.String adaptCase(java.lang.String str)
          Adapt the case to match chosen database case policy.
private  boolean checkSyntax(java.lang.String paramName, java.lang.String paramValue, java.lang.String[] possibleValues)
          Check the syntax of a parameter in the config file.
private  void defineActions(org.jdom.Element parent, Entity entity)
          Define actions.
private  void defineAttributes(org.jdom.Element parent, Entity entity)
          Define Velosurf attributes.
private  void defineConstraints(org.jdom.Element element, Entity entity)
          Define constraints.
private  void defineEntities(org.jdom.Element database)
          Define entities.
private  void defineForeignKeys(org.jdom.Element parent, Entity entity)
          Define foreign keys.
static boolean isTransaction(org.jdom.Element element)
          Check whether the action defined by this XML tree is a simple action or a transaction.
 void loadConfig(java.io.InputStream config)
          Main method of the ConfigLoader.
private static int parseCaching(java.lang.String caching)
          Parse a caching value.
private  void setDatabaseAttributes(org.jdom.Element database)
          Parses database XML attributes.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

database

private Database database
Database.


xincludeResolver

private XIncludeResolver xincludeResolver
<xi:include> tag resolver.


attributeResultSyntax

private static final java.util.regex.Pattern attributeResultSyntax
Syntax checker pattern for the result attribute of <attribute> tags.


warnedAboutAttributeTagDeprecation

private boolean warnedAboutAttributeTagDeprecation
Constructor Detail

ConfigLoader

public ConfigLoader(Database db)
Constructor.

Parameters:
db - database

ConfigLoader

public ConfigLoader(Database db,
                    XIncludeResolver xincludeResolver)
Constructor.

Parameters:
db - database
xincludeResolver - <xi:include> tag resolver
Method Detail

loadConfig

public void loadConfig(java.io.InputStream config)
                throws java.lang.Exception
Main method of the ConfigLoader.

Parameters:
config - the model configuration input stream
Throws:
java.lang.Exception

adaptCase

private java.lang.String adaptCase(java.lang.String str)
Adapt the case to match chosen database case policy.

Parameters:
str - string to adapt
Returns:
adapted string

setDatabaseAttributes

private void setDatabaseAttributes(org.jdom.Element database)
Parses database XML attributes.

Parameters:
database - parent element

defineAttributes

private void defineAttributes(org.jdom.Element parent,
                              Entity entity)
                       throws java.sql.SQLException
Define Velosurf attributes.

Parameters:
parent - parent XML element
entity - parent entity
Throws:
java.sql.SQLException

defineForeignKeys

private void defineForeignKeys(org.jdom.Element parent,
                               Entity entity)
Define foreign keys.

Parameters:
parent - parent XML element
entity - parent entity

defineActions

private void defineActions(org.jdom.Element parent,
                           Entity entity)
Define actions.

Parameters:
parent - parent XML element
entity - parent entity

defineEntities

private void defineEntities(org.jdom.Element database)
                     throws java.lang.Exception
Define entities.

Parameters:
database - database XML element
Throws:
java.lang.Exception

defineConstraints

private void defineConstraints(org.jdom.Element element,
                               Entity entity)
                        throws java.lang.Exception
Define constraints.

Parameters:
element - parent XML element
entity - parent entity
Throws:
java.lang.Exception

checkSyntax

private boolean checkSyntax(java.lang.String paramName,
                            java.lang.String paramValue,
                            java.lang.String[] possibleValues)
Check the syntax of a parameter in the config file.

Parameters:
paramName - name of the parameter
paramValue - value of the parameter
possibleValues - possible values for the parameter
Returns:
whether the syntax is correct

parseCaching

private static int parseCaching(java.lang.String caching)
Parse a caching value.

Parameters:
caching - string describing the type of caching
Returns:
type of caching

isTransaction

public static boolean isTransaction(org.jdom.Element element)
Check whether the action defined by this XML tree is a simple action or a transaction.

Parameters:
element - XML tree defining an action
Returns:
true if the action is a transaction


~ooOoo~