org.objectweb.jorm.xml2mi.lib
Class BasicMappingParser

java.lang.Object
  extended byorg.objectweb.jorm.xml2mi.lib.ParserHelper
      extended byorg.objectweb.jorm.xml2mi.lib.BasicMappingParser
All Implemented Interfaces:
Loggable, MappingParser
Direct Known Subclasses:
FosParser, MemParser, RdbParser

public abstract class BasicMappingParser
extends ParserHelper
implements MappingParser

ProxyParser is an implementation of the Parser interface. This object defines a parser which is able to dispatch operation to specific mapping parser, and able to build the corresponding meta information.

Author:
X. Spengler

Field Summary
protected  Class currentClass
          The current Class object.
protected  java.util.Map idvalue2genclassref
          A Map of String objects.
protected  Manager metaInfoManager
          The meta information manager for managing meta-objects within the context of a mapper.
protected  PathExplorer pathExplorer
          pathExplorer is able to return input or output stream from a given file.
 
Fields inherited from class org.objectweb.jorm.xml2mi.lib.ParserHelper
logger, loggerFactory, motable
 
Constructor Summary
BasicMappingParser()
           
 
Method Summary
protected  NameDef getClassRefNameDef(Class clazz, java.lang.String fieldName, java.lang.String name)
          Seeks for a ClassRef object given a class, a field name.
protected  java.lang.String getFieldName(org.w3c.dom.Element nameDef)
          Seeks for a father node of type field from a name-def node and returns the corresponding field name.
protected  int getGenClassNestingLevel(org.w3c.dom.Element fromElem, java.lang.String fieldName)
          Seeks for a father node of type field from a gen-class element or a name-def element.
protected  GenClassRef getGenClassRef(Class clazz, java.lang.String fieldName, int nestingLevel)
          Seeks for a GenClassRef object given a class, a field name and a nesting level.
protected  NameDef getGenClassRefNameDef(Class clazz, java.lang.String fieldName, java.lang.String name, int nestingLevel)
          Seeks for a GenClassRef object given a class, a field name and a nesting level.
 Logger getLogger()
          Returns a logger to an component that wants to log things.
 LoggerFactory getLoggerFactory()
          Returns a logger factory that allows the creation of new loggers.
protected  NameDef getNameDefFromSuper(java.lang.String linkend)
          Returns a NameDef object given the full qualified class name of an inherited class and possibly a NameDef name.
protected  PrimitiveElement getPrimitiveElement(java.lang.String linkend)
           
protected  NameDef getRefNameDef(java.lang.String linkend, java.lang.String tagName)
          Returns a NameDef object given a NameDef name (name), a field or a scalarfield name (fn) and possibly the full qualified class name where it is defined.
abstract  void parseMapping(org.w3c.dom.Element mappingElem, Mapping mapping)
          Parses the mapping information related to a particular mapper and builds the corresponding Jorm meta-information.
 void setCurrentClass(Class currentClass)
          Assigns the current Class object to a parser in order from it to retrieve the meta-objects (for example, PrimitiveElement objects) that are referenced from XML mapping elements.
 void setidvalue2genclassref(java.util.Map idvalue2genclassref)
          Assigns an HashTable object to the MappingParser object.
 void setLogger(Logger logger)
          Defines a logger object.
 void setLoggerFactory(LoggerFactory loggerfactory)
          Defines the logger factory to obtain new loggers.
 void setMetaInfoManager(Manager mim)
          Assigns a meta-information manager to a parser in order from it to create the meta-information related to the XML files it parses.
 void setmotable(java.util.Hashtable motable)
          Assigns an HashTable object to the MappingParser object.
 void setPathExplorer(PathExplorer pathExpl)
          Assigns a PathExplorer object for locating files that have to be parsed.
 
Methods inherited from class org.objectweb.jorm.xml2mi.lib.ParserHelper
getIdNameDef, getIdNameDef
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaInfoManager

protected Manager metaInfoManager
The meta information manager for managing meta-objects within the context of a mapper.


currentClass

protected Class currentClass
The current Class object.


pathExplorer

protected PathExplorer pathExplorer
pathExplorer is able to return input or output stream from a given file.


idvalue2genclassref

protected java.util.Map idvalue2genclassref
A Map of String objects. key = a String object that represents an id value. value = the associated GenClassRef object.

Constructor Detail

BasicMappingParser

public BasicMappingParser()
Method Detail

setMetaInfoManager

public void setMetaInfoManager(Manager mim)
Assigns a meta-information manager to a parser in order from it to create the meta-information related to the XML files it parses.

Specified by:
setMetaInfoManager in interface MappingParser
Parameters:
mim - the meta-information Manager to be associated to this parser

setPathExplorer

public void setPathExplorer(PathExplorer pathExpl)
Assigns a PathExplorer object for locating files that have to be parsed.

Specified by:
setPathExplorer in interface MappingParser
Parameters:
pathExpl - The PathExplorer to be used for file location

setCurrentClass

