1 17 package org.apache.servicemix.jbi.jaxp; 18 19 import javax.xml.transform.Source ; 20 import javax.xml.transform.stream.StreamSource ; 21 22 import java.io.ByteArrayInputStream ; 23 import java.io.InputStream ; 24 import java.io.InputStreamReader ; 25 import java.io.Reader ; 26 27 33 public class BytesSource extends StreamSource { 34 private byte[] data; 35 36 public BytesSource(byte[] data) { 37 this.data = data; 38 } 39 40 public BytesSource(byte[] data, String systemId) { 41 this.data = data; 42 setSystemId(systemId); 43 } 44 45 public InputStream getInputStream() { 46 return new ByteArrayInputStream (data); 47 } 48 49 public Reader getReader() { 50 return new InputStreamReader (getInputStream()); 51 } 52 53 public byte[] getData() { 54 return data; 55 } 56 57 public String toString() { 58 return "BytesSource[" + new String (data) + "]"; 59 } 60 61 } 62 | Popular Tags |