Mercurial Hosting > luan
annotate src/org/eclipse/jetty/io/JBuffer.java @ 1073:6e511ea557b4
remove old JBuffer.put()
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 10 Nov 2016 02:33:09 -0700 |
parents | 00704b28b9f1 |
children | 6b7ff30bb990 |
rev | line source |
---|---|
1046 | 1 // tmp class to implement Buffer until I can get rid of it |
2 | |
3 package org.eclipse.jetty.io; | |
4 | |
5 import java.io.InputStream; | |
6 import java.io.IOException; | |
7 import java.nio.ByteBuffer; | |
8 import org.slf4j.Logger; | |
9 import org.slf4j.LoggerFactory; | |
10 import org.eclipse.jetty.util.TypeUtil; | |
11 | |
12 | |
1048 | 13 public final class JBuffer { |
1046 | 14 private static final Logger LOG = LoggerFactory.getLogger(JBuffer.class); |
15 | |
16 private final ByteBuffer bb; | |
17 | |
18 public JBuffer(ByteBuffer bb) { | |
19 this.bb = bb; | |
20 } | |
21 | |
1050
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
22 public int position() { |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
23 return bb.position(); |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
24 } |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
25 |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
26 public void position(int i) { |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
27 bb.position(i); |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
28 } |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
29 |
1062
4a50422596b6
fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1061
diff
changeset
|
30 public int limit() { |
4a50422596b6
fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1061
diff
changeset
|
31 return bb.limit(); |
4a50422596b6
fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1061
diff
changeset
|
32 } |
4a50422596b6
fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1061
diff
changeset
|
33 |
1050
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
34 public void limit(int i) { |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
35 bb.limit(i); |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
36 } |
5ef954fad97b
remove JBuffer.sliceFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1049
diff
changeset
|
37 |
1046 | 38 public byte[] array() { |
1053 | 39 return bb.array(); |
40 } | |
41 | |
42 public boolean hasArray() { | |
43 return bb.hasArray(); | |
1046 | 44 } |
45 | |
1048 | 46 public JBuffer duplicate() { |
1046 | 47 return new JBuffer(bb.duplicate()); |
48 } | |
49 | |
50 public int remaining() { | |
51 return bb.remaining(); | |
52 } | |
53 | |
54 public boolean isReadOnly() { | |
55 return bb.isReadOnly(); | |
56 } | |
57 | |
58 public boolean hasRemaining() { | |
59 return bb.hasRemaining(); | |
60 } | |
61 | |
62 public byte get() { | |
63 return bb.get(); | |
64 } | |
65 | |
1054
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
66 public void get(byte[] bytes) { |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
67 bb.get(bytes); |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
68 } |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
69 |
1046 | 70 public void compact() { |
71 bb.compact(); | |
72 } | |
73 | |
74 public int capacity() { | |
75 return bb.capacity(); | |
76 } | |
77 | |
78 | |
79 | |
80 public ByteBuffer getByteBuffer() { | |
1062
4a50422596b6
fix JBuffer.getByteBuffer()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1061
diff
changeset
|
81 return bb; |
1046 | 82 } |
83 | |
1066
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
84 public void clear() { |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
85 bb.clear(); |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
86 } |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
87 |
1046 | 88 |
1060 | 89 public void get(byte[] b, int offset, int length) { |
1046 | 90 bb.get(b,offset,length); |
91 } | |
92 | |
93 | |
1066
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
94 public void putQ(JBuffer src) { |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
95 bb.put(src.bb); |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
96 } |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
97 |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
98 public void putQ(byte b) { |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
99 bb.put(b); |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
100 } |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
101 |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
102 public void putQ(byte[] b) { |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
103 bb.put(b); |
1046 | 104 } |
105 | |
1064
a0abb16cf6e7
remove JBuffer.readFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1063
diff
changeset
|
106 /* |
1046 | 107 @Override |
1054
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
108 public String toString() { |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
109 // return toString("ISO-8859-1"); |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
110 // Thread.dumpStack(); |
87275900646e
remove JBuffer.toString()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1053
diff
changeset
|
111 throw new RuntimeException("toString"); |
1046 | 112 } |
1064
a0abb16cf6e7
remove JBuffer.readFrom()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1063
diff
changeset
|
113 */ |
1046 | 114 |
1052
4a2489f1d5fe
remove JBuffer.peek()
Franklin Schmidt <fschmidt@gmail.com>
parents:
1051
diff
changeset
|
115 public byte get(int index) { |
1046 | 116 return bb.get(index); |
117 } | |
118 | |
1066
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
119 public void flip() { |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
120 bb.flip(); |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
121 } |
bbbda7c6e8ec
fix use of HttpGenerator._header
Franklin Schmidt <fschmidt@gmail.com>
parents:
1065
diff
changeset
|
122 |
1046 | 123 } |