01: package org.objectweb.celtix.bus.context;
02:
03: import java.io.InputStream;
04: import java.io.OutputStream;
05:
06: import org.objectweb.celtix.context.InputStreamMessageContext;
07: import org.objectweb.celtix.context.MessageContextWrapper;
08: import org.objectweb.celtix.context.OutputStreamMessageContext;
09: import org.objectweb.celtix.context.StreamMessageContext;
10:
11: /**
12: * Describe class StreamMessageContextImpl here.
13: *
14: *
15: * Created: Thu Nov 17 14:52:48 2005
16: *
17: * @author <a href="mailto:codea@iona.com">Conrad O'Dea</a>
18: * @version 1.0
19: */
20: public class StreamMessageContextImpl extends MessageContextWrapper
21: implements StreamMessageContext {
22:
23: private InputStreamMessageContext inContext;
24: private OutputStreamMessageContext outContext;
25:
26: public StreamMessageContextImpl(InputStreamMessageContext wrapped) {
27: super (wrapped);
28: inContext = wrapped;
29: if (wrapped == null) {
30: throw new NullPointerException(
31: "wrapped context must not be null");
32: }
33: }
34:
35: public StreamMessageContextImpl(OutputStreamMessageContext wrapped) {
36: super (wrapped);
37: outContext = wrapped;
38: if (wrapped == null) {
39: throw new NullPointerException(
40: "wrapped context must not be null");
41: }
42: }
43:
44: public InputStream getInputStream() {
45: if (inContext == null) {
46: throw new IllegalStateException(
47: "Context intialised for OutputStream");
48: }
49: return inContext.getInputStream();
50: }
51:
52: public void setInputStream(InputStream in) {
53: if (inContext == null) {
54: throw new IllegalStateException(
55: "Context intialised for OutputStream");
56: }
57: inContext.setInputStream(in);
58: }
59:
60: public OutputStream getOutputStream() {
61: if (outContext == null) {
62: throw new IllegalStateException(
63: "Context intialised for OutputStream");
64: }
65: return outContext.getOutputStream();
66: }
67:
68: public void setOutputStream(OutputStream out) {
69: if (outContext == null) {
70: throw new IllegalStateException(
71: "Context intialised for OutputStream");
72: }
73: outContext.setOutputStream(out);
74: }
75: }
|