comparison src/org/eclipse/jetty/io/JBuffer.java @ 1050:5ef954fad97b

remove JBuffer.sliceFrom()
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 07 Nov 2016 23:49:41 -0700
parents 4afdf0f0c5bc
children 1ab2dd0a7db5
comparison
equal deleted inserted replaced
1049:4afdf0f0c5bc 1050:5ef954fad97b
17 17
18 private final ByteBuffer bb; 18 private final ByteBuffer bb;
19 19
20 public JBuffer(ByteBuffer bb) { 20 public JBuffer(ByteBuffer bb) {
21 this.bb = bb; 21 this.bb = bb;
22 }
23
24 public int position() {
25 return bb.position();
26 }
27
28 public void position(int i) {
29 bb.position(i);
30 }
31
32 public void limit(int i) {
33 bb.limit(i);
22 } 34 }
23 35
24 public byte[] array() { 36 public byte[] array() {
25 return bb.hasArray() ? bb.array() : null; 37 return bb.hasArray() ? bb.array() : null;
26 } 38 }
141 153
142 public int skip(int n) { 154 public int skip(int n) {
143 if (remaining() < n) n = remaining(); 155 if (remaining() < n) n = remaining();
144 bb.position(bb.position() + n); 156 bb.position(bb.position() + n);
145 return n; 157 return n;
146 }
147
148 public final JBuffer sliceFrom(int index) {
149 ByteBuffer dup = bb.duplicate();
150 dup.position(index);
151 dup.limit(bb.position()-1);
152 return new JBuffer(dup);
153 } 158 }
154 159
155 public int readFrom(InputStream in,int max) throws IOException { 160 public int readFrom(InputStream in,int max) throws IOException {
156 ByteBuffer dup = bb.duplicate(); 161 ByteBuffer dup = bb.duplicate();
157 int put = bb.limit(); 162 int put = bb.limit();