1 6 7 10 package javax.xml.transform.stream; 11 12 import java.io.File ; 13 import java.io.InputStream ; 14 import java.io.Reader ; 15 16 import javax.xml.transform.Source ; 17 18 28 public class StreamSource implements Source { 29 30 34 public static final String FEATURE = 35 "http://javax.xml.transform.stream.StreamSource/feature"; 36 37 48 public StreamSource() { } 49 50 62 public StreamSource(InputStream inputStream) { 63 setInputStream(inputStream); 64 } 65 66 79 public StreamSource(InputStream inputStream, String systemId) { 80 setInputStream(inputStream); 81 setSystemId(systemId); 82 } 83 84 94 public StreamSource(Reader reader) { 95 setReader(reader); 96 } 97 98 109 public StreamSource(Reader reader, String systemId) { 110 setReader(reader); 111 setSystemId(systemId); 112 } 113 114 119 public StreamSource(String systemId) { 120 this.systemId = systemId; 121 } 122 123 128 public StreamSource(File f) { 129 setSystemId(f); 130 } 131 132 144 public void setInputStream(InputStream inputStream) { 145 this.inputStream = inputStream; 146 } 147 148 154 public InputStream getInputStream() { 155 return inputStream; 156 } 157 158 168 public void setReader(Reader reader) { 169 this.reader = reader; 170 } 171 172 178 public Reader getReader() { 179 return reader; 180 } 181 182 191 public void setPublicId(String publicId) { 192 this.publicId = publicId; 193 } 194 195 201 public String getPublicId() { 202 return publicId; 203 } 204 205 217 public void setSystemId(String systemId) { 218 this.systemId = systemId; 219 } 220 221 227 public String getSystemId() { 228 return systemId; 229 } 230 231 236 public void setSystemId(File f) { 237 String fpath=f.getAbsolutePath(); 238 if (File.separatorChar != '/') { 239 fpath = fpath.replace(File.separatorChar, '/'); 240 } 241 if( fpath.startsWith("/")) 242 this.systemId= "file://" + fpath; 243 else 244 this.systemId = "file:///" + fpath; 245 } 246 247 251 254 private String publicId; 255 256 259 private String systemId; 260 261 264 private InputStream inputStream; 265 266 269 private Reader reader; 270 } 271 | Popular Tags |