public void setCurrentClass(Class currentClass)
Assigns the current Class object to a parser in order from it to retrieve the meta-objects (for example, PrimitiveElement objects) that are referenced from XML mapping elements.

Specified by:
setCurrentClass in interface MappingParser
Parameters:
currentClass - the Jorm meta-object associated to the parsed class.

getRefNameDef

protected NameDef getRefNameDef(java.lang.String linkend,
                                java.lang.String tagName)
Returns a NameDef object given a NameDef name (name), a field or a scalarfield name (fn) and possibly the full qualified class name where it is defined. This NameDef object is referenced from a ReferenceMapping object. First seeks for a TypedElement object given a field or a scalarfield name and possibly the full qualified class name (fqcn) where it is defined.

Parameters:
linkend - a String object whose structure is defined as follows: /fqcn/fn/name or fn/name, tagName a String object whose value matches "rdb-class-ref-mapping" or "rdb-gen-class-ref-mapping".
Returns:
a NameDef object.

getNameDefFromSuper

protected NameDef getNameDefFromSuper(java.lang.String linkend)
Returns a NameDef object given the full qualified class name of an inherited class and possibly a NameDef name.

Parameters:
linkend - a String object whose structure is defined as follows: /fqcn or /fqcn/name,
Returns:
a NameDef object.

getPrimitiveElement

protected PrimitiveElement getPrimitiveElement(java.lang.String linkend)

getFieldName

protected java.lang.String getFieldName(org.w3c.dom.Element nameDef)
Seeks for a father node of type field from a name-def node and returns the corresponding field name.

Parameters:
nameDef - the name-def element.
Returns:
a field name.

getClassRefNameDef

protected NameDef getClassRefNameDef(Class clazz,
                                     java.lang.String fieldName,
                                     java.lang.String name)
Seeks for a ClassRef object given a class, a field name. This method returns the NameDef object of the ClassRef object.

Returns:
the NameDef object of the ClassRef object.

getGenClassNestingLevel

protected int getGenClassNestingLevel(org.w3c.dom.Element fromElem,
                                      java.lang.String fieldName)
Seeks for a father node of type field from a gen-class element or a name-def element. The name-def element represents the pname of a reference to a generic class. This method returns the nesting level of the generic class as well as the corresponding field name.

Returns:
the nesting level of a gen-class element.

getGenClassRefNameDef

protected NameDef getGenClassRefNameDef(Class clazz,
                                        java.lang.String fieldName,
                                        java.lang.String name,
                                        int nestingLevel)
Seeks for a GenClassRef object given a class, a field name and a nesting level. This method returns the NameDef object of the GenClassRef object.

Returns:
the NameDef object of the GenClassRef object.

getGenClassRef

protected GenClassRef getGenClassRef(Class clazz,
                                     java.lang.String fieldName,
                                     int nestingLevel)
Seeks for a GenClassRef object given a class, a field name and a nesting level. This method returns the NameDef object of the GenClassRef object.

Returns:
the NameDef object of the GenClassRef object.

parseMapping

public abstract void parseMapping(org.w3c.dom.Element mappingElem,
                                  Mapping mapping)
                           throws PException
Parses the mapping information related to a particular mapper and builds the corresponding Jorm meta-information. It can be class-related or generic class-related information. Manager, PathExplorer and currentClass must be set before calling this method.

Specified by:
parseMapping in interface MappingParser
Parameters:
mappingElem - the current XML node.
mapping - a Mapping object.
Throws:
PException

setidvalue2genclassref

public void setidvalue2genclassref(java.util.Map idvalue2genclassref)
Assigns an HashTable object to the MappingParser object.

Specified by:
setidvalue2genclassref in interface MappingParser
Parameters:
idvalue2genclassref - an HashTable that associates an id value with a GenClassRef object.

setmotable

public void setmotable(java.util.Hashtable motable)
Assigns an HashTable object to the MappingParser object.

Specified by:
setmotable in interface MappingParser
Parameters:
motable - an HashTable that associates a pd file to its corresponding MetaObject.

setLogger

public void setLogger(Logger logger)
Defines a logger object.

Specified by:
setLogger in interface Loggable
Overrides:
setLogger in class ParserHelper
Parameters:
logger - the logger object

setLoggerFactory

public void setLoggerFactory(LoggerFactory loggerfactory)
Defines the logger factory to obtain new loggers.

Specified by:
setLoggerFactory in interface Loggable
Overrides:
setLoggerFactory in class ParserHelper
Parameters:
loggerfactory - The LoggerFactory object to obtain a logger object

getLogger

public Logger getLogger()
Description copied from interface: Loggable
Returns a logger to an component that wants to log things.

Specified by:
getLogger in interface Loggable
Overrides:
getLogger in class ParserHelper

getLoggerFactory

public LoggerFactory getLoggerFactory()
Description copied from interface: Loggable
Returns a logger factory that allows the creation of new loggers.

Specified by:
getLoggerFactory in interface Loggable
Overrides:
getLoggerFactory in class ParserHelper