org.objectweb.jorm.xml2mi.api

Interface Parser

public interface Parser

The Parser interface defines the behaviour of a JORM component used to parse a set of JORM definition files. A parser is able to parse XML files (these files may be passed by the pmc command line), and build a schema of meta-objects, using a meta-information manager component.

Author:
P. Dechamboux, X. Spengler

Method Summary

void
addMappingParser(String mappername, MappingParser mappingParser)
Sets the parser which is able to parse the mapping part of the XML file.
MappingParser
getMappingParser(String mapperName)
Returns a MappingParser object.
ParserErrorHandler
getParserErrorHandler()
Allows to know the list of error the parser encounters.
Exception
getParserException()
Returns the exception which is reached during the parsing of a file.
void
init(boolean dtdVerify, ArrayList dtds)
Initializes the Parser.
Collection
parse(Iterator files)
Launches the parsing process.
MetaObject
parse(String file)
Launches the parsing process.
void
parseMapping(Element mappingElem, ClassProject classProject)
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.jorm.util.io.api.PathExplorer pathexpl)
Assigns a PathExplorer object for locating files that have to be parsed.

Method Details

addMappingParser

public void addMappingParser(String mappername,
                             MappingParser mappingParser)
            throws PException
Sets the parser which is able to parse the mapping part of the XML file.

Parameters:
mappername - the name of the mapper
mappingParser - the parser which parses the mapping object


getMappingParser

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

Parameters:
mapperName - a mapper name,

Returns:
a MappingParser object.


getParserErrorHandler

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

Returns:
a ParserErrorHandler object which countains all errors from the xml parser


getParserException

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

Returns:
an Exception object


init

public void init(boolean dtdVerify,
                 ArrayList dtds)
Initializes the Parser. In order to compile XML files.

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


parse

public Collection parse(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).

Parameters:
files - an iterator over the name the XML files to be parsed


parse

public MetaObject parse(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 parser object (with setMappingParser).

Parameters:
file - the name of the XML file to be parsed


parseMapping

public void parseMapping(Element mappingElem,
                         ClassProject classProject)
            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.

Parameters:
mim - the meta-information Manager to be associated to this parser


setPathExplorer

public void setPathExplorer(org.objectweb.jorm.util.io.api.PathExplorer pathexpl)
Assigns a PathExplorer object for locating files that have to be parsed.

Parameters:
pathexpl - the PathExplorer to be used for file location