Source Code Cross Referenced for SimpleResultTreeImpl.java in  » XML » xalan » org » apache » xalan » xsltc » dom » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » XML » xalan » org.apache.xalan.xsltc.dom 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 1999-2004 The Apache Software Foundation.
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        /*
017:         * $Id: SimpleResultTreeImpl.java,v 1.8 2004/12/15 17:35:44 jycli Exp $
018:         */
019:        package org.apache.xalan.xsltc.dom;
020:
021:        import org.apache.xalan.xsltc.DOM;
022:        import org.apache.xalan.xsltc.TransletException;
023:        import org.apache.xalan.xsltc.StripFilter;
024:        import org.apache.xalan.xsltc.runtime.Hashtable;
025:
026:        import org.apache.xml.dtm.DTM;
027:        import org.apache.xml.dtm.Axis;
028:        import org.apache.xml.dtm.DTMAxisIterator;
029:        import org.apache.xml.dtm.DTMAxisTraverser;
030:        import org.apache.xml.dtm.DTMManager;
031:        import org.apache.xml.dtm.ref.DTMAxisIteratorBase;
032:        import org.apache.xml.dtm.ref.DTMManagerDefault;
033:        import org.apache.xml.serializer.EmptySerializer;
034:        import org.apache.xml.serializer.SerializationHandler;
035:        import org.apache.xml.utils.XMLString;
036:        import org.apache.xml.utils.XMLStringDefault;
037:
038:        import org.w3c.dom.Node;
039:        import org.w3c.dom.NodeList;
040:
041:        import org.xml.sax.SAXException;
042:
043:        import javax.xml.transform.SourceLocator;
044:
045:        /**
046:         * This class represents a light-weight DOM model for simple result tree fragment(RTF).
047:         * A simple RTF is an RTF that has only one Text node. The Text node can be produced by a
048:         * combination of Text, xsl:value-of and xsl:number instructions. It can also be produced
049:         * by a control structure (xsl:if or xsl:choose) whose body is pure Text.
050:         * <p>
051:         * A SimpleResultTreeImpl has only two nodes, i.e. the ROOT node and its Text child. All DOM
052:         * interfaces are overridden with this in mind. For example, the getStringValue() interface
053:         * returns the value of the Text node. This class receives the character data from the 
054:         * characters() interface.
055:         * <p>
056:         * This class implements DOM and SerializationHandler. It also implements the DTM interface
057:         * for support in MultiDOM. The nested iterators (SimpleIterator and SingletonIterator) are
058:         * used to support the nodeset() extension function.
059:         */
060:        public class SimpleResultTreeImpl extends EmptySerializer implements 
061:                DOM, DTM {
062:
063:            /**
064:             * The SimpleIterator is designed to support the nodeset() extension function. It has
065:             * a traversal direction parameter. The DOWN direction is used for child and descendant
066:             * axes, while the UP direction is used for parent and ancestor axes.
067:             *
068:             * This iterator only handles two nodes (RTF_ROOT and RTF_TEXT). If the type is set,
069:             * it will also match the node type with the given type.
070:             */
071:            public final class SimpleIterator extends DTMAxisIteratorBase {
072:                static final int DIRECTION_UP = 0;
073:                static final int DIRECTION_DOWN = 1;
074:                static final int NO_TYPE = -1;
075:
076:                // The direction of traversal (default to DOWN).
077:                // DOWN is for child and descendant. UP is for parent and ancestor.
078:                int _direction = DIRECTION_DOWN;
079:
080:                int _type = NO_TYPE;
081:                int _currentNode;
082:
083:                public SimpleIterator() {
084:                }
085:
086:                public SimpleIterator(int direction) {
087:                    _direction = direction;
088:                }
089:
090:                public SimpleIterator(int direction, int type) {
091:                    _direction = direction;
092:                    _type = type;
093:                }
094:
095:                public int next() {
096:                    // Increase the node ID for down traversal. Also match the node type
097:                    // if the type is given.
098:                    if (_direction == DIRECTION_DOWN) {
099:                        while (_currentNode < NUMBER_OF_NODES) {
100:                            if (_type != NO_TYPE) {
101:                                if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
102:                                        || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
103:                                    return returnNode(getNodeHandle(_currentNode++));
104:                                else
105:                                    _currentNode++;
106:                            } else
107:                                return returnNode(getNodeHandle(_currentNode++));
108:                        }
109:
110:                        return END;
111:                    }
112:                    // Decrease the node ID for up traversal.
113:                    else {
114:                        while (_currentNode >= 0) {
115:                            if (_type != NO_TYPE) {
116:                                if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
117:                                        || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
118:                                    return returnNode(getNodeHandle(_currentNode--));
119:                                else
120:                                    _currentNode--;
121:                            } else
122:                                return returnNode(getNodeHandle(_currentNode--));
123:                        }
124:
125:                        return END;
126:                    }
127:                }
128:
129:                public DTMAxisIterator setStartNode(int nodeHandle) {
130:                    int nodeID = getNodeIdent(nodeHandle);
131:                    _startNode = nodeID;
132:
133:                    // Increase the node ID by 1 if self is not included.
134:                    if (!_includeSelf && nodeID != DTM.NULL) {
135:                        if (_direction == DIRECTION_DOWN)
136:                            nodeID++;
137:                        else if (_direction == DIRECTION_UP)
138:                            nodeID--;
139:                    }
140:
141:                    _currentNode = nodeID;
142:                    return this ;
143:                }
144:
145:                public void setMark() {
146:                    _markedNode = _currentNode;
147:                }
148:
149:                public void gotoMark() {
150:                    _currentNode = _markedNode;
151:                }
152:
153:            } // END of SimpleIterator
154:
155:            /**
156:             * The SingletonIterator is used for the self axis.
157:             */
158:            public final class SingletonIterator extends DTMAxisIteratorBase {
159:                static final int NO_TYPE = -1;
160:                int _type = NO_TYPE;
161:                int _currentNode;
162:
163:                public SingletonIterator() {
164:                }
165:
166:                public SingletonIterator(int type) {
167:                    _type = type;
168:                }
169:
170:                public void setMark() {
171:                    _markedNode = _currentNode;
172:                }
173:
174:                public void gotoMark() {
175:                    _currentNode = _markedNode;
176:                }
177:
178:                public DTMAxisIterator setStartNode(int nodeHandle) {
179:                    _currentNode = _startNode = getNodeIdent(nodeHandle);
180:                    return this ;
181:                }
182:
183:                public int next() {
184:                    if (_currentNode == END)
185:                        return END;
186:
187:                    _currentNode = END;
188:
189:                    if (_type != NO_TYPE) {
190:                        if ((_currentNode == RTF_ROOT && _type == DTM.ROOT_NODE)
191:                                || (_currentNode == RTF_TEXT && _type == DTM.TEXT_NODE))
192:                            return getNodeHandle(_currentNode);
193:                    } else
194:                        return getNodeHandle(_currentNode);
195:
196:                    return END;
197:                }
198:
199:            } // END of SingletonIterator
200:
201:            // empty iterator to be returned when there are no children
202:            private final static DTMAxisIterator EMPTY_ITERATOR = new DTMAxisIteratorBase() {
203:                public DTMAxisIterator reset() {
204:                    return this ;
205:                }
206:
207:                public DTMAxisIterator setStartNode(int node) {
208:                    return this ;
209:                }
210:
211:                public int next() {
212:                    return DTM.NULL;
213:                }
214:
215:                public void setMark() {
216:                }
217:
218:                public void gotoMark() {
219:                }
220:
221:                public int getLast() {
222:                    return 0;
223:                }
224:
225:                public int getPosition() {
226:                    return 0;
227:                }
228:
229:                public DTMAxisIterator cloneIterator() {
230:                    return this ;
231:                }
232:
233:                public void setRestartable(boolean isRestartable) {
234:                }
235:            };
236:
237:            // The root node id of the simple RTF
238:            public static final int RTF_ROOT = 0;
239:
240:            // The Text node id of the simple RTF (simple RTF has only one Text node).
241:            public static final int RTF_TEXT = 1;
242:
243:            // The number of nodes.
244:            public static final int NUMBER_OF_NODES = 2;
245:
246:            // Document URI index, which increases by 1 at each getDocumentURI() call.
247:            private static int _documentURIIndex = 0;
248:
249:            // Constant for empty String
250:            private static final String EMPTY_STR = "";
251:
252:            // The String value of the Text node.
253:            // This is set at the endDocument() call.
254:            private String _text;
255:
256:            // The array of Text items, which is built by the characters() call.
257:            // The characters() interface can be called multiple times. Each character item
258:            // can have different escape settings.
259:            protected String[] _textArray;
260:
261:            // The DTMManager
262:            protected XSLTCDTMManager _dtmManager;
263:
264:            // Number of character items
265:            protected int _size = 0;
266:
267:            // The document ID
268:            private int _documentID;
269:
270:            // A BitArray, each bit holding the escape setting for a character item.
271:            private BitArray _dontEscape = null;
272:
273:            // The current escape setting
274:            private boolean _escaping = true;
275:
276:            // Create a SimpleResultTreeImpl from a DTMManager and a document ID.
277:            public SimpleResultTreeImpl(XSLTCDTMManager dtmManager,
278:                    int documentID) {
279:                _dtmManager = dtmManager;
280:                _documentID = documentID;
281:                _textArray = new String[4];
282:            }
283:
284:            public DTMManagerDefault getDTMManager() {
285:                return _dtmManager;
286:            }
287:
288:            // Return the document ID
289:            public int getDocument() {
290:                return _documentID;
291:            }
292:
293:            // Return the String value of the RTF
294:            public String getStringValue() {
295:                return _text;
296:            }
297:
298:            public DTMAxisIterator getIterator() {
299:                return new SingletonIterator(getDocument());
300:            }
301:
302:            public DTMAxisIterator getChildren(final int node) {
303:                return new SimpleIterator().setStartNode(node);
304:            }
305:
306:            public DTMAxisIterator getTypedChildren(final int type) {
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:                switch (axis) {
314:                case Axis.CHILD:
315:                case Axis.DESCENDANT:
316:                    return new SimpleIterator(SimpleIterator.DIRECTION_DOWN);
317:                case Axis.PARENT:
318:                case Axis.ANCESTOR:
319:                    return new SimpleIterator(SimpleIterator.DIRECTION_UP);
320:                case Axis.ANCESTORORSELF:
321:                    return (new SimpleIterator(SimpleIterator.DIRECTION_UP))
322:                            .includeSelf();
323:                case Axis.DESCENDANTORSELF:
324:                    return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN))
325:                            .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,
334:                    final int type) {
335:                switch (axis) {
336:                case Axis.CHILD:
337:                case Axis.DESCENDANT:
338:                    return new SimpleIterator(SimpleIterator.DIRECTION_DOWN,
339:                            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,
345:                            type)).includeSelf();
346:                case Axis.DESCENDANTORSELF:
347:                    return (new SimpleIterator(SimpleIterator.DIRECTION_DOWN,
348:                            type)).includeSelf();
349:                case Axis.SELF:
350:                    return new SingletonIterator(type);
351:                default:
352:                    return EMPTY_ITERATOR;
353:                }
354:            }
355:
356:            // %REVISIT% Can this one ever get used?
357:            public DTMAxisIterator getNthDescendant(int node, int n,
358:                    boolean includeself) {
359:                return null;
360:            }
361:
362:            public DTMAxisIterator getNamespaceAxisIterator(final int axis,
363:                    final int ns) {
364:                return null;
365:            }
366:
367:            // %REVISIT% Can this one ever get used?
368:            public DTMAxisIterator getNodeValueIterator(DTMAxisIterator iter,
369:                    int returnType, String value, boolean op) {
370:                return null;
371:            }
372:
373:            public DTMAxisIterator orderNodes(DTMAxisIterator source, int node) {
374:                return source;
375:            }
376:
377:            public String getNodeName(final int node) {
378:                if (getNodeIdent(node) == RTF_TEXT)
379:                    return "#text";
380:                else
381:                    return EMPTY_STR;
382:            }
383:
384:            public String getNodeNameX(final int node) {
385:                return EMPTY_STR;
386:            }
387:
388:            public String getNamespaceName(final int node) {
389:                return EMPTY_STR;
390:            }
391:
392:            // Return the expanded type id of a given node
393:            public int getExpandedTypeID(final int nodeHandle) {
394:                int nodeID = getNodeIdent(nodeHandle);
395:                if (nodeID == RTF_TEXT)
396:                    return DTM.TEXT_NODE;
397:                else if (nodeID == RTF_ROOT)
398:                    return DTM.ROOT_NODE;
399:                else
400:                    return DTM.NULL;
401:            }
402:
403:            public int getNamespaceType(final int node) {
404:                return 0;
405:            }
406:
407:            public int getParent(final int nodeHandle) {
408:                int nodeID = getNodeIdent(nodeHandle);
409:                return (nodeID == RTF_TEXT) ? getNodeHandle(RTF_ROOT)
410:                        : DTM.NULL;
411:            }
412:
413:            public int getAttributeNode(final int gType, final int element) {
414:                return DTM.NULL;
415:            }
416:
417:            public String getStringValueX(final int nodeHandle) {
418:                int nodeID = getNodeIdent(nodeHandle);
419:                if (nodeID == RTF_ROOT || nodeID == RTF_TEXT)
420:                    return _text;
421:                else
422:                    return EMPTY_STR;
423:            }
424:
425:            public void copy(final int node, SerializationHandler handler)
426:                    throws TransletException {
427:                characters(node, handler);
428:            }
429:
430:            public void copy(DTMAxisIterator nodes, SerializationHandler handler)
431:                    throws TransletException {
432:                int node;
433:                while ((node = nodes.next()) != DTM.NULL) {
434:                    copy(node, handler);
435:                }
436:            }
437:
438:            public String shallowCopy(final int node,
439:                    SerializationHandler handler) throws TransletException {
440:                characters(node, handler);
441:                return null;
442:            }
443:
444:            public boolean lessThan(final int node1, final int node2) {
445:                if (node1 == DTM.NULL) {
446:                    return false;
447:                } else if (node2 == DTM.NULL) {
448:                    return true;
449:                } else
450:                    return (node1 < node2);
451:            }
452:
453:            /**
454:             * Dispatch the character content of a node to an output handler.
455:             *
456:             * The escape setting should be taken care of when outputting to
457:             * a handler.
458:             */
459:            public void characters(final int node, SerializationHandler handler)
460:                    throws TransletException {
461:                int nodeID = getNodeIdent(node);
462:                if (nodeID == RTF_ROOT || nodeID == RTF_TEXT) {
463:                    boolean escapeBit = false;
464:                    boolean oldEscapeSetting = false;
465:
466:                    try {
467:                        for (int i = 0; i < _size; i++) {
468:
469:                            if (_dontEscape != null) {
470:                                escapeBit = _dontEscape.getBit(i);
471:                                if (escapeBit) {
472:                                    oldEscapeSetting = handler
473:                                            .setEscaping(false);
474:                                }
475:                            }
476:
477:                            handler.characters(_textArray[i]);
478:
479:                            if (escapeBit) {
480:                                handler.setEscaping(oldEscapeSetting);
481:                            }
482:                        }
483:                    } catch (SAXException e) {
484:                        throw new TransletException(e);
485:                    }
486:                }
487:            }
488:
489:            // %REVISIT% Can the makeNode() and makeNodeList() interfaces ever get used?
490:            public Node makeNode(int index) {
491:                return null;
492:            }
493:
494:            public Node makeNode(DTMAxisIterator iter) {
495:                return null;
496:            }
497:
498:            public NodeList makeNodeList(int index) {
499:                return null;
500:            }
501:
502:            public NodeList makeNodeList(DTMAxisIterator iter) {
503:                return null;
504:            }
505:
506:            public String getLanguage(int node) {
507:                return null;
508:            }
509:
510:            public int getSize() {
511:                return 2;
512:            }
513:
514:            public String getDocumentURI(int node) {
515:                return "simple_rtf" + _documentURIIndex++;
516:            }
517:
518:            public void setFilter(StripFilter filter) {
519:            }
520:
521:            public void setupMapping(String[] names, String[] uris,
522:                    int[] types, String[] namespaces) {
523:            }
524:
525:            public boolean isElement(final int node) {
526:                return false;
527:            }
528:
529:            public boolean isAttribute(final int node) {
530:                return false;
531:            }
532:
533:            public String lookupNamespace(int node, String prefix)
534:                    throws TransletException {
535:                return null;
536:            }
537:
538:            /**
539:             * Return the node identity from a node handle.
540:             */
541:            public int getNodeIdent(final int nodehandle) {
542:                return (nodehandle != DTM.NULL) ? (nodehandle - _documentID)
543:                        : DTM.NULL;
544:            }
545:
546:            /**
547:             * Return the node handle from a node identity.
548:             */
549:            public int getNodeHandle(final int nodeId) {
550:                return (nodeId != DTM.NULL) ? (nodeId + _documentID) : DTM.NULL;
551:            }
552:
553:            public DOM getResultTreeFrag(int initialSize, int rtfType) {
554:                return null;
555:            }
556:
557:            public DOM getResultTreeFrag(int initialSize, int rtfType,
558:                    boolean addToManager) {
559:                return null;
560:            }
561:
562:            public SerializationHandler getOutputDomBuilder() {
563:                return this ;
564:            }
565:
566:            public int getNSType(int node) {
567:                return 0;
568:            }
569:
570:            public String getUnparsedEntityURI(String name) {
571:                return null;
572:            }
573:
574:            public Hashtable getElementsWithIDs() {
575:                return null;
576:            }
577:
578:            /** Implementation of the SerializationHandler interfaces **/
579:
580:            /**
581:             * We only need to override the endDocument, characters, and 
582:             * setEscaping interfaces. A simple RTF does not have element
583:             * nodes. We do not need to touch startElement and endElement.
584:             */
585:
586:            public void startDocument() throws SAXException {
587:
588:            }
589:
590:            public void endDocument() throws SAXException {
591:                // Set the String value when the document is built.
592:                if (_size == 1)
593:                    _text = _textArray[0];
594:                else {
595:                    StringBuffer buffer = new StringBuffer();
596:                    for (int i = 0; i < _size; i++) {
597:                        buffer.append(_textArray[i]);
598:                    }
599:                    _text = buffer.toString();
600:                }
601:            }
602:
603:            public void characters(String str) throws SAXException {
604:                // Resize the text array if necessary
605:                if (_size >= _textArray.length) {
606:                    String[] newTextArray = new String[_textArray.length * 2];
607:                    System.arraycopy(_textArray, 0, newTextArray, 0,
608:                            _textArray.length);
609:                    _textArray = newTextArray;
610:                }
611:
612:                // If the escape setting is false, set the corresponding bit in
613:                // the _dontEscape BitArray.
614:                if (!_escaping) {
615:                    // The _dontEscape array is only created when needed.
616:                    if (_dontEscape == null) {
617:                        _dontEscape = new BitArray(8);
618:                    }
619:
620:                    // Resize the _dontEscape array if necessary
621:                    if (_size >= _dontEscape.size())
622:                        _dontEscape.resize(_dontEscape.size() * 2);
623:
624:                    _dontEscape.setBit(_size);
625:                }
626:
627:                _textArray[_size++] = str;
628:            }
629:
630:            public void characters(char[] ch, int offset, int length)
631:                    throws SAXException {
632:                if (_size >= _textArray.length) {
633:                    String[] newTextArray = new String[_textArray.length * 2];
634:                    System.arraycopy(_textArray, 0, newTextArray, 0,
635:                            _textArray.length);
636:                    _textArray = newTextArray;
637:                }
638:
639:                if (!_escaping) {
640:                    if (_dontEscape == null) {
641:                        _dontEscape = new BitArray(8);
642:                    }
643:
644:                    if (_size >= _dontEscape.size())
645:                        _dontEscape.resize(_dontEscape.size() * 2);
646:
647:                    _dontEscape.setBit(_size);
648:                }
649:
650:                _textArray[_size++] = new String(ch, offset, length);
651:
652:            }
653:
654:            public boolean setEscaping(boolean escape) throws SAXException {
655:                final boolean temp = _escaping;
656:                _escaping = escape;
657:                return temp;
658:            }
659:
660:            /** Implementation of the DTM interfaces **/
661:
662:            /**
663:             * The DTM interfaces are not used in this class. Implementing the DTM
664:             * interface is a requirement from MultiDOM. If we have a better way
665:             * of handling multiple documents, we can get rid of the DTM dependency.
666:             *
667:             * The following interfaces are just placeholders. The implementation
668:             * does not have an impact because they will not be used.
669:             */
670:
671:            public void setFeature(String featureId, boolean state) {
672:            }
673:
674:            public void setProperty(String property, Object value) {
675:            }
676:
677:            public DTMAxisTraverser getAxisTraverser(final int axis) {
678:                return null;
679:            }
680:
681:            public boolean hasChildNodes(int nodeHandle) {
682:                return (getNodeIdent(nodeHandle) == RTF_ROOT);
683:            }
684:
685:            public int getFirstChild(int nodeHandle) {
686:                int nodeID = getNodeIdent(nodeHandle);
687:                if (nodeID == RTF_ROOT)
688:                    return getNodeHandle(RTF_TEXT);
689:                else
690:                    return DTM.NULL;
691:            }
692:
693:            public int getLastChild(int nodeHandle) {
694:                return getFirstChild(nodeHandle);
695:            }
696:
697:            public int getAttributeNode(int elementHandle, String namespaceURI,
698:                    String name) {
699:                return DTM.NULL;
700:            }
701:
702:            public int getFirstAttribute(int nodeHandle) {
703:                return DTM.NULL;
704:            }
705:
706:            public int getFirstNamespaceNode(int nodeHandle, boolean inScope) {
707:                return DTM.NULL;
708:            }
709:
710:            public int getNextSibling(int nodeHandle) {
711:                return DTM.NULL;
712:            }
713:
714:            public int getPreviousSibling(int nodeHandle) {
715:                return DTM.NULL;
716:            }
717:
718:            public int getNextAttribute(int nodeHandle) {
719:                return DTM.NULL;
720:            }
721:
722:            public int getNextNamespaceNode(int baseHandle,
723:                    int namespaceHandle, boolean inScope) {
724:                return DTM.NULL;
725:            }
726:
727:            public int getOwnerDocument(int nodeHandle) {
728:                return getDocument();
729:            }
730:
731:            public int getDocumentRoot(int nodeHandle) {
732:                return getDocument();
733:            }
734:
735:            public XMLString getStringValue(int nodeHandle) {
736:                return new XMLStringDefault(getStringValueX(nodeHandle));
737:            }
738:
739:            public int getStringValueChunkCount(int nodeHandle) {
740:                return 0;
741:            }
742:
743:            public char[] getStringValueChunk(int nodeHandle, int chunkIndex,
744:                    int[] startAndLen) {
745:                return null;
746:            }
747:
748:            public int getExpandedTypeID(String namespace, String localName,
749:                    int type) {
750:                return DTM.NULL;
751:            }
752:
753:            public String getLocalNameFromExpandedNameID(int ExpandedNameID) {
754:                return EMPTY_STR;
755:            }
756:
757:            public String getNamespaceFromExpandedNameID(int ExpandedNameID) {
758:                return EMPTY_STR;
759:            }
760:
761:            public String getLocalName(int nodeHandle) {
762:                return EMPTY_STR;
763:            }
764:
765:            public String getPrefix(int nodeHandle) {
766:                return null;
767:            }
768:
769:            public String getNamespaceURI(int nodeHandle) {
770:                return EMPTY_STR;
771:            }
772:
773:            public String getNodeValue(int nodeHandle) {
774:                return (getNodeIdent(nodeHandle) == RTF_TEXT) ? _text : null;
775:            }
776:
777:            public short getNodeType(int nodeHandle) {
778:                int nodeID = getNodeIdent(nodeHandle);
779:                if (nodeID == RTF_TEXT)
780:                    return DTM.TEXT_NODE;
781:                else if (nodeID == RTF_ROOT)
782:                    return DTM.ROOT_NODE;
783:                else
784:                    return DTM.NULL;
785:
786:            }
787:
788:            public short getLevel(int nodeHandle) {
789:                int nodeID = getNodeIdent(nodeHandle);
790:                if (nodeID == RTF_TEXT)
791:                    return 2;
792:                else if (nodeID == RTF_ROOT)
793:                    return 1;
794:                else
795:                    return DTM.NULL;
796:            }
797:
798:            public boolean isSupported(String feature, String version) {
799:                return false;
800:            }
801:
802:            public String getDocumentBaseURI() {
803:                return EMPTY_STR;
804:            }
805:
806:            public void setDocumentBaseURI(String baseURI) {
807:            }
808:
809:            public String getDocumentSystemIdentifier(int nodeHandle) {
810:                return null;
811:            }
812:
813:            public String getDocumentEncoding(int nodeHandle) {
814:                return null;
815:            }
816:
817:            public String getDocumentStandalone(int nodeHandle) {
818:                return null;
819:            }
820:
821:            public String getDocumentVersion(int documentHandle) {
822:                return null;
823:            }
824:
825:            public boolean getDocumentAllDeclarationsProcessed() {
826:                return false;
827:            }
828:
829:            public String getDocumentTypeDeclarationSystemIdentifier() {
830:                return null;
831:            }
832:
833:            public String getDocumentTypeDeclarationPublicIdentifier() {
834:                return null;
835:            }
836:
837:            public int getElementById(String elementId) {
838:                return DTM.NULL;
839:            }
840:
841:            public boolean supportsPreStripping() {
842:                return false;
843:            }
844:
845:            public boolean isNodeAfter(int firstNodeHandle, int secondNodeHandle) {
846:                return lessThan(firstNodeHandle, secondNodeHandle);
847:            }
848:
849:            public boolean isCharacterElementContentWhitespace(int nodeHandle) {
850:                return false;
851:            }
852:
853:            public boolean isDocumentAllDeclarationsProcessed(int documentHandle) {
854:                return false;
855:            }
856:
857:            public boolean isAttributeSpecified(int attributeHandle) {
858:                return false;
859:            }
860:
861:            public void dispatchCharactersEvents(int nodeHandle,
862:                    org.xml.sax.ContentHandler ch, boolean normalize)
863:                    throws org.xml.sax.SAXException {
864:            }
865:
866:            public void dispatchToEvents(int nodeHandle,
867:                    org.xml.sax.ContentHandler ch)
868:                    throws org.xml.sax.SAXException {
869:            }
870:
871:            public org.w3c.dom.Node getNode(int nodeHandle) {
872:                return makeNode(nodeHandle);
873:            }
874:
875:            public boolean needsTwoThreads() {
876:                return false;
877:            }
878:
879:            public org.xml.sax.ContentHandler getContentHandler() {
880:                return null;
881:            }
882:
883:            public org.xml.sax.ext.LexicalHandler getLexicalHandler() {
884:                return null;
885:            }
886:
887:            public org.xml.sax.EntityResolver getEntityResolver() {
888:                return null;
889:            }
890:
891:            public org.xml.sax.DTDHandler getDTDHandler() {
892:                return null;
893:            }
894:
895:            public org.xml.sax.ErrorHandler getErrorHandler() {
896:                return null;
897:            }
898:
899:            public org.xml.sax.ext.DeclHandler getDeclHandler() {
900:                return null;
901:            }
902:
903:            public void appendChild(int newChild, boolean clone,
904:                    boolean cloneDepth) {
905:            }
906:
907:            public void appendTextChild(String str) {
908:            }
909:
910:            public SourceLocator getSourceLocatorFor(int node) {
911:                return null;
912:            }
913:
914:            public void documentRegistration() {
915:            }
916:
917:            public void documentRelease() {
918:            }
919:
920:            public void migrateTo(DTMManager manager) {
921:            }
922:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.