KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > quikj > server > framework > AceInputSocketStreamMessage


1 package com.quikj.server.framework;
2
3 import java.util.*;
4
5 public final class AceInputSocketStreamMessage implements AceMessageInterface
6 {
7     public static final int READ_FAILED = 1;
8     public static final int READ_COMPLETED = 2;
9     public static final int EOF_REACHED = 3;
10     public static final int ERROR_OCCURED = 4;
11     public static final int MESSAGE_OVERFLOW = 5;
12     public static final int DISCRIMINATOR_MISMATCH = 6;
13     public static final int TIMEOUT = 7;
14     
15     protected AceInputSocketStreamMessage(AceInputSocketStream stream, byte[] buffer, int length, int status,
16     long user_parm)
17     {
18         inputStream = stream;
19         this.buffer = buffer;
20         this.status = status;
21         this.length = length;
22         userParm = user_parm;
23     }
24     
25     protected AceInputSocketStreamMessage(AceInputSocketStream stream, String JavaDoc line, int status, long user_parm)
26     {
27         inputStream = stream;
28         this.line = line;
29         this.status = status;
30         userParm = user_parm;
31     }
32     
33     protected AceInputSocketStreamMessage(AceInputSocketStream stream,
34     boolean simple_req,
35     String JavaDoc method,
36     String JavaDoc url,
37     String JavaDoc http_version,
38     Vector headers,
39     char[] body,
40     int body_length,
41     int status,
42     long user_parm)
43     {
44         inputStream = stream;
45         simpleReq = simple_req;
46         httpURL = url;
47         httpMethod = method;
48         httpVersion = http_version;
49         this.status = status;
50         userParm = user_parm;
51         this.headers = headers;
52         this.body = body;
53         bodyLength = body_length;
54         httpRequest = true;
55     }
56     
57     protected AceInputSocketStreamMessage(AceInputSocketStream stream,
58     String JavaDoc http_version,
59     String JavaDoc http_status,
60     String JavaDoc http_reason,
61     Vector headers,
62     char[] body,
63     int body_length,
64     int status,
65     long user_parm)
66     {
67         inputStream = stream;
68         httpVersion = http_version;
69         httpStatus = http_status;
70         httpReason = http_reason;
71         this.status = status;
72         userParm = user_parm;
73         this.headers = headers;
74         this.body = body;
75         bodyLength = body_length;
76         httpRequest = false;
77     }
78     
79     // this method is made public for the web server application that resides
80
// in a different package
81
public AceInputSocketStreamMessage(AceInputSocketStream stream,
82     AceHTTPMessage message,
83     int status,
84     long user_parm)
85     {
86         inputStream = stream;
87         httpRequest = message.isHTTPRequest();
88         simpleReq = message.isSimpleReq();
89         httpURL = message.getURL();;
90         httpMethod = message.getRequestMethod();
91         httpVersion = message.getHTTPVersion();
92         httpStatus = message.getHTTPStatus();
93         httpReason = message.getHTTPReason();
94         headers = message.getHeaderFields();
95         
96         this.body = message.getBodyChar();
97         bodyLength = message.getBodyLength();
98         
99         this.status = status;
100         userParm = user_parm;
101     }
102     
103     public String JavaDoc messageType()
104     {
105         return new String JavaDoc("AceInputSocketStreamMessage");
106     }
107     
108     public AceInputSocketStream getInputSocketStream()
109     {
110         return inputStream;
111     }
112     
113     public byte[] getMessage()
114     {
115         return buffer;
116     }
117     
118     public int getLength()
119     {
120         return length;
121     }
122     
123     public int getStatus()
124     {
125         return status;
126     }
127     
128     public String JavaDoc getLines()
129     {
130         return line;
131     }
132     
133     public long getUserParm()
134     {
135         return userParm;
136     }
137     
138     public Vector getHTTPHeaders()
139     {
140         return headers;
141     }
142     
143     public char[] getHTTPBody()
144     {
145         return body;
146     }
147     
148     public int getHTTPBodyLength()
149     {
150         return bodyLength;
151     }
152     
153     public boolean isSimpleRequest()
154     {
155         return simpleReq;
156     }
157     
158     public String JavaDoc getHTTPMethod()
159     {
160         return httpMethod;
161     }
162     
163     public String JavaDoc getHTTPVersion()
164     {
165         return httpVersion;
166     }
167     
168     public String JavaDoc getURL()
169     {
170         return httpURL;
171     }
172     
173     public boolean isHTTPRequest()
174     {
175         return httpRequest;
176     }
177     
178     public String JavaDoc getHTTPStatus()
179     {
180         return httpStatus;
181     }
182     
183     public String JavaDoc getHTTPReasonPhrase()
184     {
185         return httpReason;
186     }
187     
188     private AceInputSocketStream inputStream;
189     private byte[] buffer = null;
190     private int status;
191     private int length = 0;
192     private String JavaDoc line = null;
193     private long userParm;
194     private char[] body = null;
195     private int bodyLength = 0;
196     private Vector headers = null;
197     private boolean simpleReq = false;
198     private String JavaDoc httpMethod = null;
199     private String JavaDoc httpVersion = null;
200     private String JavaDoc httpURL = null;
201     private boolean httpRequest = false;
202     private String JavaDoc httpStatus = null;
203     private String JavaDoc httpReason = null;
204 }
205
206
207
208
209
210
211
212
213
214
215
Popular Tags