author | mkos |
Sun, 30 Dec 2012 00:00:00 +0100 | |
changeset 22678 | ac1ea46be942 |
parent 12009 | 4abb694f273a |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
22678
ac1ea46be942
8029237: Update copyright year to match last edit in jaxws repository for 2012
mkos
parents:
12009
diff
changeset
|
2 |
* Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
* |
|
25 |
* THIS FILE WAS MODIFIED BY SUN MICROSYSTEMS, INC. |
|
26 |
*/ |
|
27 |
||
28 |
package com.sun.xml.internal.org.jvnet.fastinfoset.sax; |
|
29 |
||
30 |
import java.io.IOException; |
|
31 |
import java.io.InputStream; |
|
32 |
import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetException; |
|
33 |
import com.sun.xml.internal.org.jvnet.fastinfoset.FastInfosetParser; |
|
34 |
import org.xml.sax.SAXException; |
|
35 |
import org.xml.sax.XMLReader; |
|
36 |
import org.xml.sax.ext.DeclHandler; |
|
37 |
import org.xml.sax.ext.LexicalHandler; |
|
38 |
||
39 |
/** |
|
40 |
* Interface for reading an Fast Infoset document using callbacks. |
|
41 |
* |
|
42 |
* <p>FastInfosetReader is the interface that a Fast Infoset parser's |
|
43 |
* SAX2 driver must implement. This interface allows an application to |
|
44 |
* to register Fast Infoset specific event handlers for encoding algorithms.</p> |
|
45 |
* |
|
46 |
* <p>The reception of encoding algorithm events is determined by |
|
47 |
* the registration of: |
|
48 |
* <ul> |
|
49 |
* <li>A {@link PrimitiveTypeContentHandler}, for the recieving of events, |
|
50 |
* associated with built-in encoding algorithms, for decoded data that |
|
51 |
* can be reported as Java primitive types.</li> |
|
52 |
* <li>A {@link EncodingAlgorithmContentHandler}, for the recieving of events, |
|
53 |
* associated with built-in and application-defined encoding algorithms, for |
|
54 |
* decoded data that can be reported as an array of octets or as a Java |
|
55 |
* Object.</li> |
|
56 |
* <li>{@link com.sun.xml.internal.org.jvnet.fastinfoset.EncodingAlgorithm} implementations, for |
|
57 |
* the receiving of events, associated with application defined algorithms. |
|
58 |
* for decoded data that shall be reported as a Java Object by way of the |
|
59 |
* registered EncodingAlgorithmContentHandler.</li> |
|
60 |
* </ul> |
|
61 |
* </p> |
|
62 |
* |
|
63 |
* <p>The reporting of element content events for built-in algorithms |
|
64 |
* is determimed by the following: |
|
65 |
* <ul> |
|
66 |
* <li>If a PrimitiveContentHandler is registered then decoded data is reported |
|
67 |
* as Java primitive types using the corresponding methods on the PrimitiveContentHandler |
|
68 |
* interface.</li> |
|
69 |
* <li>If a PrimitiveContentHandler is not registered and a |
|
70 |
* EncodingAlgorithmContentHandler is registered then decoded data is reported |
|
71 |
* as Java Objects using {@link EncodingAlgorithmContentHandler#object(String, int, Object)}. |
|
72 |
* An Object shall correspond to the Java primitive type that |
|
73 |
* would otherwise be reported using the PrimitiveContentHandler.</li> |
|
74 |
* <li>If neither is registered then then decoded data is reported as characters.</li> |
|
75 |
* </ul> |
|
76 |
* </p> |
|
77 |
* |
|
78 |
* <p>The reporting of element content events for application-defined algorithms |
|
79 |
* is determimed by the following: |
|
80 |
* <ul> |
|
81 |
* <li>If an EncodingAlgorithmContentHandler is registered and there is no |
|
82 |
* EncodingAlgorithm registered for an application-defined encoding algorithm |
|
83 |
* then decoded data for such an algoroithm is reported as an array of octets |
|
84 |
* using {@link EncodingAlgorithmContentHandler#octets(String, int, byte[], int, int)}; |
|
85 |
* otherwise</li> |
|
86 |
* <li>If there is an EncodingAlgorithm registered for the application-defined |
|
87 |
* encoding algorithm then the decoded data is reported as a Java Object, |
|
88 |
* returned by decoding according to the EncodingAlgorithm, using |
|
89 |
* {@link EncodingAlgorithmContentHandler#object(String, int, Object)}.</li> |
|
90 |
* </ul> |
|
91 |
* </p> |
|
92 |
* |
|
93 |
* <p>The reporting of attribute values for encoding algorithms is achieved using |
|
94 |
* {@link EncodingAlgorithmAttributes} that extends {@link org.xml.sax.Attributes}. |
|
95 |
* The registered ContentHandler may cast the attr paramter of the |
|
96 |
* {@link org.xml.sax.ContentHandler#startElement(String, String, String, org.xml.sax.Attributes)} |
|
97 |
* to the EncodingAlgorithmAttributes interface to access to encoding algorithm information. |
|
98 |
* </p> |
|
99 |
* |
|
100 |
* <p>The reporting of attribute values for built-in algorithms |
|
101 |
* is determimed by the following: |
|
102 |
* <ul> |
|
103 |
* <li>If a PrimitiveContentHandler or EncodingAlgorithmContentHandler is |
|
104 |
* registered then decoded data is reported as Java Objects corresponding |
|
105 |
* to the Java primitive types. The Java Objects may be obtained using |
|
106 |
* {@link EncodingAlgorithmAttributes#getAlgorithmData(int)}. |
|
107 |
* <li>If neither is registered then then decoded data is reported as characters.</li> |
|
108 |
* </ul> |
|
109 |
* </p> |
|
110 |
* |
|
111 |
* <p>The reporting of attribute values for application-defined algorithms |
|
112 |
* is determimed by the following: |
|
113 |
* <ul> |
|
114 |
* <li>If an EncodingAlgorithmContentHandler is registered and there is no |
|
115 |
* EncodingAlgorithm registered for an application-defined encoding algorithm |
|
116 |
* then decoded data for such an algoroithm is reported as Java Object, |
|
117 |
* that is an instance of <code>byte[]</code>, |
|
118 |
* using {@link EncodingAlgorithmAttributes#getAlgorithmData(int)}; |
|
119 |
* otherwise</li> |
|
120 |
* <li>If there is an EncodingAlgorithm registered for the application-defined |
|
121 |
* encoding algorithm then the decoded data is reported as a Java Object, |
|
122 |
* returned by decoding according to the EncodingAlgorithm, using |
|
123 |
* {@link EncodingAlgorithmAttributes#getAlgorithmData(int)}.</li> |
|
124 |
* </ul> |
|
125 |
* </p> |
|
126 |
* |
|
127 |
* @see com.sun.xml.internal.org.jvnet.fastinfoset.sax.PrimitiveTypeContentHandler |
|
128 |
* @see com.sun.xml.internal.org.jvnet.fastinfoset.sax.EncodingAlgorithmContentHandler |
|
129 |
* @see org.xml.sax.XMLReader |
|
130 |
* @see org.xml.sax.ContentHandler |
|
131 |
*/ |
|
132 |
public interface FastInfosetReader extends XMLReader, FastInfosetParser { |
|
133 |
/** |
|
134 |
* The property name to be used for getting and setting the |
|
135 |
* EncodingAlgorithmContentHandler. |
|
136 |
* |
|
137 |
*/ |
|
138 |
public static final String ENCODING_ALGORITHM_CONTENT_HANDLER_PROPERTY = |
|
139 |
"http://jvnet.org/fastinfoset/sax/properties/encoding-algorithm-content-handler"; |
|
140 |
||
141 |
/** |
|
142 |
* The property name to be used for getting and setting the |
|
143 |
* PrimtiveTypeContentHandler. |
|
144 |
* |
|
145 |
*/ |
|
146 |
public static final String PRIMITIVE_TYPE_CONTENT_HANDLER_PROPERTY = |
|
147 |
"http://jvnet.org/fastinfoset/sax/properties/primitive-type-content-handler"; |
|
148 |
||
149 |
/** |
|
150 |
* Parse a fast infoset document from an InputStream. |
|
151 |
* |
|
152 |
* <p>The application can use this method to instruct the Fast Infoset |
|
153 |
* reader to begin parsing a fast infoset document from a byte stream.</p> |
|
154 |
* |
|
155 |
* <p>Applications may not invoke this method while a parse is in progress |
|
156 |
* (they should create a new XMLReader instead for each nested XML document). |
|
157 |
* Once a parse is complete, an application may reuse the same |
|
158 |
* FastInfosetReader object, possibly with a different byte stream.</p> |
|
159 |
* |
|
160 |
* <p>During the parse, the FastInfosetReader will provide information about |
|
161 |
* the fast infoset document through the registered event handlers.<p> |
|
162 |
* |
|
163 |
* <p> This method is synchronous: it will not return until parsing has ended. |
|
164 |
* If a client application wants to terminate parsing early, it should throw |
|
165 |
* an exception.<p> |
|
166 |
* |
|
167 |
* @param s The byte stream to parse from. |
|
168 |
*/ |
|
169 |
public void parse(InputStream s) throws IOException, FastInfosetException, SAXException; |
|
170 |
||
171 |
/** |
|
172 |
* Allow an application to register a lexical handler. |
|
173 |
* |
|
174 |
* <p>Applications may register a new or different handler in the |
|
175 |
* middle of a parse, and the SAX parser must begin using the new |
|
176 |
* handler immediately.</p> |
|
177 |
* |
|
178 |
* @param handler The lexical handler. |
|
179 |
* @see #getLexicalHandler |
|
180 |
*/ |
|
181 |
public void setLexicalHandler(LexicalHandler handler); |
|
182 |
||
183 |
/** |
|
184 |
* Return the current lexical handler. |
|
185 |
* |
|
186 |
* @return The current lexical handler, or null if none |
|
187 |
* has been registered. |
|
188 |
* @see #setLexicalHandler |
|
189 |
*/ |
|
190 |
public LexicalHandler getLexicalHandler(); |
|
191 |
||
192 |
/** |
|
193 |
* Allow an application to register a DTD declaration handler. |
|
194 |
* |
|
195 |
* <p>Applications may register a new or different handler in the |
|
196 |
* middle of a parse, and the SAX parser must begin using the new |
|
197 |
* handler immediately.</p> |
|
198 |
* |
|
199 |
* @param handler The DTD declaration handler. |
|
200 |
* @see #getLexicalHandler |
|
201 |
*/ |
|
202 |
public void setDeclHandler(DeclHandler handler); |
|
203 |
||
204 |
/** |
|
205 |
* Return the current DTD declaration handler. |
|
206 |
* |
|
207 |
* @return The current DTD declaration handler, or null if none |
|
208 |
* has been registered. |
|
209 |
* @see #setLexicalHandler |
|
210 |
*/ |
|
211 |
public DeclHandler getDeclHandler(); |
|
212 |
||
213 |
/** |
|
214 |
* Allow an application to register an encoding algorithm handler. |
|
215 |
* |
|
216 |
* <p>Applications may register a new or different handler in the |
|
217 |
* middle of a parse, and the SAX parser must begin using the new |
|
218 |
* handler immediately.</p> |
|
219 |
* |
|
220 |
* @param handler The encoding algorithm handler. |
|
221 |
* @see #getEncodingAlgorithmContentHandler |
|
222 |
*/ |
|
223 |
public void setEncodingAlgorithmContentHandler(EncodingAlgorithmContentHandler handler); |
|
224 |
||
225 |
/** |
|
226 |
* Return the current encoding algorithm handler. |
|
227 |
* |
|
228 |
* @return The current encoding algorithm handler, or null if none |
|
229 |
* has been registered. |
|
230 |
* @see #setEncodingAlgorithmContentHandler |
|
231 |
*/ |
|
232 |
public EncodingAlgorithmContentHandler getEncodingAlgorithmContentHandler(); |
|
233 |
||
234 |
/** |
|
235 |
* Allow an application to register a primitive type handler. |
|
236 |
* |
|
237 |
* <p>Applications may register a new or different handler in the |
|
238 |
* middle of a parse, and the SAX parser must begin using the new |
|
239 |
* handler immediately.</p> |
|
240 |
* |
|
241 |
* @param handler The primitive type handler. |
|
242 |
* @see #getPrimitiveTypeContentHandler |
|
243 |
*/ |
|
244 |
public void setPrimitiveTypeContentHandler(PrimitiveTypeContentHandler handler); |
|
245 |
||
246 |
||
247 |
/** |
|
248 |
* Return the current primitive type handler. |
|
249 |
* |
|
250 |
* @return The current primitive type handler, or null if none |
|
251 |
* has been registered. |
|
252 |
* @see #setPrimitiveTypeContentHandler |
|
253 |
*/ |
|
254 |
public PrimitiveTypeContentHandler getPrimitiveTypeContentHandler(); |
|
255 |
} |