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(boolean dtdVerify, java.util.ArrayList dtds)
          Main constructor for BasicDomParser.
 
Method Summary
 org.objectweb.util.monolog.api.Logger getLogger()
          Returns a logger to an component that wants to log things.
 org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
          Returns a logger factory that allows the creation of new loggers.
 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
 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 setGenDep(boolean gendep)
          Enables or disables the generation of the dependances.
 void setLogger(org.objectweb.util.monolog.api.Logger logger)
          Defines a logger object.
 void setLoggerFactory(org.objectweb.util.monolog.api.LoggerFactory loggerfactory)
          Defines the logger factory to obtain new loggers.
 void setMapperName(java.lang.String mapperName)
          Sets the name of the mapper to use.
 void setMappingName(java.lang.String mappingName)
          Sets the name of the mapping to use.
 void setMappingParser(MappingParser mappingParser)
          Sets the parser which is able to parse the mapping part of the XML file.
 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(org.objectweb.util.io.api.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(boolean dtdVerify,
                      java.util.ArrayList dtds)
Main constructor for BasicDomParser. In order to compile XML files, it creates a DOMParser and initialzes it.
Parameters:
dtdVerify - true, the dtd must be used to validate xml files, else false
Method Detail

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 name (with setMappingName), 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

parse

public MetaObject parse(java.lang.String file)
                 throws PException
Launches the parsing process. It reads and parse 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 name (with setMappingName), the mapping parser object (with setMappingParser).
Specified by:
parse in interface Parser
Parameters:
file - the name of the XML file to be parsed

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(org.objectweb.util.io.api.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

setMapperName

public void setMapperName(java.lang.String mapperName)
Sets the name of the mapper to use. This name is passed on the command line or defined in a properties file.
Specified by:
setMapperName in interface Parser
Parameters:
mapperName - the name of the mapper

setMappingName

public void setMappingName(java.lang.String mappingName)
Sets the name of the mapping to use. This name is passed on the command line or defined in a properties file.
Specified by:
setMappingName in interface Parser
Parameters:
mappingName - the name of the mapping

setMappingParser

public void setMappingParser(MappingParser mappingParser)
Sets the parser which is able to parse the mapping part of the XML file.
Specified by:
setMappingParser in interface Parser
Parameters:
mappingParser - the parser which parses the mapping object

setGenDep

public void setGenDep(boolean gendep)
Enables or disables the generation of the dependances.
Specified by:
setGenDep in interface Parser
Parameters:
gendep - true, the dependances are generated, else false

isGenDep

public boolean isGenDep()
Allows to know if the dependances must be generated or not.
Specified by:
isGenDep in interface Parser
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

setLogger

public void setLogger(org.objectweb.util.monolog.api.Logger logger)
Defines a logger object.
Specified by:
setLogger in interface Loggable
Parameters:
logger - the logger object

setLoggerFactory

public void setLoggerFactory(org.objectweb.util.monolog.api.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 org.objectweb.util.monolog.api.Logger getLogger()
Description copied from interface: Loggable
Returns a logger to an component that wants to log things.
Specified by:
getLogger in interface Loggable
Following copied from interface: org.objectweb.jorm.util.api.Loggable
Parameters:
logger - the logger object

getLoggerFactory

public org.objectweb.util.monolog.api.LoggerFactory getLoggerFactory()
Description copied from interface: Loggable
Returns a logger factory that allows the creation of new loggers.
Specified by:
getLoggerFactory in interface Loggable
Following copied from interface: org.objectweb.jorm.util.api.Loggable
Parameters:
loggerfactory - the LoggerFactory object to obtain new loggers