View Javadoc
1   /*
2    * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved.
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;
29  
30  import java.io.OutputStream;
31  import java.util.Map;
32  
33  /**
34   * A general interface for serializers of fast infoset documents.
35   *
36   * <p>
37   * This interface contains common methods that are not specific to any
38   * API associated with the serialization of XML Infoset to fast infoset
39   * documents.
40   *
41   * @author Paul.Sandoz@Sun.Com
42   */
43  public interface FastInfosetSerializer {
44      /**
45       * The feature to ignore the document type declaration and the
46       * internal subset.
47       * <p>
48       * The default value is false. If true a serializer shall ignore document
49       * type declaration and the internal subset.
50       */
51      public static final String IGNORE_DTD_FEATURE =
52          "http://jvnet.org/fastinfoset/serializer/feature/ignore/DTD";
53  
54      /**
55       * The feature to ignore comments.
56       * <p>
57       * The default value is false. If true a serializer shall ignore comments
58       * and shall not serialize them.
59       */
60      public static final String IGNORE_COMMENTS_FEATURE =
61          "http://jvnet.org/fastinfoset/serializer/feature/ignore/comments";
62  
63      /**
64       * The feature to ignore processing instructions.
65       * <p>
66       * The default value is false. If true a serializer shall ignore processing
67       * instructions and shall not serialize them.
68       */
69      public static final String IGNORE_PROCESSING_INSTRUCTIONS_FEATURE =
70          "http://jvnet.org/fastinfoset/serializer/feature/ignore/processingInstructions";
71  
72      /**
73       * The feature to ignore text content that consists completely of white
74       * space characters.
75       * <p>
76       * The default value is false. If true a serializer shall ignore text
77       * content that consists completely of white space characters.
78       */
79      public static final String IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE =
80          "http://jvnet.org/fastinfoset/serializer/feature/ignore/whiteSpaceTextContent";
81  
82      /**
83       * The property name to be used for getting and setting the buffer size
84       * of a parser.
85       */
86      public static final String BUFFER_SIZE_PROPERTY =
87          "http://jvnet.org/fastinfoset/parser/properties/buffer-size";
88  
89      /**
90       * The property name to be used for getting and setting the
91       * Map containing encoding algorithms.
92       *
93       */
94      public static final String REGISTERED_ENCODING_ALGORITHMS_PROPERTY =
95          "http://jvnet.org/fastinfoset/parser/properties/registered-encoding-algorithms";
96  
97     /**
98       * The property name to be used for getting and setting the
99       * Map containing external vocabularies.
100      *
101      */
102     public static final String EXTERNAL_VOCABULARIES_PROPERTY =
103         "http://jvnet.org/fastinfoset/parser/properties/external-vocabularies";
104 
105     /**
106      * The default minimum size of the character content chunks,
107      * that will be indexed.
108      */
109     public final static int MIN_CHARACTER_CONTENT_CHUNK_SIZE = 0;
110 
111     /**
112      * The default maximum size of the character content chunks,
113      * that will be indexed.
114      */
115     public final static int MAX_CHARACTER_CONTENT_CHUNK_SIZE = 32;
116 
117     /**
118      * The default value for limit on the size of indexed Map for attribute values
119      * Limit is measured in bytes not in number of entries
120      */
121     public static final int CHARACTER_CONTENT_CHUNK_MAP_MEMORY_CONSTRAINT = Integer.MAX_VALUE;
122 
123     /**
124      * The default minimum size of the attribute values, that will be indexed.
125      */
126     public final static int MIN_ATTRIBUTE_VALUE_SIZE = 0;
127 
128     /**
129      * The default maximum size of the attribute values, that will be indexed.
130      */
131     public final static int MAX_ATTRIBUTE_VALUE_SIZE = 32;
132 
133     /**
134      * The default value for limit on the size of indexed Map for attribute values
135      * Limit is measured in bytes not in number of entries
136      */
137     public static final int ATTRIBUTE_VALUE_MAP_MEMORY_CONSTRAINT = Integer.MAX_VALUE;
138 
139     /**
140      * The character encoding scheme string for UTF-8.
141      */
142     public static final String UTF_8 = "UTF-8";
143 
144     /**
145      * The character encoding scheme string for UTF-16BE.
146      */
147     public static final String UTF_16BE = "UTF-16BE";
148 
149     /**
150      * Set the {@link #IGNORE_DTD_FEATURE}.
151      * @param ignoreDTD true if the feature shall be ignored.
152      */
153     public void setIgnoreDTD(boolean ignoreDTD);
154 
155     /**
156      * Get the {@link #IGNORE_DTD_FEATURE}.
157      * @return true if the feature is ignored, false otherwise.
158      */
159     public boolean getIgnoreDTD();
160 
161     /**
162      * Set the {@link #IGNORE_COMMENTS_FEATURE}.
163      * @param ignoreComments true if the feature shall be ignored.
164      */
165     public void setIgnoreComments(boolean ignoreComments);
166 
167     /**
168      * Get the {@link #IGNORE_COMMENTS_FEATURE}.
169      * @return true if the feature is ignored, false otherwise.
170      */
171     public boolean getIgnoreComments();
172 
173     /**
174      * Set the {@link #IGNORE_PROCESSING_INSTRUCTIONS_FEATURE}.
175      * @param ignoreProcesingInstructions true if the feature shall be ignored.
176      */
177     public void setIgnoreProcesingInstructions(boolean ignoreProcesingInstructions);
178 
179     /**
180      * Get the {@link #IGNORE_PROCESSING_INSTRUCTIONS_FEATURE}.
181      * @return true if the feature is ignored, false otherwise.
182      */
183     public boolean getIgnoreProcesingInstructions();
184 
185     /**
186      * Set the {@link #IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE}.
187      * @param ignoreWhiteSpaceTextContent true if the feature shall be ignored.
188      */
189     public void setIgnoreWhiteSpaceTextContent(boolean ignoreWhiteSpaceTextContent);
190 
191     /**
192      * Get the {@link #IGNORE_WHITE_SPACE_TEXT_CONTENT_FEATURE}.
193      * @return true if the feature is ignored, false otherwise.
194      */
195     public boolean getIgnoreWhiteSpaceTextContent();
196 
197     /**
198      * Sets the character encoding scheme.
199      *
200      * The character encoding can be either UTF-8 or UTF-16BE for the
201      * the encoding of chunks of CIIs, the [normalized value]
202      * property of attribute information items, comment information
203      * items and processing instruction information items.
204      *
205      * @param characterEncodingScheme The set of registered algorithms.
206      */
207     public void setCharacterEncodingScheme(String characterEncodingScheme);
208 
209     /**
210      * Gets the character encoding scheme.
211      *
212      * @return The character encoding scheme.
213      */
214     public String getCharacterEncodingScheme();
215 
216     /**
217      * Sets the set of registered encoding algorithms.
218      *
219      * @param algorithms The set of registered algorithms.
220      */
221     public void setRegisteredEncodingAlgorithms(Map algorithms);
222 
223     /**
224      * Gets the set of registered encoding algorithms.
225      *
226      * @return The set of registered algorithms.
227      */
228     public Map getRegisteredEncodingAlgorithms();
229 
230     /**
231      * Gets the minimum size of character content chunks
232      * that will be indexed.
233      *
234      * @return The minimum character content chunk size.
235      */
236     public int getMinCharacterContentChunkSize();
237 
238     /**
239      * Sets the minimum size of character content chunks
240      * that will be indexed.
241      *
242      * @param size the minimum character content chunk size.
243      */
244     public void setMinCharacterContentChunkSize(int size);
245 
246     /**
247      * Gets the maximum size of character content chunks
248      * that might be indexed.
249      *
250      * @return The maximum character content chunk size.
251      */
252     public int getMaxCharacterContentChunkSize();
253 
254     /**
255      * Sets the maximum size of character content chunks
256      * that might be indexed.
257      *
258      * @param size the maximum character content chunk size.
259      */
260     public void setMaxCharacterContentChunkSize(int size);
261 
262     /**
263      * Gets the limit on the memory size, allocated for indexed character
264      * content chunks.
265      *
266      * @return the limit on the memory size, allocated for indexed character
267      * content chunks.
268      */
269     public int getCharacterContentChunkMapMemoryLimit();
270 
271     /**
272      * Sets the limit on the memory size, allocated for indexed character
273      * content chunks.
274      *
275      * @param size the limit on the memory size, allocated for indexed character
276      * content chunks.
277      */
278     public void setCharacterContentChunkMapMemoryLimit(int size);
279 
280     /**
281      * Gets the minimum size of attribute values
282      * that will be indexed.
283      *
284      * @return The minimum attribute values size.
285      */
286     public int getMinAttributeValueSize();
287 
288     /**
289      * Sets the minimum size of attribute values
290      * that will be indexed.
291      *
292      * @param size the minimum attribute values size.
293      */
294     public void setMinAttributeValueSize(int size);
295 
296     /**
297      * Gets the maximum size of attribute values
298      * that will be indexed.
299      *
300      * @return The maximum attribute values size.
301      */
302     public int getMaxAttributeValueSize();
303 
304     /**
305      * Sets the maximum size of attribute values
306      * that will be indexed.
307      *
308      * @param size the maximum attribute values size.
309      */
310     public void setMaxAttributeValueSize(int size);
311 
312     /**
313      * Gets the limit on the memory size of Map of attribute values
314      * that will be indexed.
315      *
316      * @return The attribute value size limit.
317      */
318     public int getAttributeValueMapMemoryLimit();
319 
320     /**
321      * Sets the limit on the memory size of Map of attribute values
322      * that will be indexed.
323      *
324      * @param size The attribute value size limit. Any value less
325      * that a length of size limit will be indexed.
326      */
327     public void setAttributeValueMapMemoryLimit(int size);
328 
329     /**
330      * Set the external vocabulary that shall be used when serializing.
331      *
332      * @param v the vocabulary.
333      */
334     public void setExternalVocabulary(ExternalVocabulary v);
335 
336     /**
337      * Set the application data to be associated with the serializer vocabulary.
338      *
339      * @param data the application data.
340      */
341     public void setVocabularyApplicationData(VocabularyApplicationData data);
342 
343     /**
344      * Get the application data associated with the serializer vocabulary.
345      *
346      * @return the application data.
347      */
348     public VocabularyApplicationData getVocabularyApplicationData();
349 
350     /**
351      * Reset the serializer for reuse serializing another XML infoset.
352      */
353     public void reset();
354 
355     /**
356      * Set the OutputStream to serialize the XML infoset to a
357      * fast infoset document.
358      *
359      * @param s the OutputStream where the fast infoset document is written to.
360      */
361     public void setOutputStream(OutputStream s);
362 }