1 29 30 package com.caucho.xml.stream; 31 import javax.xml.stream.*; 32 import javax.xml.stream.util.XMLEventAllocator; 33 import javax.xml.transform.Source ; 34 import java.io.IOException ; 35 import java.io.InputStream ; 36 import java.io.InputStreamReader ; 37 import java.io.Reader ; 38 39 public class XMLInputFactoryImpl extends XMLInputFactory { 40 41 private XMLEventAllocator _allocator = new XMLEventAllocatorImpl(); 42 private XMLReporter _reporter; 43 private XMLResolver _resolver; 44 45 public XMLInputFactoryImpl() 46 { 47 } 48 49 53 public XMLEventReader 54 createFilteredReader(XMLEventReader reader, EventFilter filter) 55 throws XMLStreamException 56 { 57 return new FilteredEventReader(reader, filter); 58 } 59 60 public XMLStreamReader 61 createFilteredReader(XMLStreamReader reader, StreamFilter filter) 62 throws XMLStreamException 63 { 64 return new FilteredStreamReader(reader, filter); 65 } 66 67 71 public XMLEventReader 72 createXMLEventReader(InputStream stream) 73 throws XMLStreamException 74 { 75 return new XMLEventReaderImpl(createXMLStreamReader(stream)); 76 } 77 78 public XMLEventReader 79 createXMLEventReader(InputStream stream, String encoding) 80 throws XMLStreamException 81 { 82 return new XMLEventReaderImpl(createXMLStreamReader(stream, encoding)); 83 } 84 85 public XMLEventReader 86 createXMLEventReader(Reader reader) 87 throws XMLStreamException 88 { 89 return new XMLEventReaderImpl(createXMLStreamReader(reader)); 90 } 91 92 95 public XMLEventReader 96 createXMLEventReader(Source source) 97 throws XMLStreamException 98 { 99 throw new JAXPNotSupportedInStAXException(); 100 } 101 102 public XMLEventReader 103 createXMLEventReader(String systemId, InputStream stream) 104 throws XMLStreamException 105 { 106 return new XMLEventReaderImpl(createXMLStreamReader(systemId, stream)); 107 } 108 109 public XMLEventReader 110 createXMLEventReader(String systemId, Reader reader) 111 throws XMLStreamException 112 { 113 return new XMLEventReaderImpl(createXMLStreamReader(systemId, reader)); 114 } 115 116 public XMLEventReader 117 createXMLEventReader(XMLStreamReader reader) 118 throws XMLStreamException 119 { 120 return new XMLEventReaderImpl(reader); 121 } 122 123 127 public XMLStreamReader 128 createXMLStreamReader(InputStream stream) 129 throws XMLStreamException 130 { 131 return new XMLStreamReaderImpl(stream); 132 } 133 134 public XMLStreamReader 135 createXMLStreamReader(InputStream stream, String encoding) 136 throws XMLStreamException 137 { 138 try { 139 InputStreamReader isr = new InputStreamReader (stream, encoding); 140 return new XMLStreamReaderImpl(isr); 141 } 142 catch (IOException e) { 143 throw new XMLStreamException(e); 144 } 145 } 146 147 public XMLStreamReader 148 createXMLStreamReader(Reader reader) 149 throws XMLStreamException 150 { 151 return new XMLStreamReaderImpl(reader); 152 } 153 154 157 public XMLStreamReader 158 createXMLStreamReader(Source source) 159 throws XMLStreamException 160 { 161 throw new JAXPNotSupportedInStAXException(); 162 } 163 164 public XMLStreamReader 165 createXMLStreamReader(String systemId, InputStream stream) 166 throws XMLStreamException 167 { 168 return new XMLStreamReaderImpl(stream, systemId); 169 } 170 171 public XMLStreamReader 172 createXMLStreamReader(String systemId, Reader reader) 173 throws XMLStreamException 174 { 175 return new XMLStreamReaderImpl(reader, systemId); 176 } 177 178 public XMLEventAllocator getEventAllocator() 179 { 180 return _allocator; 181 } 182 183 public Object getProperty(String name) 184 throws IllegalArgumentException 185 { 186 throw new IllegalArgumentException ("property \""+name+"\" not supported"); 187 } 188 189 public XMLReporter getXMLReporter() 190 { 191 return _reporter; 192 } 193 194 public XMLResolver getXMLResolver() 195 { 196 return _resolver; 197 } 198 199 public boolean isPropertySupported(String name) 200 { 201 return false; 202 } 203 204 public void setEventAllocator(XMLEventAllocator allocator) 205 { 206 _allocator = allocator; 207 } 208 209 public void setProperty(String name, Object value) 210 throws IllegalArgumentException 211 { 212 213 if ("javax.xml.stream.allocator".equals(name)) { 214 setEventAllocator((XMLEventAllocator)value); 215 return; 216 } 217 218 throw new IllegalArgumentException ("property \""+name+"\" not supported"); 219 } 220 221 public void setXMLReporter(XMLReporter reporter) 222 { 223 _reporter = reporter; 224 } 225 226 public void setXMLResolver(XMLResolver resolver) 227 { 228 _resolver = resolver; 229 } 230 231 } 232 233 | Popular Tags |