Mercurial Hosting > luan
comparison src/org/eclipse/jetty/io/View.java @ 1005:0e96ce3db20a
remove HttpBuffers
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 23 Oct 2016 02:42:05 -0600 |
parents | 3428c60d7cfc |
children | cf0367978d8b |
comparison
equal
deleted
inserted
replaced
1004:3fa54d9d19cd | 1005:0e96ce3db20a |
---|---|
25 * | 25 * |
26 * | 26 * |
27 */ | 27 */ |
28 public class View extends AbstractBuffer | 28 public class View extends AbstractBuffer |
29 { | 29 { |
30 Buffer _buffer; | 30 Buffer _buffer; |
31 | 31 |
32 /** | 32 /** |
33 * @param buffer The <code>Buffer</code> on which we are presenting a <code>View</code>. | 33 * @param buffer The <code>Buffer</code> on which we are presenting a <code>View</code>. |
34 * @param mark The initial value of the {@link Buffer#markIndex mark index} | 34 * @param mark The initial value of the {@link Buffer#markIndex mark index} |
35 * @param get The initial value of the {@link Buffer#getIndex get index} | 35 * @param get The initial value of the {@link Buffer#getIndex get index} |
36 * @param put The initial value of the {@link Buffer#putIndex put index} | 36 * @param put The initial value of the {@link Buffer#putIndex put index} |
37 * @param access The access level - one of the constants from {@link Buffer}. | 37 * @param access The access level - one of the constants from {@link Buffer}. |
38 */ | 38 */ |
39 public View(Buffer buffer, int mark, int get, int put,int access) | 39 public View(Buffer buffer, int mark, int get, int put,int access) |
40 { | 40 { |
41 super(READWRITE,!buffer.isImmutable()); | 41 super(READWRITE,!buffer.isImmutable()); |
42 _buffer=buffer.buffer(); | 42 _buffer=buffer.buffer(); |
43 setPutIndex(put); | 43 setPutIndex(put); |
44 setGetIndex(get); | 44 setGetIndex(get); |
45 setMarkIndex(mark); | 45 setMarkIndex(mark); |
46 _access=access; | 46 _access=access; |
47 } | 47 } |
48 | 48 |
49 public View(Buffer buffer) | 49 public View(Buffer buffer) |
50 { | 50 { |
51 super(READWRITE,!buffer.isImmutable()); | 51 super(READWRITE,!buffer.isImmutable()); |
52 _buffer=buffer.buffer(); | 52 _buffer=buffer.buffer(); |
53 setPutIndex(buffer.putIndex()); | 53 setPutIndex(buffer.putIndex()); |
54 setGetIndex(buffer.getIndex()); | 54 setGetIndex(buffer.getIndex()); |
55 setMarkIndex(buffer.markIndex()); | 55 setMarkIndex(buffer.markIndex()); |
56 _access=buffer.isReadOnly()?READONLY:READWRITE; | 56 _access=buffer.isReadOnly()?READONLY:READWRITE; |
57 } | 57 } |
58 | 58 |
59 public View() | 59 public View() |
60 { | 60 { |
61 super(READWRITE,true); | 61 super(READWRITE,true); |
62 } | 62 } |
63 | 63 |
64 /** | 64 /** |
65 * Update view to buffer | 65 * Update view to buffer |
66 */ | 66 */ |
67 public void update(Buffer buffer) | 67 public void update(Buffer buffer) |
68 { | 68 { |
69 _access=READWRITE; | 69 _access=READWRITE; |
70 _buffer=buffer.buffer(); | 70 _buffer=buffer.buffer(); |
71 setGetIndex(0); | 71 setGetIndex(0); |
72 setPutIndex(buffer.putIndex()); | 72 setPutIndex(buffer.putIndex()); |
73 setGetIndex(buffer.getIndex()); | 73 setGetIndex(buffer.getIndex()); |
74 setMarkIndex(buffer.markIndex()); | 74 setMarkIndex(buffer.markIndex()); |
75 _access=buffer.isReadOnly()?READONLY:READWRITE; | 75 _access=buffer.isReadOnly()?READONLY:READWRITE; |
76 } | 76 } |
77 | 77 |
78 public void update(int get, int put) | 78 public void update(int get, int put) |
79 { | 79 { |
80 int a=_access; | 80 int a=_access; |
81 _access=READWRITE; | 81 _access=READWRITE; |
82 setGetIndex(0); | 82 setGetIndex(0); |
83 setPutIndex(put); | 83 setPutIndex(put); |
84 setGetIndex(get); | 84 setGetIndex(get); |
85 setMarkIndex(-1); | 85 setMarkIndex(-1); |
86 _access=a; | 86 _access=a; |
87 } | 87 } |
88 | 88 |
89 /** | 89 /** |
90 * @return The {@link Buffer#array()} from the underlying buffer. | 90 * @return The {@link Buffer#array()} from the underlying buffer. |
91 */ | 91 */ |
92 public byte[] array() | 92 public byte[] array() |
93 { | 93 { |
94 return _buffer.array(); | 94 return _buffer.array(); |
95 } | 95 } |
96 | 96 |
97 /** | 97 /** |
98 * @return The {@link Buffer#buffer()} from the underlying buffer. | 98 * @return The {@link Buffer#buffer()} from the underlying buffer. |
99 */ | 99 */ |
100 @Override | 100 @Override |
101 public Buffer buffer() | 101 public Buffer buffer() |
102 { | 102 { |
103 return _buffer.buffer(); | 103 return _buffer.buffer(); |
104 } | 104 } |
105 | 105 |
106 /** | 106 /** |
107 * @return The {@link Buffer#capacity} of the underlying buffer. | 107 * @return The {@link Buffer#capacity} of the underlying buffer. |
108 */ | 108 */ |
109 public int capacity() | 109 public int capacity() |
110 { | 110 { |
111 return _buffer.capacity(); | 111 return _buffer.capacity(); |
112 } | 112 } |
113 | 113 |
114 /** | 114 /** |
115 * | 115 * |
116 */ | 116 */ |
117 @Override | 117 @Override |
118 public void clear() | 118 public void clear() |
119 { | 119 { |
120 setMarkIndex(-1); | 120 setMarkIndex(-1); |
121 setGetIndex(0); | 121 setGetIndex(0); |
122 setPutIndex(_buffer.getIndex()); | 122 setPutIndex(_buffer.getIndex()); |
123 setGetIndex(_buffer.getIndex()); | 123 setGetIndex(_buffer.getIndex()); |
124 } | 124 } |
125 | 125 |
126 /** | 126 /** |
127 * | 127 * |
128 */ | 128 */ |
129 @Override | 129 @Override |
130 public void compact() | 130 public void compact() |
131 { | 131 { |
132 // TODO | 132 // TODO |
133 } | 133 } |
134 | 134 |
135 /* | 135 /* |
136 * (non-Javadoc) | 136 * (non-Javadoc) |
137 * | 137 * |
138 * @see java.lang.Object#equals(java.lang.Object) | 138 * @see java.lang.Object#equals(java.lang.Object) |
139 */ | 139 */ |
140 @Override | 140 @Override |
141 public boolean equals(Object obj) | 141 public boolean equals(Object obj) |
142 { | 142 { |
143 return this==obj ||((obj instanceof Buffer)&& obj.equals(this)) || super.equals(obj); | 143 return this==obj ||((obj instanceof Buffer)&& obj.equals(this)) || super.equals(obj); |
144 } | 144 } |
145 | 145 |
146 /** | 146 /** |
147 * @return Whether the underlying buffer is {@link Buffer#isReadOnly read only} | 147 * @return Whether the underlying buffer is {@link Buffer#isReadOnly read only} |
148 */ | 148 */ |
149 @Override | 149 @Override |
150 public boolean isReadOnly() | 150 public boolean isReadOnly() |
151 { | 151 { |
152 return _buffer.isReadOnly(); | 152 return _buffer.isReadOnly(); |
153 } | 153 } |
154 | 154 |
155 /** | 155 /** |
156 * @return Whether the underlying buffer is {@link Buffer#isVolatile volatile} | 156 * @return Whether the underlying buffer is {@link Buffer#isVolatile volatile} |
157 */ | 157 */ |
158 @Override | 158 @Override |
159 public boolean isVolatile() | 159 public boolean isVolatile() |
160 { | 160 { |
161 return true; | 161 return true; |
162 } | 162 } |
163 | 163 |
164 /** | 164 /** |
165 * @return The result of calling {@link Buffer#peek(int)} on the underlying buffer | 165 * @return The result of calling {@link Buffer#peek(int)} on the underlying buffer |
166 */ | 166 */ |
167 public byte peek(int index) | 167 public byte peek(int index) |
168 { | 168 { |
169 return _buffer.peek(index); | 169 return _buffer.peek(index); |
170 } | 170 } |
171 | 171 |
172 /** | 172 /** |
173 * @return The result of calling {@link Buffer#peek(int, byte[], int, int)} on the underlying buffer | 173 * @return The result of calling {@link Buffer#peek(int, byte[], int, int)} on the underlying buffer |
174 */ | 174 */ |
175 public int peek(int index, byte[] b, int offset, int length) | 175 public int peek(int index, byte[] b, int offset, int length) |
176 { | 176 { |
177 return _buffer.peek(index,b,offset,length); | 177 return _buffer.peek(index,b,offset,length); |
178 } | 178 } |
179 | 179 |
180 /** | 180 /** |
181 * @return The result of calling {@link Buffer#peek(int, int)} on the underlying buffer | 181 * @return The result of calling {@link Buffer#peek(int, int)} on the underlying buffer |
182 */ | 182 */ |
183 @Override | 183 @Override |
184 public Buffer peek(int index, int length) | 184 public Buffer peek(int index, int length) |
185 { | 185 { |
186 return _buffer.peek(index, length); | 186 return _buffer.peek(index, length); |
187 } | 187 } |
188 | 188 |
189 /** | 189 /** |
190 * @param index | 190 * @param index |
191 * @param src | 191 * @param src |
192 */ | 192 */ |
193 @Override | 193 @Override |
194 public int poke(int index, Buffer src) | 194 public int poke(int index, Buffer src) |
195 { | 195 { |
196 return _buffer.poke(index,src); | 196 return _buffer.poke(index,src); |
197 } | 197 } |
198 | 198 |
199 /** | 199 /** |
200 * @param index | 200 * @param index |
201 * @param b | 201 * @param b |
202 */ | 202 */ |
203 public void poke(int index, byte b) | 203 public void poke(int index, byte b) |
204 { | 204 { |
205 _buffer.poke(index,b); | 205 _buffer.poke(index,b); |
206 } | 206 } |
207 | 207 |
208 /** | 208 /** |
209 * @param index | 209 * @param index |
210 * @param b | 210 * @param b |
211 * @param offset | 211 * @param offset |
212 * @param length | 212 * @param length |
213 */ | 213 */ |
214 @Override | 214 @Override |
215 public int poke(int index, byte[] b, int offset, int length) | 215 public int poke(int index, byte[] b, int offset, int length) |
216 { | 216 { |
217 return _buffer.poke(index,b,offset,length); | 217 return _buffer.poke(index,b,offset,length); |
218 } | 218 } |
219 | 219 |
220 @Override | 220 @Override |
221 public String toString() | 221 public String toString() |
222 { | 222 { |
223 if (_buffer==null) | 223 if (_buffer==null) |
224 return "INVALID"; | 224 return "INVALID"; |
225 return super.toString(); | 225 return super.toString(); |
226 } | 226 } |
227 | 227 |
228 public static class CaseInsensitive extends View implements Buffer.CaseInsensitve | 228 public static class CaseInsensitive extends View implements Buffer.CaseInsensitve |
229 { | 229 { |
230 public CaseInsensitive() | 230 public CaseInsensitive() |
231 { | 231 { |
232 super(); | 232 super(); |
233 } | 233 } |
234 | 234 |
235 public CaseInsensitive(Buffer buffer, int mark, int get, int put, int access) | 235 public CaseInsensitive(Buffer buffer, int mark, int get, int put, int access) |
236 { | 236 { |
237 super(buffer,mark,get,put,access); | 237 super(buffer,mark,get,put,access); |
238 } | 238 } |
239 | 239 |
240 public CaseInsensitive(Buffer buffer) | 240 public CaseInsensitive(Buffer buffer) |
241 { | 241 { |
242 super(buffer); | 242 super(buffer); |
243 } | 243 } |
244 | 244 |
245 @Override | 245 @Override |
246 public boolean equals(Object obj) | 246 public boolean equals(Object obj) |
247 { | 247 { |
248 return this==obj ||((obj instanceof Buffer)&&((Buffer)obj).equalsIgnoreCase(this)) || super.equals(obj); | 248 return this==obj ||((obj instanceof Buffer)&&((Buffer)obj).equalsIgnoreCase(this)) || super.equals(obj); |
249 } | 249 } |
250 } | 250 } |
251 } | 251 } |