KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > n3 > nanoxml > IXMLBuilder


1 /* IXMLBuilder.java NanoXML/Java
2  *
3  * $Revision: 1421 $
4  * $Date: 2006-03-12 17:32:32 +0100 (Sun, 12 Mar 2006) $
5  * $Name$
6  *
7  * This file is part of NanoXML 2 for Java.
8  * Copyright (C) 2001 Marc De Scheemaecker, All Rights Reserved.
9  *
10  * This software is provided 'as-is', without any express or implied warranty.
11  * In no event will the authors be held liable for any damages arising from the
12  * use of this software.
13  *
14  * Permission is granted to anyone to use this software for any purpose,
15  * including commercial applications, and to alter it and redistribute it
16  * freely, subject to the following restrictions:
17  *
18  * 1. The origin of this software must not be misrepresented; you must not
19  * claim that you wrote the original software. If you use this software in
20  * a product, an acknowledgment in the product documentation would be
21  * appreciated but is not required.
22  *
23  * 2. Altered source versions must be plainly marked as such, and must not be
24  * misrepresented as being the original software.
25  *
26  * 3. This notice may not be removed or altered from any source distribution.
27  */

28
29 package net.n3.nanoxml;
30
31 import java.io.Reader JavaDoc;
32
33 /**
34  * NanoXML uses IXMLBuilder to construct the XML data structure it retrieved from its data source.
35  * You can supply your own builder or you can use the default builder of NanoXML.
36  *
37  * @see net.n3.nanoxml.IXMLParser
38  *
39  * @author Marc De Scheemaecker
40  * @version $Name$, $Revision: 1421 $
41  */

42 public interface IXMLBuilder
43 {
44
45     /**
46      * This method is called before the parser starts processing its input.
47      *
48      * @param systemID the system ID of the XML data source
49      * @param lineNr the line on which the parsing starts
50      *
51      * @throws java.lang.Exception If an exception occurred while processing the event.
52      */

53     public void startBuilding(String JavaDoc systemID, int lineNr) throws Exception JavaDoc;
54
55     /**
56      * This method is called when a processing instruction is encountered. PIs with target "xml" are
57      * handled by the parser.
58      *
59      * @param target the PI target
60      * @param reader to read the data from the PI
61      *
62      * @throws java.lang.Exception If an exception occurred while processing the event.
63      */

64     public void newProcessingInstruction(String JavaDoc target, Reader JavaDoc reader) throws Exception JavaDoc;
65
66     /**
67      * This method is called when a new XML element is encountered.
68      *
69      * @see #endElement
70      *
71      * @param name the name of the element
72      * @param nsPrefix the prefix used to identify the namespace
73      * @param nsSystemID the system ID associated with the namespace
74      * @param systemID the system ID of the XML data source
75      * @param lineNr the line in the source where the element starts
76      *
77      * @throws java.lang.Exception If an exception occurred while processing the event.
78      */

79     public void startElement(String JavaDoc name, String JavaDoc nsPrefix, String JavaDoc nsSystemID, String JavaDoc systemID,
80             int lineNr) throws Exception JavaDoc;
81
82     /**
83      * This method is called when a new attribute of an XML element is encountered.
84      *
85      * @param key the key (name) of the attribute
86      * @param nsPrefix the prefix used to identify the namespace
87      * @param nsSystemID the system ID associated with the namespace
88      * @param value the value of the attribute
89      * @param type the type of the attribute ("CDATA" if unknown)
90      *
91      * @throws java.lang.Exception If an exception occurred while processing the event.
92      */

93     public void addAttribute(String JavaDoc key, String JavaDoc nsPrefix, String JavaDoc nsSystemID, String JavaDoc value,
94             String JavaDoc type) throws Exception JavaDoc;
95
96     /**
97      * This method is called when the attributes of an XML element have been processed.
98      *
99      * @see #startElement
100      * @see #addAttribute
101      *
102      * @param name the name of the element
103      * @param nsPrefix the prefix used to identify the namespace
104      * @param nsSystemID the system ID associated with the namespace
105      *
106      * @throws java.lang.Exception If an exception occurred while processing the event.
107      */

108     public void elementAttributesProcessed(String JavaDoc name, String JavaDoc nsPrefix, String JavaDoc nsSystemID)
109             throws Exception JavaDoc;
110
111     /**
112      * This method is called when the end of an XML elemnt is encountered.
113      *
114      * @see #startElement
115      *
116      * @param name the name of the element
117      * @param nsPrefix the prefix used to identify the namespace
118      * @param nsSystemID the system ID associated with the namespace
119      *
120      * @throws java.lang.Exception If an exception occurred while processing the event.
121      */

122     public void endElement(String JavaDoc name, String JavaDoc nsPrefix, String JavaDoc nsSystemID) throws Exception JavaDoc;
123
124     /**
125      * This method is called when a PCDATA element is encountered. A Java reader is supplied from
126      * which you can read the data. The reader will only read the data of the element. You don't
127      * need to check for boundaries. If you don't read the full element, the rest of the data is
128      * skipped. You also don't have to care about entities; they are resolved by the parser.
129      *
130      * @param reader the Java reader from which you can retrieve the data
131      * @param systemID the system ID of the XML data source
132      * @param lineNr the line in the source where the element starts
133      *
134      * @throws java.lang.Exception If an exception occurred while processing the event.
135      */

136     public void addPCData(Reader JavaDoc reader, String JavaDoc systemID, int lineNr) throws Exception JavaDoc;
137
138     /**
139      * Returns the result of the building process. This method is called just before the parse()
140      * method of IXMLParser returns.
141      *
142      * @see net.n3.nanoxml.IXMLParser#parse
143      *
144      * @return the result of the building process.
145      *
146      * @throws java.lang.Exception If an exception occurred while processing the event.
147      */

148     public Object JavaDoc getResult() throws Exception JavaDoc;
149
150 }
151
Popular Tags