1 package ca.uhn.hl7v2.hoh.raw.api;
2
3 import java.io.IOException;
4 import java.io.Writer;
5
6 import ca.uhn.hl7v2.hoh.api.IResponseSendable;
7 import ca.uhn.hl7v2.hoh.encoder.EncodingStyle;
8 import ca.uhn.hl7v2.hoh.encoder.ResponseCode;
9
10 public class RawSendable implements IResponseSendable<String> {
11
12 private final String myRawMessage;
13 private final EncodingStyle myEncodingStyle;
14 private ResponseCode myResponseCode;
15
16
17
18
19
20
21
22 public RawSendable(String theRawMessage) {
23 if (theRawMessage == null) {
24 throw new NullPointerException("Raw Message may not be null");
25 }
26 myRawMessage = theRawMessage;
27 myEncodingStyle = EncodingStyle.detect(myRawMessage);
28 }
29
30 public void writeMessage(Writer theWriter) throws IOException {
31 theWriter.write(myRawMessage);
32 theWriter.flush();
33 }
34
35 public EncodingStyle getEncodingStyle() {
36 return myEncodingStyle;
37 }
38
39 public ResponseCode getResponseCode() {
40 if (myResponseCode == null) {
41 myResponseCode = ResponseCode.detect(myRawMessage);
42 }
43 return myResponseCode;
44 }
45
46 public String getMessage() {
47 return myRawMessage;
48 }
49
50 }