comparison src/org/eclipse/jetty/io/JBuffer.java @ 1049:4afdf0f0c5bc

remove unused JBuffer methods
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:34:48 -0700
parents 2b769da7f67d
children 5ef954fad97b
comparison
equal deleted inserted replaced
1048:2b769da7f67d 1049:4afdf0f0c5bc
54 54
55 public int capacity() { 55 public int capacity() {
56 return bb.capacity(); 56 return bb.capacity();
57 } 57 }
58 58
59 public boolean isDirect() {
60 return bb.isDirect();
61 }
62
63 59
64 60
65 public ByteBuffer getByteBuffer() { 61 public ByteBuffer getByteBuffer() {
66 ByteBuffer dup = bb.duplicate(); 62 ByteBuffer dup = bb.duplicate();
67 dup.limit(dup.capacity()); 63 dup.limit(dup.capacity());
77 bb.limit(0); 73 bb.limit(0);
78 } 74 }
79 75
80 public int space() { 76 public int space() {
81 return bb.capacity() - bb.limit(); 77 return bb.capacity() - bb.limit();
82 }
83
84 public JBuffer buffer() {
85 return this;
86 } 78 }
87 79
88 80
89 public JBuffer get(int length) { 81 public JBuffer get(int length) {
90 ByteBuffer dup = bb.duplicate(); 82 ByteBuffer dup = bb.duplicate();
116 dup.limit(bb.capacity()); 108 dup.limit(bb.capacity());
117 dup.put(b); 109 dup.put(b);
118 bb.limit(bb.limit()+1); 110 bb.limit(bb.limit()+1);
119 } 111 }
120 112
121 public int put(byte[] b, int offset, int length) { 113 private int put(byte[] b, int offset, int length) {
122 ByteBuffer dup = bb.duplicate(); 114 ByteBuffer dup = bb.duplicate();
123 int put = bb.limit(); 115 int put = bb.limit();
124 int capacity = bb.capacity(); 116 int capacity = bb.capacity();
125 dup.position(put); 117 dup.position(put);
126 dup.limit(capacity); 118 dup.limit(capacity);
151 if (remaining() < n) n = remaining(); 143 if (remaining() < n) n = remaining();
152 bb.position(bb.position() + n); 144 bb.position(bb.position() + n);
153 return n; 145 return n;
154 } 146 }
155 147
156 public JBuffer slice() {
157 return duplicate();
158 }
159
160 public final JBuffer sliceFrom(int index) { 148 public final JBuffer sliceFrom(int index) {
161 ByteBuffer dup = bb.duplicate(); 149 ByteBuffer dup = bb.duplicate();
162 dup.position(index); 150 dup.position(index);
163 dup.limit(bb.position()-1); 151 dup.limit(bb.position()-1);
164 return new JBuffer(dup); 152 return new JBuffer(dup);
195 dup.limit(index+length); 183 dup.limit(index+length);
196 dup.position(index); 184 dup.position(index);
197 return new JBuffer(dup).toString(); 185 return new JBuffer(dup).toString();
198 } 186 }
199 187
200 public final String toString(String charset) 188 private final String toString(String charset)
201 { 189 {
202 byte[] bytes = asArray(); 190 byte[] bytes = asArray();
203 try 191 try
204 { 192 {
205 return new String(bytes,charset); 193 return new String(bytes,charset);
209 LOG.warn("",e); 197 LOG.warn("",e);
210 return new String(bytes); 198 return new String(bytes);
211 } 199 }
212 } 200 }
213 201
214 public String toDetailString()
215 {
216 StringBuilder buf = new StringBuilder();
217 buf.append("[");
218 buf.append(super.hashCode());
219 buf.append(",");
220 buf.append(this.buffer().hashCode());
221 buf.append(",g=");
222 buf.append(getIndex());
223 buf.append(",p=");
224 buf.append(putIndex());
225 buf.append(",c=");
226 buf.append(capacity());
227 buf.append("]={");
228 int count = 0;
229 for (int i = getIndex(); i < putIndex(); i++)
230 {
231 byte b = peek(i);
232 TypeUtil.toHex(b,buf);
233 if (count++ == 50)
234 {
235 if (putIndex() - i > 20)
236 {
237 buf.append(" ... ");
238 i = putIndex() - 20;
239 }
240 }
241 }
242 buf.append('}');
243 return buf.toString();
244 }
245
246
247 202
248 private JBuffer pokeBuffer(int index) { 203 private JBuffer pokeBuffer(int index) {
249 JBuffer dup = duplicate(); 204 JBuffer dup = duplicate();
250 dup.setPutIndex(index); 205 dup.setPutIndex(index);
251 return dup; 206 return dup;
255 return pokeBuffer(index).put(b,offset,length); 210 return pokeBuffer(index).put(b,offset,length);
256 } 211 }
257 212
258 public void poke(int index, byte b) { 213 public void poke(int index, byte b) {
259 pokeBuffer(index).put(b); 214 pokeBuffer(index).put(b);
260 }
261
262 public int poke(int index, JBuffer src) {
263 return pokeBuffer(index).put(src);
264 } 215 }
265 216
266 private JBuffer peekBuffer(int index) { 217 private JBuffer peekBuffer(int index) {
267 JBuffer dup = duplicate(); 218 JBuffer dup = duplicate();
268 dup.setGetIndex(index); 219 dup.setGetIndex(index);
269 dup.setPutIndex(dup.capacity()); 220 dup.setPutIndex(dup.capacity());
270 return dup; 221 return dup;
271 } 222 }
272 223
273 public int peek(int index, byte[] b, int offset, int length) {
274 return peekBuffer(index).get(b,offset,length);
275 }
276
277 public byte peek(int index) { 224 public byte peek(int index) {
278 return bb.get(index); 225 return bb.get(index);
279 } 226 }
280 227
281 public byte peek() { 228 public byte peek() {