Source Code Cross Referenced for AbstractDOMTransformer.java in  » Content-Management-System » apache-lenya-2.0 » org » apache » cocoon » transformation » 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 » Content Management System » apache lenya 2.0 » org.apache.cocoon.transformation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.cocoon.transformation;
018:
019:        import org.apache.avalon.framework.activity.Disposable;
020:        import org.apache.avalon.framework.component.ComponentManager;
021:        import org.apache.avalon.framework.component.Composable;
022:        import org.apache.avalon.framework.parameters.Parameters;
023:
024:        import org.apache.cocoon.ProcessingException;
025:        import org.apache.cocoon.environment.SourceResolver;
026:        import org.apache.cocoon.xml.dom.DOMBuilder;
027:        import org.apache.cocoon.xml.dom.DOMStreamer;
028:
029:        import org.w3c.dom.Document;
030:        import org.xml.sax.SAXException;
031:        import org.xml.sax.Locator;
032:        import org.xml.sax.Attributes;
033:
034:        import java.io.IOException;
035:        import java.util.Map;
036:
037:        /**
038:         * An Abstract DOM Transformer, for use when a transformer needs a DOM-based
039:         * view of the document.
040:         * Subclass this interface and implement <code>transform(Document doc)</code>.
041:         * If you need a ComponentManager there is an instance variable
042:         * <code>manager</code> for use.
043:         *
044:         * @author <a href="mailto:rossb@apache.org">Ross Burton</a>
045:         * @author <a href="mailto:brobertson@mta.ca">Bruce G. Robertson</a>
046:         * @author <a href="mailto:vgritsenko@apache.org">Vadim Gritsenko</a>
047:         * @version CVS $Id: AbstractDOMTransformer.java 433543 2006-08-22 06:22:54Z crossley $
048:         */
049:        public abstract class AbstractDOMTransformer extends
050:                AbstractTransformer implements  DOMBuilder.Listener, Composable,
051:                Disposable {
052:
053:            /**
054:             *  The SAX entity resolver
055:             */
056:            protected SourceResolver resolver;
057:
058:            /**
059:             *  The request object model
060:             */
061:            protected Map objectModel;
062:
063:            /**
064:             *  The URI requested
065:             */
066:            protected String source;
067:
068:            /**
069:             *  Parameters in the sitemap
070:             */
071:            protected Parameters parameters;
072:
073:            /**
074:             * A <code>ComponentManager</code> which is available for use.
075:             */
076:            protected ComponentManager manager;
077:
078:            /**
079:             * The <code>DOMBuilder</code> used to build DOM tree out of
080:             *incoming SAX events.
081:             */
082:            protected DOMBuilder builder;
083:
084:            public AbstractDOMTransformer() {
085:                super ();
086:                this .builder = new DOMBuilder(this );
087:            }
088:
089:            /**
090:             * Set the component manager.
091:             */
092:            public void compose(ComponentManager manager) {
093:                this .manager = manager;
094:            }
095:
096:            /**
097:             * Set the <code>SourceResolver</code>, objectModel <code>Map</code>,
098:             * the source and sitemap <code>Parameters</code> used to process the request.
099:             *
100:             * If you wish to process the parameters, override this method, call
101:             * <code>super()</code> and then add your code.
102:             */
103:            public void setup(SourceResolver resolver, Map objectModel,
104:                    String src, Parameters par) throws ProcessingException,
105:                    SAXException, IOException {
106:
107:                this .resolver = resolver;
108:                this .objectModel = objectModel;
109:                this .source = src;
110:                this .parameters = par;
111:            }
112:
113:            /**
114:             * Recycle the component.
115:             */
116:            public void recycle() {
117:                this .resolver = null;
118:                this .source = null;
119:                this .objectModel = null;
120:                this .parameters = null;
121:                this .builder.recycle();
122:            }
123:
124:            /**
125:             * dispose
126:             */
127:            public void dispose() {
128:                this .builder = null;
129:                this .manager = null;
130:            }
131:
132:            /**
133:             * This method is called when the Document is finished.
134:             * @param doc The DOM Document object representing this SAX stream
135:             * @see org.apache.cocoon.xml.dom.DOMBuilder.Listener
136:             */
137:            public void notify(Document doc) throws SAXException {
138:                // Call the user's transform method
139:                Document newdoc = transform(doc);
140:
141:                // Now we stream the resulting DOM tree down the pipe
142:                DOMStreamer s = new DOMStreamer(contentHandler, lexicalHandler);
143:                s.stream(newdoc);
144:            }
145:
146:            /**
147:             * Transform the specified DOM, returning a new DOM to stream down the pipeline.
148:             * @param doc The DOM Document representing the SAX stream
149:             * @return A DOM Document to stream down the pipeline
150:             */
151:            protected abstract Document transform(Document doc);
152:
153:            //
154:            // SAX Methods. Send incoming SAX events to the DOMBuilder.
155:            //
156:
157:            public void setDocumentLocator(Locator locator) {
158:                builder.setDocumentLocator(locator);
159:            }
160:
161:            public void startDocument() throws SAXException {
162:                builder.startDocument();
163:            }
164:
165:            public void endDocument() throws SAXException {
166:                builder.endDocument();
167:            }
168:
169:            public void startPrefixMapping(String prefix, String uri)
170:                    throws SAXException {
171:                builder.startPrefixMapping(prefix, uri);
172:            }
173:
174:            public void endPrefixMapping(String prefix) throws SAXException {
175:                builder.endPrefixMapping(prefix);
176:            }
177:
178:            public void startElement(String uri, String loc, String raw,
179:                    Attributes a) throws SAXException {
180:                builder.startElement(uri, loc, raw, a);
181:            }
182:
183:            public void endElement(String uri, String loc, String raw)
184:                    throws SAXException {
185:                builder.endElement(uri, loc, raw);
186:            }
187:
188:            public void characters(char c[], int start, int len)
189:                    throws SAXException {
190:                builder.characters(c, start, len);
191:            }
192:
193:            public void ignorableWhitespace(char c[], int start, int len)
194:                    throws SAXException {
195:                builder.ignorableWhitespace(c, start, len);
196:            }
197:
198:            public void processingInstruction(String target, String data)
199:                    throws SAXException {
200:                builder.processingInstruction(target, data);
201:            }
202:
203:            public void skippedEntity(String name) throws SAXException {
204:                builder.skippedEntity(name);
205:            }
206:
207:            public void startDTD(String name, String publicId, String systemId)
208:                    throws SAXException {
209:                builder.startDTD(name, publicId, systemId);
210:            }
211:
212:            public void endDTD() throws SAXException {
213:                builder.endDTD();
214:            }
215:
216:            public void startEntity(String name) throws SAXException {
217:                builder.startEntity(name);
218:            }
219:
220:            public void endEntity(String name) throws SAXException {
221:                builder.endEntity(name);
222:            }
223:
224:            public void startCDATA() throws SAXException {
225:                builder.startCDATA();
226:            }
227:
228:            public void endCDATA() throws SAXException {
229:                builder.endCDATA();
230:            }
231:
232:            public void comment(char ch[], int start, int len)
233:                    throws SAXException {
234:                builder.comment(ch, start, len);
235:            }
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.