Statistics
| Revision:

svn-gvsig-desktop / branches / F2 / extensions / extJCRS / install / IzPack / src / lib / net / n3 / nanoxml / IXMLBuilder.java @ 20036

History | View | Annotate | Download (6.54 KB)

1
/* IXMLBuilder.java                                                NanoXML/Java
2
 *
3
 * $Revision: 5819 $
4
 * $Date: 2006-06-14 08:29:09 +0100 (miƩ, 14 jun 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

    
32
import java.io.Reader;
33

    
34

    
35
/**
36
 * NanoXML uses IXMLBuilder to construct the XML data structure it retrieved
37
 * from its data source. You can supply your own builder or you can use the
38
 * default builder of NanoXML.
39
 *
40
 * @see net.n3.nanoxml.IXMLParser
41
 *
42
 * @author Marc De Scheemaecker
43
 * @version $Name$, $Revision: 5819 $
44
 */
45
public interface IXMLBuilder
46
{
47

    
48
    /**
49
     * This method is called before the parser starts processing its input.
50
     *
51
     * @param systemID the system ID of the XML data source
52
     * @param lineNr   the line on which the parsing starts
53
     *
54
     * @throws java.lang.Exception
55
     *     If an exception occurred while processing the event.
56
     */
57
    public void startBuilding(String systemID,
58
                              int    lineNr)
59
        throws Exception;
60

    
61

    
62
    /**
63
     * This method is called when a processing instruction is encountered.
64
     * PIs with target "xml" are handled by the parser.
65
     *
66
     * @param target the PI target
67
     * @param reader to read the data from the PI
68
     *
69
     * @throws java.lang.Exception
70
     *     If an exception occurred while processing the event.
71
     */
72
    public void newProcessingInstruction(String target,
73
                                         Reader reader)
74
        throws Exception;
75

    
76

    
77
    /**
78
     * This method is called when a new XML element is encountered.
79
     *
80
     * @see #endElement
81
     *
82
     * @param name       the name of the element
83
     * @param nsPrefix   the prefix used to identify the namespace
84
     * @param nsSystemID the system ID associated with the namespace
85
     * @param systemID   the system ID of the XML data source
86
     * @param lineNr     the line in the source where the element starts
87
     *
88
     * @throws java.lang.Exception
89
     *     If an exception occurred while processing the event.
90
     */
91
    public void startElement(String name,
92
                             String nsPrefix,
93
                             String nsSystemID,
94
                             String systemID,
95
                             int    lineNr)
96
        throws Exception;
97

    
98
    
99
    /**
100
     * This method is called when a new attribute of an XML element is 
101
     * encountered.
102
     *
103
     * @param key        the key (name) of the attribute
104
     * @param nsPrefix   the prefix used to identify the namespace
105
     * @param nsSystemID the system ID associated with the namespace
106
     * @param value      the value of the attribute
107
     * @param type       the type of the attribute ("CDATA" if unknown)
108
     *
109
     * @throws java.lang.Exception
110
     *     If an exception occurred while processing the event.
111
     */
112
    public void addAttribute(String key,
113
                             String nsPrefix,
114
                             String nsSystemID,
115
                             String value,
116
                             String type)
117
        throws Exception;
118
    
119
    
120
    /**
121
     * This method is called when the attributes of an XML element have been
122
     * processed.
123
     *
124
     * @see #startElement
125
     * @see #addAttribute
126
     *
127
     * @param name       the name of the element
128
     * @param nsPrefix   the prefix used to identify the namespace
129
     * @param nsSystemID the system ID associated with the namespace
130
     *
131
     * @throws java.lang.Exception
132
     *     If an exception occurred while processing the event.
133
     */
134
    public void elementAttributesProcessed(String name,
135
                                           String nsPrefix,
136
                                           String nsSystemID)
137
        throws Exception;
138
    
139
    
140
    /**
141
     * This method is called when the end of an XML elemnt is encountered.
142
     *
143
     * @see #startElement
144
     *
145
     * @param name       the name of the element
146
     * @param nsPrefix   the prefix used to identify the namespace
147
     * @param nsSystemID the system ID associated with the namespace
148
     *
149
     * @throws java.lang.Exception
150
     *     If an exception occurred while processing the event.
151
     */
152
    public void endElement(String name,
153
                           String nsPrefix,
154
                           String nsSystemID)
155
        throws Exception;
156
    
157
    
158
    /**
159
     * This method is called when a PCDATA element is encountered. A Java 
160
     * reader is supplied from which you can read the data. The reader will
161
     * only read the data of the element. You don't need to check for
162
     * boundaries. If you don't read the full element, the rest of the data 
163
     * is skipped. You also don't have to care about entities; they are 
164
     * resolved by the parser.
165
     *
166
     * @param reader   the Java reader from which you can retrieve the data
167
     * @param systemID the system ID of the XML data source
168
     * @param lineNr   the line in the source where the element starts
169
     *
170
     * @throws java.lang.Exception
171
     *     If an exception occurred while processing the event.
172
     */
173
    public void addPCData(Reader reader,
174
                          String systemID,
175
                          int    lineNr)
176
        throws Exception;
177
                          
178
    
179
    /**
180
     * Returns the result of the building process. This method is called just
181
     * before the parse() method of IXMLParser returns.
182
     *
183
     * @see net.n3.nanoxml.IXMLParser#parse
184
     *
185
     * @return the result of the building process.
186
     *
187
     * @throws java.lang.Exception
188
     *     If an exception occurred while processing the event.
189
     */
190
    public Object getResult()
191
        throws Exception;
192

    
193
}