author | joehw |
Wed, 09 Mar 2016 16:09:55 -0800 | |
changeset 36486 | b84e564d2358 |
parent 33349 | 975138b77cff |
child 44797 | 8b3b3b911b8a |
permissions | -rw-r--r-- |
6 | 1 |
/* |
36486
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
2 |
* Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
6 | 3 |
*/ |
4 |
/* |
|
5 |
* Copyright 1999-2004 The Apache Software Foundation. |
|
6 |
* |
|
7 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
8 |
* you may not use this file except in compliance with the License. |
|
9 |
* You may obtain a copy of the License at |
|
10 |
* |
|
11 |
* http://www.apache.org/licenses/LICENSE-2.0 |
|
12 |
* |
|
13 |
* Unless required by applicable law or agreed to in writing, software |
|
14 |
* distributed under the License is distributed on an "AS IS" BASIS, |
|
15 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
16 |
* See the License for the specific language governing permissions and |
|
17 |
* limitations under the License. |
|
18 |
*/ |
|
36486
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
19 |
|
6 | 20 |
package com.sun.org.apache.xalan.internal.xsltc.dom; |
21 |
||
22 |
import com.sun.org.apache.xalan.internal.xsltc.DOM; |
|
33349 | 23 |
import com.sun.org.apache.xalan.internal.xsltc.StripFilter; |
6 | 24 |
import com.sun.org.apache.xalan.internal.xsltc.TransletException; |
33349 | 25 |
import com.sun.org.apache.xml.internal.dtm.Axis; |
6 | 26 |
import com.sun.org.apache.xml.internal.dtm.DTM; |
27 |
import com.sun.org.apache.xml.internal.dtm.DTMAxisIterator; |
|
28 |
import com.sun.org.apache.xml.internal.dtm.DTMAxisTraverser; |
|
29 |
import com.sun.org.apache.xml.internal.dtm.DTMManager; |
|
30 |
import com.sun.org.apache.xml.internal.dtm.ref.DTMAxisIteratorBase; |
|
31 |
import com.sun.org.apache.xml.internal.dtm.ref.DTMManagerDefault; |
|
32 |
import com.sun.org.apache.xml.internal.serializer.EmptySerializer; |
|
33 |
import com.sun.org.apache.xml.internal.serializer.SerializationHandler; |
|
34 |
import com.sun.org.apache.xml.internal.utils.XMLString; |
|
35 |
import com.sun.org.apache.xml.internal.utils.XMLStringDefault; |
|
33349 | 36 |
import java.util.Map; |
37 |
import javax.xml.transform.SourceLocator; |
|
6 | 38 |
import org.w3c.dom.Node; |
39 |
import org.w3c.dom.NodeList; |
|
40 |
import org.xml.sax.SAXException; |
|
41 |
||
42 |
/** |
|
43 |
* This class represents a light-weight DOM model for simple result tree fragment(RTF). |
|
44 |
* A simple RTF is an RTF that has only one Text node. The Text node can be produced by a |
|
45 |
* combination of Text, xsl:value-of and xsl:number instructions. It can also be produced |
|
46 |
* by a control structure (xsl:if or xsl:choose) whose body is pure Text. |
|
47 |
* <p> |
|
48 |
* A SimpleResultTreeImpl has only two nodes, i.e. the ROOT node and its Text child. All DOM |
|
49 |
* interfaces are overridden with this in mind. For example, the getStringValue() interface |
|
50 |
* returns the value of the Text node. This class receives the character data from the |
|
51 |
* characters() interface. |
|
52 |
* <p> |
|
53 |
* This class implements DOM and SerializationHandler. It also implements the DTM interface |
|
54 |
* for support in MultiDOM. The nested iterators (SimpleIterator and SingletonIterator) are |
|
55 |
* used to support the nodeset() extension function. |
|
56 |
*/ |
|
57 |
public class SimpleResultTreeImpl extends EmptySerializer implements DOM, DTM |
|
58 |
{ |
|
59 |
||
60 |
/** |
|
61 |
* The SimpleIterator is designed to support the nodeset() extension function. It has |
|
62 |
* a traversal direction parameter. The DOWN direction is used for child and descendant |
|
63 |
* axes, while the UP direction is used for parent and ancestor axes. |
|
64 |
* |
|
65 |
* This iterator only handles two nodes (RTF_ROOT and RTF_TEXT). If the type is set, |
|
66 |
* it will also match the node type with the given type. |
|
67 |
*/ |
|
68 |
public final class SimpleIterator extends DTMAxisIteratorBase |
|
69 |
{ |
|
70 |
static final int DIRECTION_UP = 0; |
|
71 |
static final int DIRECTION_DOWN = 1; |
|
72 |
static final int NO_TYPE = -1; |
|
73 |
||
74 |
// The direction of traversal (default to DOWN). |
|
75 |
// DOWN is for child and descendant. UP is for parent and ancestor. |
|
76 |
int _direction = DIRECTION_DOWN; |
|
77 |
||
78 |
int _type = NO_TYPE; |
|
79 |
int _currentNode; |
|
80 |
||
81 |
public SimpleIterator() |
|
82 |
{ |
|
83 |
} |
|
84 |
||
85 |
public SimpleIterator(int direction) |
|
86 |
{ |
|
87 |
_direction = direction; |
|
88 |
} |
|
89 |
||
90 |
public SimpleIterator(int direction, int type) |
|
91 |
{ |
|
92 |
_direction = direction; |
|
93 |
_type = type; |
|
94 |
} |
|
95 |
||
96 |
public int next() |
|
97 |
{ |
|
98 |
// Increase the node ID for down traversal. Also match the node type |
|
99 |
// if the type is given. |
|
100 |
if (_direction == DIRECTION_DOWN) { |
|
101 |
while (_currentNode < NUMBER_OF_NODES) { |
|
102 |
if (_type != NO_TYPE) { |
|
103 |
if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE) |
|
104 |
|| (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE)) |
|
105 |
return returnNode(getNodeHandle(_currentNode++)); |
|
106 |
else |
|
107 |
_currentNode++; |
|
108 |
} |
|
109 |
else |
|
110 |
return returnNode(getNodeHandle(_currentNode++)); |
|
111 |
} |
|
112 |
||
113 |
return END; |
|
114 |
} |
|
115 |
// Decrease the node ID for up traversal. |
|
116 |
else { |
|
117 |
while (_currentNode >= 0) { |
|
118 |
if (_type != NO_TYPE) { |
|
119 |
if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE) |
|
120 |
|| (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE)) |
|
121 |
return returnNode(getNodeHandle(_currentNode--)); |
|
122 |
else |
|
123 |
_currentNode--; |
|
124 |
} |
|
125 |
else |
|
126 |
return returnNode(getNodeHandle(_currentNode--)); |
|
127 |
} |
|
128 |
||
129 |
return END; |
|
130 |
} |
|
131 |
} |
|
132 |
||
133 |
public DTMAxisIterator setStartNode(int nodeHandle) |
|
134 |
{ |
|
135 |
int nodeID = getNodeIdent(nodeHandle); |
|
136 |
_startNode = nodeID; |
|
137 |
||
138 |
// Increase the node ID by 1 if self is not included. |
|
139 |
if (!_includeSelf && nodeID != DTM.NULL) { |
|
140 |
if (_direction == DIRECTION_DOWN) |
|
141 |
nodeID++; |
|
142 |
else if (_direction == DIRECTION_UP) |
|
143 |
nodeID--; |
|
144 |
} |
|
145 |
||
146 |
_currentNode = nodeID; |
|
147 |
return this; |
|
148 |
} |
|
149 |
||
150 |
public void setMark() |
|
151 |
{ |
|
152 |
_markedNode = _currentNode; |
|
153 |
} |
|
154 |
||
155 |
public void gotoMark() |
|
156 |
{ |
|
157 |
_currentNode = _markedNode; |
|
158 |
} |
|
159 |
||
160 |
} // END of SimpleIterator |
|
161 |
||
162 |
/** |
|
163 |
* The SingletonIterator is used for the self axis. |
|
164 |
*/ |
|
165 |
public final class SingletonIterator extends DTMAxisIteratorBase |
|
166 |
{ |
|
167 |
static final int NO_TYPE = -1; |
|
168 |
int _type = NO_TYPE; |
|
169 |
int _currentNode; |
|
170 |
||
171 |
public SingletonIterator() |
|
172 |
{ |
|
173 |
} |
|
174 |
||
175 |
public SingletonIterator(int type) |
|
176 |
{ |
|
177 |
_type = type; |
|
178 |
} |
|
179 |
||
180 |
public void setMark() |
|
181 |
{ |
|
182 |
_markedNode = _currentNode; |
|
183 |
} |
|
184 |
||
185 |
public void gotoMark() |
|
186 |
{ |
|
187 |
_currentNode = _markedNode; |
|
188 |
} |
|
189 |
||
190 |
public DTMAxisIterator setStartNode(int nodeHandle) |
|
191 |
{ |
|
192 |
_currentNode = _startNode = getNodeIdent(nodeHandle); |
|
193 |
return this; |
|
194 |
} |
|
195 |
||
196 |
public int next() |
|
197 |
{ |
|
198 |
if (_currentNode == END) |
|
199 |
return END; |
|
200 |
||
201 |
_currentNode = END; |
|
202 |
||
203 |
if (_type != NO_TYPE) { |
|
204 |
if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE) |
|
205 |
|| (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE)) |
|
206 |
return getNodeHandle(_currentNode); |
|
207 |
} |
|
208 |
else |
|
209 |
return getNodeHandle(_currentNode); |
|
210 |
||
211 |
return END; |
|
212 |
} |
|
213 |
||
214 |
} // END of SingletonIterator |
|
215 |
||
216 |
// empty iterator to be returned when there are no children |
|
217 |
private final static DTMAxisIterator EMPTY_ITERATOR = |
|
218 |
new DTMAxisIteratorBase() { |
|
219 |
public DTMAxisIterator reset() { return this; } |
|
220 |
public DTMAxisIterator setStartNode(int node) { return this; } |
|
221 |
public int next() { return DTM.NULL; } |
|
222 |
public void setMark() {} |
|
223 |
public void gotoMark() {} |
|
224 |
public int getLast() { return 0; } |
|
225 |
public int getPosition() { return 0; } |
|
226 |
public DTMAxisIterator cloneIterator() { return this; } |
|
227 |
public void setRestartable(boolean isRestartable) { } |
|
228 |
}; |
|
229 |
||
230 |
||
231 |
// The root node id of the simple RTF |
|
232 |
public static final int RTF_ROOT = 0; |
|
233 |
||
234 |
// The Text node id of the simple RTF (simple RTF has only one Text node). |
|
235 |
public static final int RTF_TEXT = 1; |
|
236 |
||
237 |
// The number of nodes. |
|
238 |
public static final int NUMBER_OF_NODES = 2; |
|
239 |
||
240 |
// Document URI index, which increases by 1 at each getDocumentURI() call. |
|
241 |
private static int _documentURIIndex = 0; |
|
242 |
||
243 |
// Constant for empty String |
|
244 |
private static final String EMPTY_STR = ""; |
|
245 |
||
246 |
// The String value of the Text node. |
|
247 |
// This is set at the endDocument() call. |
|
248 |
private String _text; |
|
249 |
||
250 |
// The array of Text items, which is built by the characters() call. |
|
251 |
// The characters() interface can be called multiple times. Each character item |
|
252 |
// can have different escape settings. |
|
253 |
protected String[] _textArray; |
|
254 |
||
255 |
// The DTMManager |
|
256 |
protected XSLTCDTMManager _dtmManager; |
|
257 |
||
258 |
// Number of character items |
|
259 |
protected int _size = 0; |
|
260 |
||
261 |
// The document ID |
|
262 |
private int _documentID; |
|
263 |
||
264 |
// A BitArray, each bit holding the escape setting for a character item. |
|
265 |
private BitArray _dontEscape = null; |
|
266 |
||
267 |
// The current escape setting |
|
268 |
private boolean _escaping = true; |
|
269 |
||
270 |
// Create a SimpleResultTreeImpl from a DTMManager and a document ID. |
|
271 |
public SimpleResultTreeImpl(XSLTCDTMManager dtmManager, int documentID) |
|
272 |
{ |
|
273 |
_dtmManager = dtmManager; |
|
274 |
_documentID = documentID; |
|
275 |
_textArray = new String[4]; |
|
276 |
} |
|
277 |
||
278 |
public DTMManagerDefault getDTMManager() |
|
279 |
{ |
|
280 |
return _dtmManager; |
|
281 |
} |
|
282 |
||
283 |
// Return the document ID |
|
284 |
public int getDocument() |
|
285 |
{ |
|
286 |
return _documentID; |
|
287 |
} |
|
288 |
||
289 |
// Return the String value of the RTF |
|
290 |
public String getStringValue() |
|
291 |
{ |
|
292 |
return _text; |
|
293 |
} |
|
294 |
||
295 |
public DTMAxisIterator getIterator() |
|
296 |
{ |
|
297 |
return new SingletonIterator(getDocument()); |
|
298 |
} |
|
299 |
||
300 |
public DTMAxisIterator getChildren(final int node) |
|
301 |
{ |
|
302 |
return new SimpleIterator().setStartNode(node); |
|
303 |
} |
|
304 |
||
305 |
public DTMAxisIterator getTypedChildren(final int type) |
|
306 |
{ |
|
307 |
return new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type); |
|
308 |
} |
|
309 |
||
310 |
// Return the axis iterator for a given axis. |
|
311 |
// The SimpleIterator is used for the child, descendant, parent and ancestor axes. |
|
312 |
public DTMAxisIterator getAxisIterator(final int axis) |
|
313 |
{ |
|
314 |
switch (axis) |
|
315 |
{ |
|
316 |
case Axis.CHILD: |
|
317 |
case Axis.DESCENDANT: |
|
318 |
return new SimpleIterator(SimpleIterator.DIRECTION_DOWN); |
|
319 |
case Axis.PARENT: |
|
320 |
case Axis.ANCESTOR: |
|
321 |
return new SimpleIterator(SimpleIterator.DIRECTION_UP); |
|
322 |
case Axis.ANCESTORORSELF: |
|
323 |
return (new SimpleIterator(SimpleIterator.DIRECTION_UP)).includeSelf(); |
|
324 |
case Axis.DESCENDANTORSELF: |
|
325 |
return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN)).includeSelf(); |
|
326 |
case Axis.SELF: |
|
327 |
return new SingletonIterator(); |
|
328 |
default: |
|
329 |
return EMPTY_ITERATOR; |
|
330 |
} |
|
331 |
} |
|
332 |
||
333 |
public DTMAxisIterator getTypedAxisIterator(final int axis, final int type) |
|
334 |
{ |
|
335 |
switch (axis) |
|
336 |
{ |
|
337 |
case Axis.CHILD: |
|
338 |
case Axis.DESCENDANT: |
|
339 |
return new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type); |
|
340 |
case Axis.PARENT: |
|
341 |
case Axis.ANCESTOR: |
|
342 |
return new SimpleIterator(SimpleIterator.DIRECTION_UP, type); |
|
343 |
case Axis.ANCESTORORSELF: |
|
344 |
return (new SimpleIterator(SimpleIterator.DIRECTION_UP, type)).includeSelf(); |
|
345 |
case Axis.DESCENDANTORSELF: |
|
346 |
return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN, type)).includeSelf(); |
|
347 |
case Axis.SELF: |
|
348 |
return new SingletonIterator(type); |
|
349 |
default: |
|
350 |
return EMPTY_ITERATOR; |
|
351 |
} |
|
352 |
} |
|
353 |
||
354 |
// %REVISIT% Can this one ever get used? |
|
355 |
public DTMAxisIterator getNthDescendant(int node, int n, boolean includeself) |
|
356 |
{ |
|
357 |
return null; |
|
358 |
} |
|
359 |
||
360 |
public DTMAxisIterator getNamespaceAxisIterator(final int axis, final int ns) |
|
361 |
{ |
|
362 |
return null; |
|
363 |
} |
|
364 |
||
365 |
// %REVISIT% Can this one ever get used? |
|
366 |
public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter, int returnType, |
|
367 |
String value, boolean op) |
|
368 |
{ |
|
369 |
return null; |
|
370 |
} |
|
371 |
||
372 |
public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) |
|
373 |
{ |
|
374 |
return source; |
|
375 |
} |
|
376 |
||
377 |
public String getNodeName(final int node) |
|
378 |
{ |
|
379 |
if (getNodeIdent(node) == RTF_TEXT) |
|
380 |
return "#text"; |
|
381 |
else |
|
382 |
return EMPTY_STR; |
|
383 |
} |
|
384 |
||
385 |
public String getNodeNameX(final int node) |
|
386 |
{ |
|
387 |
return EMPTY_STR; |
|
388 |
} |
|
389 |
||
390 |
public String getNamespaceName(final int node) |
|
391 |
{ |
|
392 |
return EMPTY_STR; |
|
393 |
} |
|
394 |
||
395 |
// Return the expanded type id of a given node |
|
396 |
public int getExpandedTypeID(final int nodeHandle) |
|
397 |
{ |
|
398 |
int nodeID = getNodeIdent(nodeHandle); |
|
399 |
if (nodeID == RTF_TEXT) |
|
400 |
return DTM.TEXT_NODE; |
|
401 |
else if (nodeID == RTF_ROOT) |
|
402 |
return DTM.ROOT_NODE; |
|
403 |
else |
|
404 |
return DTM.NULL; |
|
405 |
} |
|
406 |
||
407 |
public int getNamespaceType(final int node) |
|
408 |
{ |
|
409 |
return 0; |
|
410 |
} |
|
411 |
||
412 |
public int getParent(final int nodeHandle) |
|
413 |
{ |
|
414 |
int nodeID = getNodeIdent(nodeHandle); |
|
415 |
return (nodeID == RTF_TEXT) ? getNodeHandle(RTF_ROOT) : DTM.NULL; |
|
416 |
} |
|
417 |
||
418 |
public int getAttributeNode(final int gType, final int element) |
|
419 |
{ |
|
420 |
return DTM.NULL; |
|
421 |
} |
|
422 |
||
423 |
public String getStringValueX(final int nodeHandle) |
|
424 |
{ |
|
425 |
int nodeID = getNodeIdent(nodeHandle); |
|
426 |
if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) |
|
427 |
return _text; |
|
428 |
else |
|
429 |
return EMPTY_STR; |
|
430 |
} |
|
431 |
||
432 |
public void copy(final int node, SerializationHandler handler) |
|
433 |
throws TransletException |
|
434 |
{ |
|
435 |
characters(node, handler); |
|
436 |
} |
|
437 |
||
438 |
public void copy(DTMAxisIterator nodes, SerializationHandler handler) |
|
439 |
throws TransletException |
|
440 |
{ |
|
441 |
int node; |
|
442 |
while ((node = nodes.next()) != DTM.NULL) |
|
443 |
{ |
|
444 |
copy(node, handler); |
|
445 |
} |
|
446 |
} |
|
447 |
||
448 |
public String shallowCopy(final int node, SerializationHandler handler) |
|
449 |
throws TransletException |
|
450 |
{ |
|
451 |
characters(node, handler); |
|
452 |
return null; |
|
453 |
} |
|
454 |
||
455 |
public boolean lessThan(final int node1, final int node2) |
|
456 |
{ |
|
457 |
if (node1 == DTM.NULL) { |
|
458 |
return false; |
|
459 |
} |
|
460 |
else if (node2 == DTM.NULL) { |
|
461 |
return true; |
|
462 |
} |
|
463 |
else |
|
464 |
return (node1 < node2); |
|
465 |
} |
|
466 |
||
467 |
/** |
|
468 |
* Dispatch the character content of a node to an output handler. |
|
469 |
* |
|
470 |
* The escape setting should be taken care of when outputting to |
|
471 |
* a handler. |
|
472 |
*/ |
|
473 |
public void characters(final int node, SerializationHandler handler) |
|
474 |
throws TransletException |
|
475 |
{ |
|
476 |
int nodeID = getNodeIdent(node); |
|
477 |
if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) { |
|
478 |
boolean escapeBit = false; |
|
479 |
boolean oldEscapeSetting = false; |
|
480 |
||
481 |
try { |
|
482 |
for (int i = 0; i < _size; i++) { |
|
483 |
||
484 |
if (_dontEscape != null) { |
|
485 |
escapeBit = _dontEscape.getBit(i); |
|
486 |
if (escapeBit) { |
|
487 |
oldEscapeSetting = handler.setEscaping(false); |
|
488 |
} |
|
489 |
} |
|
490 |
||
491 |
handler.characters(_textArray[i]); |
|
492 |
||
493 |
if (escapeBit) { |
|
494 |
handler.setEscaping(oldEscapeSetting); |
|
495 |
} |
|
496 |
} |
|
497 |
} catch (SAXException e) { |
|
498 |
throw new TransletException(e); |
|
499 |
} |
|
500 |
} |
|
501 |
} |
|
502 |
||
503 |
// %REVISIT% Can the makeNode() and makeNodeList() interfaces ever get used? |
|
504 |
public Node makeNode(int index) |
|
505 |
{ |
|
506 |
return null; |
|
507 |
} |
|
508 |
||
509 |
public Node makeNode(DTMAxisIterator iter) |
|
510 |
{ |
|
511 |
return null; |
|
512 |
} |
|
513 |
||
514 |
public NodeList makeNodeList(int index) |
|
515 |
{ |
|
516 |
return null; |
|
517 |
} |
|
518 |
||
519 |
public NodeList makeNodeList(DTMAxisIterator iter) |
|
520 |
{ |
|
521 |
return null; |
|
522 |
} |
|
523 |
||
524 |
public String getLanguage(int node) |
|
525 |
{ |
|
526 |
return null; |
|
527 |
} |
|
528 |
||
529 |
public int getSize() |
|
530 |
{ |
|
531 |
return 2; |
|
532 |
} |
|
533 |
||
534 |
public String getDocumentURI(int node) |
|
535 |
{ |
|
536 |
return "simple_rtf" + _documentURIIndex++; |
|
537 |
} |
|
538 |
||
539 |
public void setFilter(StripFilter filter) |
|
540 |
{ |
|
541 |
} |
|
542 |
||
543 |
public void setupMapping(String[] names, String[] uris, int[] types, String[] namespaces) |
|
544 |
{ |
|
545 |
} |
|
546 |
||
547 |
public boolean isElement(final int node) |
|
548 |
{ |
|
549 |
return false; |
|
550 |
} |
|
551 |
||
552 |
public boolean isAttribute(final int node) |
|
553 |
{ |
|
554 |
return false; |
|
555 |
} |
|
556 |
||
557 |
public String lookupNamespace(int node, String prefix) |
|
558 |
throws TransletException |
|
559 |
{ |
|
560 |
return null; |
|
561 |
} |
|
562 |
||
563 |
/** |
|
564 |
* Return the node identity from a node handle. |
|
565 |
*/ |
|
566 |
public int getNodeIdent(final int nodehandle) |
|
567 |
{ |
|
568 |
return (nodehandle != DTM.NULL) ? (nodehandle - _documentID) : DTM.NULL; |
|
569 |
} |
|
570 |
||
571 |
/** |
|
572 |
* Return the node handle from a node identity. |
|
573 |
*/ |
|
574 |
public int getNodeHandle(final int nodeId) |
|
575 |
{ |
|
576 |
return (nodeId != DTM.NULL) ? (nodeId + _documentID) : DTM.NULL; |
|
577 |
} |
|
578 |
||
579 |
public DOM getResultTreeFrag(int initialSize, int rtfType) |
|
580 |
{ |
|
581 |
return null; |
|
582 |
} |
|
583 |
||
584 |
public DOM getResultTreeFrag(int initialSize, int rtfType, boolean addToManager) |
|
585 |
{ |
|
586 |
return null; |
|
587 |
} |
|
588 |
||
589 |
public SerializationHandler getOutputDomBuilder() |
|
590 |
{ |
|
591 |
return this; |
|
592 |
} |
|
593 |
||
594 |
public int getNSType(int node) |
|
595 |
{ |
|
596 |
return 0; |
|
597 |
} |
|
598 |
||
599 |
public String getUnparsedEntityURI(String name) |
|
600 |
{ |
|
601 |
return null; |
|
602 |
} |
|
603 |
||
33349 | 604 |
public Map<String, Integer> getElementsWithIDs() |
6 | 605 |
{ |
606 |
return null; |
|
607 |
} |
|
608 |
||
609 |
/** Implementation of the SerializationHandler interfaces **/ |
|
610 |
||
611 |
/** |
|
612 |
* We only need to override the endDocument, characters, and |
|
613 |
* setEscaping interfaces. A simple RTF does not have element |
|
614 |
* nodes. We do not need to touch startElement and endElement. |
|
615 |
*/ |
|
616 |
||
617 |
public void startDocument() throws SAXException |
|
618 |
{ |
|
619 |
||
620 |
} |
|
621 |
||
622 |
public void endDocument() throws SAXException |
|
623 |
{ |
|
624 |
// Set the String value when the document is built. |
|
625 |
if (_size == 1) |
|
626 |
_text = _textArray[0]; |
|
627 |
else { |
|
628 |
StringBuffer buffer = new StringBuffer(); |
|
629 |
for (int i = 0; i < _size; i++) { |
|
630 |
buffer.append(_textArray[i]); |
|
631 |
} |
|
632 |
_text = buffer.toString(); |
|
633 |
} |
|
634 |
} |
|
635 |
||
636 |
public void characters(String str) throws SAXException |
|
637 |
{ |
|
638 |
// Resize the text array if necessary |
|
639 |
if (_size >= _textArray.length) { |
|
640 |
String[] newTextArray = new String[_textArray.length * 2]; |
|
641 |
System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length); |
|
642 |
_textArray = newTextArray; |
|
643 |
} |
|
644 |
||
645 |
// If the escape setting is false, set the corresponding bit in |
|
646 |
// the _dontEscape BitArray. |
|
647 |
if (!_escaping) { |
|
648 |
// The _dontEscape array is only created when needed. |
|
649 |
if (_dontEscape == null) { |
|
650 |
_dontEscape = new BitArray(8); |
|
651 |
} |
|
652 |
||
653 |
// Resize the _dontEscape array if necessary |
|
654 |
if (_size >= _dontEscape.size()) |
|
655 |
_dontEscape.resize(_dontEscape.size() * 2); |
|
656 |
||
657 |
_dontEscape.setBit(_size); |
|
658 |
} |
|
659 |
||
660 |
_textArray[_size++] = str; |
|
661 |
} |
|
662 |
||
663 |
public void characters(char[] ch, int offset, int length) |
|
664 |
throws SAXException |
|
665 |
{ |
|
666 |
if (_size >= _textArray.length) { |
|
667 |
String[] newTextArray = new String[_textArray.length * 2]; |
|
668 |
System.arraycopy(_textArray, 0, newTextArray, 0, _textArray.length); |
|
669 |
_textArray = newTextArray; |
|
670 |
} |
|
671 |
||
672 |
if (!_escaping) { |
|
673 |
if (_dontEscape == null) { |
|
674 |
_dontEscape = new BitArray(8); |
|
675 |
} |
|
676 |
||
677 |
if (_size >= _dontEscape.size()) |
|
678 |
_dontEscape.resize(_dontEscape.size() * 2); |
|
679 |
||
680 |
_dontEscape.setBit(_size); |
|
681 |
} |
|
682 |
||
683 |
_textArray[_size++] = new String(ch, offset, length); |
|
684 |
||
685 |
} |
|
686 |
||
687 |
public boolean setEscaping(boolean escape) throws SAXException |
|
688 |
{ |
|
689 |
final boolean temp = _escaping; |
|
690 |
_escaping = escape; |
|
691 |
return temp; |
|
692 |
} |
|
693 |
||
694 |
/** Implementation of the DTM interfaces **/ |
|
695 |
||
696 |
/** |
|
697 |
* The DTM interfaces are not used in this class. Implementing the DTM |
|
698 |
* interface is a requirement from MultiDOM. If we have a better way |
|
699 |
* of handling multiple documents, we can get rid of the DTM dependency. |
|
700 |
* |
|
701 |
* The following interfaces are just placeholders. The implementation |
|
702 |
* does not have an impact because they will not be used. |
|
703 |
*/ |
|
704 |
||
705 |
public void setFeature(String featureId, boolean state) |
|
706 |
{ |
|
707 |
} |
|
708 |
||
709 |
public void setProperty(String property, Object value) |
|
710 |
{ |
|
711 |
} |
|
712 |
||
713 |
public DTMAxisTraverser getAxisTraverser(final int axis) |
|
714 |
{ |
|
715 |
return null; |
|
716 |
} |
|
717 |
||
718 |
public boolean hasChildNodes(int nodeHandle) |
|
719 |
{ |
|
720 |
return (getNodeIdent(nodeHandle) == RTF_ROOT); |
|
721 |
} |
|
722 |
||
723 |
public int getFirstChild(int nodeHandle) |
|
724 |
{ |
|
725 |
int nodeID = getNodeIdent(nodeHandle); |
|
726 |
if (nodeID == RTF_ROOT) |
|
727 |
return getNodeHandle(RTF_TEXT); |
|
728 |
else |
|
729 |
return DTM.NULL; |
|
730 |
} |
|
731 |
||
732 |
public int getLastChild(int nodeHandle) |
|
733 |
{ |
|
734 |
return getFirstChild(nodeHandle); |
|
735 |
} |
|
736 |
||
737 |
public int getAttributeNode(int elementHandle, String namespaceURI, String name) |
|
738 |
{ |
|
739 |
return DTM.NULL; |
|
740 |
} |
|
741 |
||
742 |
public int getFirstAttribute(int nodeHandle) |
|
743 |
{ |
|
744 |
return DTM.NULL; |
|
745 |
} |
|
746 |
||
747 |
public int getFirstNamespaceNode(int nodeHandle, boolean inScope) |
|
748 |
{ |
|
749 |
return DTM.NULL; |
|
750 |
} |
|
751 |
||
752 |
public int getNextSibling(int nodeHandle) |
|
753 |
{ |
|
754 |
return DTM.NULL; |
|
755 |
} |
|
756 |
||
757 |
public int getPreviousSibling(int nodeHandle) |
|
758 |
{ |
|
759 |
return DTM.NULL; |
|
760 |
} |
|
761 |
||
762 |
public int getNextAttribute(int nodeHandle) |
|
763 |
{ |
|
764 |
return DTM.NULL; |
|
765 |
} |
|
766 |
||
767 |
public int getNextNamespaceNode(int baseHandle, int namespaceHandle, |
|
768 |
boolean inScope) |
|
769 |
{ |
|
770 |
return DTM.NULL; |
|
771 |
} |
|
772 |
||
773 |
public int getOwnerDocument(int nodeHandle) |
|
774 |
{ |
|
775 |
return getDocument(); |
|
776 |
} |
|
777 |
||
778 |
public int getDocumentRoot(int nodeHandle) |
|
779 |
{ |
|
780 |
return getDocument(); |
|
781 |
} |
|
782 |
||
783 |
public XMLString getStringValue(int nodeHandle) |
|
784 |
{ |
|
785 |
return new XMLStringDefault(getStringValueX(nodeHandle)); |
|
786 |
} |
|
787 |
||
788 |
public int getStringValueChunkCount(int nodeHandle) |
|
789 |
{ |
|
790 |
return 0; |
|
791 |
} |
|
792 |
||
793 |
public char[] getStringValueChunk(int nodeHandle, int chunkIndex, |
|
794 |
int[] startAndLen) |
|
795 |
{ |
|
796 |
return null; |
|
797 |
} |
|
798 |
||
799 |
public int getExpandedTypeID(String namespace, String localName, int type) |
|
800 |
{ |
|
801 |
return DTM.NULL; |
|
802 |
} |
|
803 |
||
804 |
public String getLocalNameFromExpandedNameID(int ExpandedNameID) |
|
805 |
{ |
|
806 |
return EMPTY_STR; |
|
807 |
} |
|
808 |
||
809 |
public String getNamespaceFromExpandedNameID(int ExpandedNameID) |
|
810 |
{ |
|
811 |
return EMPTY_STR; |
|
812 |
} |
|
813 |
||
814 |
public String getLocalName(int nodeHandle) |
|
815 |
{ |
|
816 |
return EMPTY_STR; |
|
817 |
} |
|
818 |
||
819 |
public String getPrefix(int nodeHandle) |
|
820 |
{ |
|
821 |
return null; |
|
822 |
} |
|
823 |
||
824 |
public String getNamespaceURI(int nodeHandle) |
|
825 |
{ |
|
826 |
return EMPTY_STR; |
|
827 |
} |
|
828 |
||
829 |
public String getNodeValue(int nodeHandle) |
|
830 |
{ |
|
831 |
return (getNodeIdent(nodeHandle) == RTF_TEXT) ? _text : null; |
|
832 |
} |
|
833 |
||
834 |
public short getNodeType(int nodeHandle) |
|
835 |
{ |
|
836 |
int nodeID = getNodeIdent(nodeHandle); |
|
837 |
if (nodeID == RTF_TEXT) |
|
838 |
return DTM.TEXT_NODE; |
|
839 |
else if (nodeID == RTF_ROOT) |
|
840 |
return DTM.ROOT_NODE; |
|
841 |
else |
|
842 |
return DTM.NULL; |
|
843 |
||
844 |
} |
|
845 |
||
846 |
public short getLevel(int nodeHandle) |
|
847 |
{ |
|
848 |
int nodeID = getNodeIdent(nodeHandle); |
|
849 |
if (nodeID == RTF_TEXT) |
|
850 |
return 2; |
|
851 |
else if (nodeID == RTF_ROOT) |
|
852 |
return 1; |
|
853 |
else |
|
854 |
return DTM.NULL; |
|
855 |
} |
|
856 |
||
857 |
public boolean isSupported(String feature, String version) |
|
858 |
{ |
|
859 |
return false; |
|
860 |
} |
|
861 |
||
862 |
public String getDocumentBaseURI() |
|
863 |
{ |
|
864 |
return EMPTY_STR; |
|
865 |
} |
|
866 |
||
867 |
public void setDocumentBaseURI(String baseURI) |
|
868 |
{ |
|
869 |
} |
|
870 |
||
871 |
public String getDocumentSystemIdentifier(int nodeHandle) |
|
872 |
{ |
|
873 |
return null; |
|
874 |
} |
|
875 |
||
876 |
public String getDocumentEncoding(int nodeHandle) |
|
877 |
{ |
|
878 |
return null; |
|
879 |
} |
|
880 |
||
881 |
public String getDocumentStandalone(int nodeHandle) |
|
882 |
{ |
|
883 |
return null; |
|
884 |
} |
|
885 |
||
886 |
public String getDocumentVersion(int documentHandle) |
|
887 |
{ |
|
888 |
return null; |
|
889 |
} |
|
890 |
||
891 |
public boolean getDocumentAllDeclarationsProcessed() |
|
892 |
{ |
|
893 |
return false; |
|
894 |
} |
|
895 |
||
896 |
public String getDocumentTypeDeclarationSystemIdentifier() |
|
897 |
{ |
|
898 |
return null; |
|
899 |
} |
|
900 |
||
901 |
public String getDocumentTypeDeclarationPublicIdentifier() |
|
902 |
{ |
|
903 |
return null; |
|
904 |
} |
|
905 |
||
906 |
public int getElementById(String elementId) |
|
907 |
{ |
|
908 |
return DTM.NULL; |
|
909 |
} |
|
910 |
||
911 |
public boolean supportsPreStripping() |
|
912 |
{ |
|
913 |
return false; |
|
914 |
} |
|
915 |
||
916 |
public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle) |
|
917 |
{ |
|
918 |
return lessThan(firstNodeHandle, secondNodeHandle); |
|
919 |
} |
|
920 |
||
921 |
public boolean isCharacterElementContentWhitespace(int nodeHandle) |
|
922 |
{ |
|
923 |
return false; |
|
924 |
} |
|
925 |
||
926 |
public boolean isDocumentAllDeclarationsProcessed(int documentHandle) |
|
927 |
{ |
|
928 |
return false; |
|
929 |
} |
|
930 |
||
931 |
public boolean isAttributeSpecified(int attributeHandle) |
|
932 |
{ |
|
933 |
return false; |
|
934 |
} |
|
935 |
||
936 |
public void dispatchCharactersEvents( |
|
937 |
int nodeHandle, |
|
938 |
org.xml.sax.ContentHandler ch, |
|
939 |
boolean normalize) |
|
940 |
throws org.xml.sax.SAXException |
|
941 |
{ |
|
942 |
} |
|
943 |
||
944 |
public void dispatchToEvents(int nodeHandle, org.xml.sax.ContentHandler ch) |
|
945 |
throws org.xml.sax.SAXException |
|
946 |
{ |
|
947 |
} |
|
948 |
||
949 |
public org.w3c.dom.Node getNode(int nodeHandle) |
|
950 |
{ |
|
951 |
return makeNode(nodeHandle); |
|
952 |
} |
|
953 |
||
954 |
public boolean needsTwoThreads() |
|
955 |
{ |
|
956 |
return false; |
|
957 |
} |
|
958 |
||
959 |
public org.xml.sax.ContentHandler getContentHandler() |
|
960 |
{ |
|
961 |
return null; |
|
962 |
} |
|
963 |
||
964 |
public org.xml.sax.ext.LexicalHandler getLexicalHandler() |
|
965 |
{ |
|
966 |
return null; |
|
967 |
} |
|
968 |
||
969 |
public org.xml.sax.EntityResolver getEntityResolver() |
|
970 |
{ |
|
971 |
return null; |
|
972 |
} |
|
973 |
||
974 |
public org.xml.sax.DTDHandler getDTDHandler() |
|
975 |
{ |
|
976 |
return null; |
|
977 |
} |
|
978 |
||
979 |
public org.xml.sax.ErrorHandler getErrorHandler() |
|
980 |
{ |
|
981 |
return null; |
|
982 |
} |
|
983 |
||
984 |
public org.xml.sax.ext.DeclHandler getDeclHandler() |
|
985 |
{ |
|
986 |
return null; |
|
987 |
} |
|
988 |
||
989 |
public void appendChild(int newChild, boolean clone, boolean cloneDepth) |
|
990 |
{ |
|
991 |
} |
|
992 |
||
993 |
public void appendTextChild(String str) |
|
994 |
{ |
|
995 |
} |
|
996 |
||
997 |
public SourceLocator getSourceLocatorFor(int node) |
|
998 |
{ |
|
999 |
return null; |
|
1000 |
} |
|
1001 |
||
1002 |
public void documentRegistration() |
|
1003 |
{ |
|
1004 |
} |
|
1005 |
||
1006 |
public void documentRelease() |
|
1007 |
{ |
|
1008 |
} |
|
1009 |
||
1010 |
public void migrateTo(DTMManager manager) |
|
1011 |
{ |
|
1012 |
} |
|
36486
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1013 |
|
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1014 |
public void release() |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1015 |
{ |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1016 |
if (_documentID != 0) { |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1017 |
_dtmManager.release(this, true); |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1018 |
_documentID = 0; |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1019 |
} |
b84e564d2358
8150704: XALAN: ERROR: 'No more DTM IDs are available' when transforming with lots of temporary result trees
joehw
parents:
33349
diff
changeset
|
1020 |
} |
6 | 1021 |
} |