org.objectweb.jorm.xml2mi.lib
Class BasicDomParser

java.lang.Object
  |
  +--org.objectweb.jorm.xml2mi.lib.BasicDomParser
All Implemented Interfaces:
Loggable, Parser

public class BasicDomParser
extends java.lang.Object
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

Constructor Summary
BasicDomParser()
           
 
Method Summary
 void addMappingParser(java.lang.String mapperName, MappingParser mappingParser)
          Adds a MappingParser object.
 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.
 MappingParser getMappingParser(java.lang.String mapperName)
          Returns a MappingParser object.
 ParserErrorHandler getParserErrorHandler()
          allows to know the list of error the parser encounters.
 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 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 setPathExplorer(PathExplorer pathexpl)
          Assigns a PathExplorer object for locating files that have to be parsed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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
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
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
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

getParserErrorHandler

public ParserErrorHandler getParserErrorHandler()
allows to know the list of error the parser encounters.

Specified by:
getParserErrorHandler in interface Parser
Returns:
a ParserErrorHandler object which countains all errors from the xml parser

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
PException

setLogger

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

Specified by:
setLogger in interface Loggable
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
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

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