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