Source Code Cross Referenced for XMLInputFactoryImpl.java in  » EJB-Server-resin-3.1.5 » resin » com » caucho » xml » stream » 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 » EJB Server resin 3.1.5 » resin » com.caucho.xml.stream 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
003:         *
004:         * This file is part of Resin(R) Open Source
005:         *
006:         * Each copy or derived work must preserve the copyright notice and this
007:         * notice unmodified.
008:         *
009:         * Resin Open Source is free software; you can redistribute it and/or modify
010:         * it under the terms of the GNU General Public License as published by
011:         * the Free Software Foundation; either version 2 of the License, or
012:         * (at your option) any later version.
013:         *
014:         * Resin Open Source is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017:         * of NON-INFRINGEMENT.  See the GNU General Public License for more
018:         * details.
019:         *
020:         * You should have received a copy of the GNU General Public License
021:         * along with Resin Open Source; if not, write to the
022:         *
023:         *   Free Software Foundation, Inc.
024:         *   59 Temple Place, Suite 330
025:         *   Boston, MA 02111-1307  USA
026:         *
027:         * @author Adam Megacz
028:         */
029:
030:        package com.caucho.xml.stream;
031:
032:        import javax.xml.stream.*;
033:        import javax.xml.stream.util.XMLEventAllocator;
034:        import javax.xml.transform.Source;
035:        import javax.xml.transform.dom.DOMSource;
036:        import javax.xml.transform.sax.SAXSource;
037:        import javax.xml.transform.stream.StreamSource;
038:        import java.io.IOException;
039:        import java.io.InputStream;
040:        import java.io.InputStreamReader;
041:        import java.io.Reader;
042:        import java.net.MalformedURLException;
043:        import java.net.URL;
044:
045:        public class XMLInputFactoryImpl extends XMLInputFactory {
046:
047:            private XMLEventAllocator _allocator = new XMLEventAllocatorImpl();
048:            private XMLReporter _reporter;
049:            private XMLResolver _resolver;
050:
051:            public XMLInputFactoryImpl() {
052:            }
053:
054:            //
055:            // Filtered
056:            //
057:
058:            public XMLEventReader createFilteredReader(XMLEventReader reader,
059:                    EventFilter filter) throws XMLStreamException {
060:                return new FilteredEventReader(reader, filter);
061:            }
062:
063:            public XMLStreamReader createFilteredReader(XMLStreamReader reader,
064:                    StreamFilter filter) throws XMLStreamException {
065:                return new FilteredStreamReader(reader, filter);
066:            }
067:
068:            //
069:            // Event reader
070:            //
071:
072:            public XMLEventReader createXMLEventReader(InputStream stream)
073:                    throws XMLStreamException {
074:                return new XMLEventReaderImpl(getEventAllocator(),
075:                        createXMLStreamReader(stream));
076:            }
077:
078:            public XMLEventReader createXMLEventReader(InputStream stream,
079:                    String encoding) throws XMLStreamException {
080:                return new XMLEventReaderImpl(getEventAllocator(),
081:                        createXMLStreamReader(stream, encoding));
082:            }
083:
084:            public XMLEventReader createXMLEventReader(Reader reader)
085:                    throws XMLStreamException {
086:                return new XMLEventReaderImpl(getEventAllocator(),
087:                        createXMLStreamReader(reader));
088:            }
089:
090:            /**
091:             *  "Support of this method is optional."
092:             */
093:            public XMLEventReader createXMLEventReader(Source source)
094:                    throws XMLStreamException {
095:                if (source instanceof  SAXSource)
096:                    return new SAXSourceXMLEventReaderImpl((SAXSource) source);
097:
098:                return new XMLEventReaderImpl(getEventAllocator(),
099:                        createXMLStreamReader(source));
100:            }
101:
102:            public XMLEventReader createXMLEventReader(String systemId,
103:                    InputStream stream) throws XMLStreamException {
104:                return new XMLEventReaderImpl(getEventAllocator(),
105:                        createXMLStreamReader(systemId, stream));
106:            }
107:
108:            public XMLEventReader createXMLEventReader(String systemId,
109:                    Reader reader) throws XMLStreamException {
110:                return new XMLEventReaderImpl(getEventAllocator(),
111:                        createXMLStreamReader(systemId, reader));
112:            }
113:
114:            public XMLEventReader createXMLEventReader(XMLStreamReader reader)
115:                    throws XMLStreamException {
116:                return new XMLEventReaderImpl(getEventAllocator(), reader);
117:            }
118:
119:            //
120:            // Stream reader
121:            //
122:
123:            public XMLStreamReader createXMLStreamReader(InputStream stream)
124:                    throws XMLStreamException {
125:                return new XMLStreamReaderImpl(stream);
126:            }
127:
128:            public XMLStreamReader createXMLStreamReader(InputStream stream,
129:                    String encoding) throws XMLStreamException {
130:                if (encoding == null)
131:                    encoding = "iso-8859-1";
132:
133:                try {
134:                    InputStreamReader isr = new InputStreamReader(stream,
135:                            encoding);
136:                    return new XMLStreamReaderImpl(isr);
137:                } catch (IOException e) {
138:                    throw new XMLStreamException(e);
139:                }
140:            }
141:
142:            public XMLStreamReader createXMLStreamReader(Reader reader)
143:                    throws XMLStreamException {
144:                return new XMLStreamReaderImpl(reader);
145:            }
146:
147:            /**
148:             *  "Support of this method is optional."
149:             */
150:            public XMLStreamReader createXMLStreamReader(Source source)
151:                    throws XMLStreamException {
152:                if (source instanceof  StreamSource) {
153:                    StreamSource streamSource = (StreamSource) source;
154:
155:                    InputStream is = streamSource.getInputStream();
156:
157:                    if (is != null)
158:                        return new XMLStreamReaderImpl(is);
159:
160:                    Reader r = streamSource.getReader();
161:
162:                    if (r != null)
163:                        return new XMLStreamReaderImpl(r);
164:
165:                    if (streamSource.getSystemId() != null) {
166:                        try {
167:                            URL url = new URL(streamSource.getSystemId());
168:
169:                            return new XMLStreamReaderImpl(url.openStream());
170:                        } catch (MalformedURLException e) {
171:                            throw new XMLStreamException(e);
172:                        } catch (IOException e) {
173:                            throw new XMLStreamException(e);
174:                        }
175:                    } else
176:                        throw new XMLStreamException(
177:                                "StreamSource contains no stream information");
178:                } else if (source instanceof  DOMSource)
179:                    return new DOMSourceXMLStreamReaderImpl((DOMSource) source);
180:                else if (source instanceof  SAXSource)
181:                    throw new JAXPNotSupportedInStAXException();
182:
183:                throw new JAXPNotSupportedInStAXException();
184:            }
185:
186:            public XMLStreamReader createXMLStreamReader(String systemId,
187:                    InputStream stream) throws XMLStreamException {
188:                return new XMLStreamReaderImpl(stream, systemId);
189:            }
190:
191:            public XMLStreamReader createXMLStreamReader(String systemId,
192:                    Reader reader) throws XMLStreamException {
193:                return new XMLStreamReaderImpl(reader, systemId);
194:            }
195:
196:            public XMLEventAllocator getEventAllocator() {
197:                return _allocator;
198:            }
199:
200:            public Object getProperty(String name)
201:                    throws IllegalArgumentException {
202:                throw new IllegalArgumentException("property \"" + name
203:                        + "\" not supported");
204:            }
205:
206:            public XMLReporter getXMLReporter() {
207:                return _reporter;
208:            }
209:
210:            public XMLResolver getXMLResolver() {
211:                return _resolver;
212:            }
213:
214:            public boolean isPropertySupported(String name) {
215:                return false;
216:            }
217:
218:            public void setEventAllocator(XMLEventAllocator allocator) {
219:                _allocator = allocator;
220:            }
221:
222:            public void setProperty(String name, Object value)
223:                    throws IllegalArgumentException {
224:                if ("javax.xml.stream.allocator".equals(name)) {
225:                    setEventAllocator((XMLEventAllocator) value);
226:                    return;
227:                } else if ("javax.xml.stream.isNamespaceAware".equals(name)) {
228:                    // XXX?
229:                    return;
230:                }
231:
232:                throw new IllegalArgumentException("property \"" + name
233:                        + "\" not supported");
234:            }
235:
236:            public void setXMLReporter(XMLReporter reporter) {
237:                _reporter = reporter;
238:            }
239:
240:            public void setXMLResolver(XMLResolver resolver) {
241:                _resolver = resolver;
242:            }
243:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.