Source Code Cross Referenced for TreeReceiver.java in  » XML » saxonb » net » sf » saxon » event » 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 » saxonb » net.sf.saxon.event 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.saxon.event;
002:
003:        import net.sf.saxon.om.*;
004:        import net.sf.saxon.trans.XPathException;
005:        import net.sf.saxon.value.AtomicValue;
006:        import net.sf.saxon.type.Type;
007:
008:        /**
009:         * A TreeReceiver acts as a bridge between a SequenceReceiver, which can receive
010:         * events for constructing any kind of sequence, and an ordinary Receiver, which
011:         * only handles events relating to the building of trees. To do this, it has to
012:         * process any items added to the sequence using the append() interface; all other
013:         * events are passed through unchanged.
014:         */
015:
016:        public class TreeReceiver extends SequenceReceiver {
017:            private Receiver baseReceiver;
018:            private String systemId;
019:            private boolean contentStarted = true;
020:
021:            public TreeReceiver(Receiver nextInChain) {
022:                baseReceiver = nextInChain;
023:                previousAtomic = false;
024:                setPipelineConfiguration(nextInChain.getPipelineConfiguration());
025:            }
026:
027:            public void setSystemId(String systemId) {
028:                if (systemId != this .systemId) {
029:                    this .systemId = systemId;
030:                    if (baseReceiver != null) {
031:                        baseReceiver.setSystemId(systemId);
032:                    }
033:                }
034:            }
035:
036:            public String getSystemId() {
037:                return systemId;
038:            }
039:
040:            /**
041:             * Get the underlying Receiver (that is, the next one in the pipeline)
042:             */
043:
044:            public Receiver getUnderlyingReceiver() {
045:                return baseReceiver;
046:            }
047:
048:            /**
049:             * Start of event sequence
050:             */
051:
052:            public void open() throws XPathException {
053:                if (baseReceiver == null) {
054:                    throw new IllegalStateException(
055:                            "TreeReceiver.open(): no underlying receiver provided");
056:                }
057:                baseReceiver.open();
058:                previousAtomic = false;
059:            }
060:
061:            /**
062:             * End of event sequence
063:             */
064:
065:            public void close() throws XPathException {
066:                if (baseReceiver != null) {
067:                    baseReceiver.close();
068:                }
069:                previousAtomic = false;
070:            }
071:
072:            /**
073:             * Start of a document node.
074:             */
075:
076:            public void startDocument(int properties) throws XPathException {
077:                baseReceiver.startDocument(properties);
078:            }
079:
080:            /**
081:             * Notify the end of a document node
082:             */
083:
084:            public void endDocument() throws XPathException {
085:                baseReceiver.endDocument();
086:            }
087:
088:            /**
089:             * Notify the start of an element
090:             * @param nameCode integer code identifying the name of the element within the name pool.
091:             * @param typeCode integer code identifying the element's type within the name pool.
092:             * @param properties bit-significant properties of the element node
093:             */
094:
095:            public void startElement(int nameCode, int typeCode,
096:                    int locationId, int properties) throws XPathException {
097:                if (!contentStarted) {
098:                    startContent();
099:                }
100:                contentStarted = false;
101:                baseReceiver.startElement(nameCode, typeCode, locationId,
102:                        properties);
103:                previousAtomic = false;
104:            }
105:
106:            /**
107:             * Notify a namespace. Namespaces are notified <b>after</b> the startElement event, and before
108:             * any children for the element. The namespaces that are reported are only required
109:             * to include those that are different from the parent element; however, duplicates may be reported.
110:             * A namespace must not conflict with any namespaces already used for element or attribute names.
111:             * @param namespaceCode an integer: the top half is a prefix code, the bottom half a URI code.
112:             * These may be translated into an actual prefix and URI using the name pool. A prefix code of
113:             * zero represents the empty prefix (that is, the default namespace). A URI code of zero represents
114:             * a URI of "", that is, a namespace undeclaration.
115:             * @throws IllegalStateException: attempt to output a namespace when there is no open element
116:             * start tag
117:             */
118:
119:            public void namespace(int namespaceCode, int properties)
120:                    throws XPathException {
121:                baseReceiver.namespace(namespaceCode, properties);
122:                previousAtomic = false;
123:            }
124:
125:            /**
126:             * Notify an attribute. Attributes are notified after the startElement event, and before any
127:             * children. Namespaces and attributes may be intermingled.
128:             * @param nameCode The name of the attribute, as held in the name pool
129:             * @param typeCode The type of the attribute, as held in the name pool
130:             * @param properties Bit significant value. The following bits are defined:
131:             *        <dd>DISABLE_ESCAPING</dd>    <dt>Disable escaping for this attribute</dt>
132:             *        <dd>NO_SPECIAL_CHARACTERS</dd>      <dt>Attribute value contains no special characters</dt>
133:             * @throws IllegalStateException: attempt to output an attribute when there is no open element
134:             * start tag
135:             */
136:
137:            public void attribute(int nameCode, int typeCode,
138:                    CharSequence value, int locationId, int properties)
139:                    throws XPathException {
140:                baseReceiver.attribute(nameCode, typeCode, value, locationId,
141:                        properties);
142:                previousAtomic = false;
143:            }
144:
145:            /**
146:             * Notify the start of the content, that is, the completion of all attributes and namespaces.
147:             * Note that the initial receiver of output from XSLT instructions will not receive this event,
148:             * it has to detect it itself. Note that this event is reported for every element even if it has
149:             * no attributes, no namespaces, and no content.
150:             */
151:
152:            public void startContent() throws XPathException {
153:                contentStarted = true;
154:                baseReceiver.startContent();
155:                previousAtomic = false;
156:            }
157:
158:            /**
159:             * End of element
160:             */
161:
162:            public void endElement() throws XPathException {
163:                if (!contentStarted) {
164:                    startContent();
165:                }
166:                baseReceiver.endElement();
167:                previousAtomic = false;
168:            }
169:
170:            /**
171:             * Character data
172:             */
173:
174:            public void characters(CharSequence chars, int locationId,
175:                    int properties) throws XPathException {
176:                if (!contentStarted) {
177:                    startContent();
178:                }
179:                baseReceiver.characters(chars, locationId, properties);
180:                previousAtomic = false;
181:            }
182:
183:            /**
184:             * Processing Instruction
185:             */
186:
187:            public void processingInstruction(String target, CharSequence data,
188:                    int locationId, int properties) throws XPathException {
189:                if (!contentStarted) {
190:                    startContent();
191:                }
192:                baseReceiver.processingInstruction(target, data, locationId,
193:                        properties);
194:                previousAtomic = false;
195:            }
196:
197:            /**
198:             * Output a comment
199:             */
200:
201:            public void comment(CharSequence chars, int locationId,
202:                    int properties) throws XPathException {
203:                if (!contentStarted) {
204:                    startContent();
205:                }
206:                baseReceiver.comment(chars, locationId, properties);
207:                previousAtomic = false;
208:            }
209:
210:            /**
211:             * Set the URI for an unparsed entity in the document.
212:             */
213:
214:            public void setUnparsedEntity(String name, String uri,
215:                    String publicId) throws XPathException {
216:                baseReceiver.setUnparsedEntity(name, uri, publicId);
217:            }
218:
219:            /**
220:             * Append an arbitrary item (node or atomic value) to the output
221:             */
222:
223:            public void append(Item item, int locationId, int copyNamespaces)
224:                    throws XPathException {
225:                if (item instanceof  AtomicValue) {
226:                    if (previousAtomic) {
227:                        characters(" ", locationId, 0);
228:                    }
229:                    characters(item.getStringValueCS(), locationId, 0);
230:                    previousAtomic = true;
231:                } else if (((NodeInfo) item).getNodeKind() == Type.DOCUMENT) {
232:                    SequenceIterator iter = ((NodeInfo) item)
233:                            .iterateAxis(Axis.CHILD);
234:                    while (true) {
235:                        Item it = iter.next();
236:                        if (it == null)
237:                            break;
238:                        append(it, locationId, NodeInfo.ALL_NAMESPACES);
239:                    }
240:                } else {
241:                    ((NodeInfo) item).copy(this , NodeInfo.ALL_NAMESPACES, true,
242:                            locationId);
243:                    previousAtomic = false;
244:                }
245:            }
246:
247:        }
248:
249:        //
250:        // The contents of this file are subject to the Mozilla Public License Version 1.0 (the "License");
251:        // you may not use this file except in compliance with the License. You may obtain a copy of the
252:        // License at http://www.mozilla.org/MPL/
253:        //
254:        // Software distributed under the License is distributed on an "AS IS" basis,
255:        // WITHOUT WARRANTY OF ANY KIND, either express or implied.
256:        // See the License for the specific language governing rights and limitations under the License.
257:        //
258:        // The Original Code is: all this file.
259:        //
260:        // The Initial Developer of the Original Code is Michael H. Kay
261:        //
262:        // Portions created by (your name) are Copyright (C) (your legal entity). All Rights Reserved.
263:        //
264:        // Contributor(s): none.
265:        //
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.