org.objectweb.jorm.xml2mi.lib
Class BasicDomParser

java.lang.Object
  extended byorg.objectweb.jorm.xml2mi.lib.ParserHelper
      extended byorg.objectweb.jorm.xml2mi.lib.BasicDomParser
All Implemented Interfaces:
Loggable, Parser

public class BasicDomParser
extends ParserHelper
implements Parser, Loggable

The BasicDomParser class implements the Parser interface. It uses the DOM trees associated to the XML files that are parsed in order to build the meta-objects.

Author:
P. Dechamboux, X. Spengler

Field Summary
 
Fields inherited from class org.objectweb.jorm.xml2mi.lib.ParserHelper
logger, loggerFactory, motable
 
Constructor Summary
BasicDomParser()
           
 
Method Summary
 void addMappingParser(java.lang.String mapperName, MappingParser mappingParser)
          Adds a MappingParser object.
 MappingParser getMappingParser(java.lang.String mapperName)
          Returns a MappingParser object.
 java.lang.Exception getParserException()
          returns the exception which is reached during the parsing of a file
 void init(boolean dtdVerify, java.util.ArrayList dtds)
          Main constructor for BasicDomParser.
 boolean isGenDep()
          Allows to know if the dependances must be generated or not.
 java.util.Collection parse(java.util.Iterator files)
          Launches the parsing process.
 MetaObject parse(java.lang.String file)
          Launches the parsing process.
 void parseMapping(org.w3c.dom.Element mappingElem, ClassProject classProject)
          Parses the mapping part of the XML file and builds the corresponding meta-information for a given Class object.
 void setGenDep(boolean gendep)
          Enables or disables the generation of the dependances.
 void setLogger(Logger logger)
          Defines a logger object.
 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 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, getLogger, getLoggerFactory, setLoggerFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jorm.util.api.Loggable
getLogger, getLoggerFactory, setLoggerFactory
 

Constructor Detail

BasicDomParser

public BasicDomParser()
Method Detail

init

public void init(boolean dtdVerify,
                 java.util.ArrayList dtds)
Main constructor for BasicDomParser. In order to compile XML files, it creates a DOMParser and initialzes it.

Specified by:
init in interface Parser
Parameters:
dtdVerify - true, the dtd must be used to validate xml files, else false
dtds - A list of usefull DTD.

addMappingParser

public void addMappingParser(java.lang.String mapperName,
                             MappingParser mappingParser)
                      throws PException
Adds a MappingParser object.

Specified by:
addMappingParser in interface Parser
Parameters:
mapperName - a mapper name, mappingParser a MappingParser object.
mappingParser - the parser which parses the mapping object
Throws:
PException

getMappingParser

public MappingParser getMappingParser(java.lang.String mapperName)
Returns a MappingParser object.

Specified by:
getMappingParser in interface Parser
Parameters:
mapperName - a mapper name,
Returns:
a MappingParser object.

parse

public java.util.Collection parse(java.util.Iterator files)
                           throws PException
Launches the parsing process. It reads and parses all the XML files and builds a schema of meta-objects for all of them. Before to use this method, the following object need to be set : Manager (with setMetaInfoManager), the PathExplorer (with setPathExplorer), the mapper name (with setMapperName), the mapping parser object (with setMappingParser).

Specified by:
parse in interface Parser
Parameters:
files - an iterator over the name the XML files to be parsed
Throws:
PException

parse

public MetaObject parse(java.lang.String file)
                 throws PException
Launches the parsing process. It reads and parses an XML file and builds a schema of meta-objects for it. Before to use this method, the following object need to be set : Manager (with setMetaInfoManager), the PathExplorer (with setPathExplorer), the mapper name (with setMapperName), the mapping parser object (with setMappingParser).

Specified by:
parse in interface Parser
Parameters:
file - the name of the XML file to be parsed
Throws:
PException

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 Parser
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 Parser
Parameters:
pathexpl - the PathExplorer to be used for file location

setGenDep

public void setGenDep(boolean gendep)
Enables or disables the generation of the dependances.

Parameters:
gendep - true, the dependances are generated, else false

isGenDep

public boolean isGenDep()
Allows to know if the dependances must be generated or not.

Returns:
true, if the dependances are generated, else false

getParserException

public java.lang.Exception getParserException()
returns the exception which is reached during the parsing of a file

Specified by:
getParserException in interface Parser
Returns:
an Exception object

parseMapping

public void parseMapping(org.w3c.dom.Element mappingElem,
                         ClassProject classProject)
                  throws PException
Parses the mapping part of the XML file and builds the corresponding meta-information for a given Class object. Manager, PathExplorer, MapperName and MappingName must be set before the call of this method.

Specified by:
parseMapping in interface Parser
Parameters:
mappingElem - the node to treat
Throws:
PException

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