KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jorm > xml2mi > api > Parser


1 /**
2  * JORM: an implementation of a generic mapping system for persistent Java
3  * objects. Two mapping are supported: to RDBMS and to binary files.
4  * Copyright (C) 2001-2003 France Telecom R&D - INRIA
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  * Contact: jorm-team@objectweb.org
21  *
22  */

23
24 package org.objectweb.jorm.xml2mi.api;
25
26 import org.objectweb.jorm.metainfo.api.Manager;
27 import org.objectweb.jorm.metainfo.api.MetaObject;
28 import org.objectweb.jorm.metainfo.api.ClassProject;
29 import org.objectweb.jorm.util.io.api.PathExplorer;
30 import org.objectweb.jorm.api.PException;
31 import org.w3c.dom.Element JavaDoc;
32
33 import java.util.Iterator JavaDoc;
34 import java.util.Collection JavaDoc;
35 import java.util.ArrayList JavaDoc;
36
37
38 /**
39  * The Parser interface defines the behaviour of a JORM component used to
40  * parse a set of JORM definition files.
41  * A parser is able to parse XML files (these files may be passed by the pmc
42  * command line), and build a schema of meta-objects, using a meta-information
43  * manager component.
44  * @author P. Dechamboux, X. Spengler
45  */

46 public interface Parser {
47     /**
48      * Launches the parsing process. It reads and parses all the XML files
49      * and builds a schema of meta-objects for all of them.
50      * Before to use this method, the following object need to be set : Manager
51      * (with setMetaInfoManager), the PathExplorer (with setPathExplorer), the
52      * mapper name (with setMapperName), the mapping parser object (with setMappingParser).
53      * @param files an iterator over the name the XML files to be parsed
54      */

55     Collection JavaDoc parse(Iterator JavaDoc files) throws PException;
56
57     /**
58      * Launches the parsing process.
59      * It reads and parse an XML file and builds a schema of meta-objects
60      * for it.
61      * Before to use this method, the following object need to be set : Manager
62      * (with setMetaInfoManager), the PathExplorer (with setPathExplorer), the
63      * mapper name (with setMapperName), the mapping parser object (with setMappingParser).
64      * @param file the name of the XML file to be parsed
65      */

66     MetaObject parse(String JavaDoc file) throws PException;
67
68
69     void parseMapping(Element JavaDoc mappingElem, ClassProject classProject) throws PException;
70
71     /**
72      * Assigns a meta-information manager to a parser in order from it to
73      * create the meta-information related to the XML files it parses.
74      * @param mim the meta-information Manager to be associated to this parser
75      */

76     void setMetaInfoManager(Manager mim);
77
78     /**
79      * Assigns a PathExplorer object for locating files that have to be parsed.
80      * @param pathexpl the PathExplorer to be used for file location
81      */

82     void setPathExplorer(PathExplorer pathexpl);
83
84     /**
85      * Sets the parser which is able to parse the mapping part of the XML file.
86      * @param mappername the name of the mapper
87      * @param mappingParser the parser which parses the mapping object
88      */

89     void addMappingParser(String JavaDoc mappername,
90                           MappingParser mappingParser) throws PException;
91
92     /**
93      * Returns a MappingParser object.
94      * @param mapperName a mapper name,
95      * @return a MappingParser object.
96      */

97     public MappingParser getMappingParser(String JavaDoc mapperName);
98
99     /**
100      * Initializes the Parser. In order to compile XML files.
101      * @param dtdVerify true, the dtd must be used to validate xml files, else
102      * false
103      * @param dtds A list of usefull DTD.
104      */

105     void init(boolean dtdVerify, ArrayList JavaDoc dtds);
106
107     /**
108      * Returns the exception which is reached during the parsing of a file.
109      * @return an Exception object
110      */

111     Exception JavaDoc getParserException();
112 }
113
Popular Tags