1 package org.apache.slide.projector.value; 2 3 import java.io.ByteArrayInputStream ; 4 import java.io.ByteArrayOutputStream ; 5 import java.io.IOException ; 6 import java.io.InputStream ; 7 8 import org.apache.slide.projector.util.StreamHelper; 9 10 13 14 public class MultipleStreamableValue extends AbstractStreamableValue { 15 private StreamableValue value; 16 private byte[] bytes; 17 18 public MultipleStreamableValue(StreamableValue resource) { 19 this.value = resource; 20 } 21 22 public InputStream getInputStream() throws IOException { 23 if ( bytes == null ) { 24 ByteArrayOutputStream outputStream = new ByteArrayOutputStream (); 25 StreamHelper.copy(value.getInputStream(), outputStream); 26 bytes = outputStream.toByteArray(); 27 } 28 return new ByteArrayInputStream (bytes); 29 } 30 31 public int getContentLength() { 32 return value.getContentLength(); 33 } 34 35 public boolean isDocument() { 36 return value.isDocument(); 37 } 38 39 public String getContentType() { 40 return value.getContentType(); 41 } 42 43 public String getCharacterEncoding() { 44 return value.getCharacterEncoding(); 45 } 46 } 47 | Popular Tags |