1 package org.objectweb.celtix.bus.context; 2 3 import java.io.InputStream ; 4 import java.io.OutputStream ; 5 6 import org.objectweb.celtix.context.InputStreamMessageContext; 7 import org.objectweb.celtix.context.MessageContextWrapper; 8 import org.objectweb.celtix.context.OutputStreamMessageContext; 9 import org.objectweb.celtix.context.StreamMessageContext; 10 11 12 13 14 23 public class StreamMessageContextImpl extends MessageContextWrapper implements StreamMessageContext { 24 25 private InputStreamMessageContext inContext; 26 private OutputStreamMessageContext outContext; 27 28 public StreamMessageContextImpl(InputStreamMessageContext wrapped) { 29 super(wrapped); 30 inContext = wrapped; 31 if (wrapped == null) { 32 throw new NullPointerException ("wrapped context must not be null"); 33 } 34 } 35 36 public StreamMessageContextImpl(OutputStreamMessageContext wrapped) { 37 super(wrapped); 38 outContext = wrapped; 39 if (wrapped == null) { 40 throw new NullPointerException ("wrapped context must not be null"); 41 } 42 } 43 44 public InputStream getInputStream() { 45 if (inContext == null) { 46 throw new IllegalStateException ("Context intialised for OutputStream"); 47 } 48 return inContext.getInputStream(); 49 } 50 51 public void setInputStream(InputStream in) { 52 if (inContext == null) { 53 throw new IllegalStateException ("Context intialised for OutputStream"); 54 } 55 inContext.setInputStream(in); 56 } 57 58 public OutputStream getOutputStream() { 59 if (outContext == null) { 60 throw new IllegalStateException ("Context intialised for OutputStream"); 61 } 62 return outContext.getOutputStream(); 63 } 64 65 public void setOutputStream(OutputStream out) { 66 if (outContext == null) { 67 throw new IllegalStateException ("Context intialised for OutputStream"); 68 } 69 outContext.setOutputStream(out); 70 } 71 } 72 | Popular Tags |