KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > celtix > bus > context > StreamMessageContextImpl


1 package org.objectweb.celtix.bus.context;
2
3 import java.io.InputStream JavaDoc;
4 import java.io.OutputStream JavaDoc;
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 /**
15  * Describe class StreamMessageContextImpl here.
16  *
17  *
18  * Created: Thu Nov 17 14:52:48 2005
19  *
20  * @author <a HREF="mailto:codea@iona.com">Conrad O'Dea</a>
21  * @version 1.0
22  */

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 JavaDoc("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 JavaDoc("wrapped context must not be null");
41         }
42     }
43
44     public InputStream JavaDoc getInputStream() {
45         if (inContext == null) {
46             throw new IllegalStateException JavaDoc("Context intialised for OutputStream");
47         }
48         return inContext.getInputStream();
49     }
50
51     public void setInputStream(InputStream JavaDoc in) {
52         if (inContext == null) {
53             throw new IllegalStateException JavaDoc("Context intialised for OutputStream");
54         }
55         inContext.setInputStream(in);
56     }
57
58     public OutputStream JavaDoc getOutputStream() {
59         if (outContext == null) {
60             throw new IllegalStateException JavaDoc("Context intialised for OutputStream");
61         }
62         return outContext.getOutputStream();
63     }
64
65     public void setOutputStream(OutputStream JavaDoc out) {
66         if (outContext == null) {
67             throw new IllegalStateException JavaDoc("Context intialised for OutputStream");
68         }
69         outContext.setOutputStream(out);
70     }
71 }
72
Popular Tags