comparison 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
comparison
equal deleted inserted replaced
1072:00704b28b9f1 1073:6e511ea557b4
93 93
94 public void putQ(JBuffer src) { 94 public void putQ(JBuffer src) {
95 bb.put(src.bb); 95 bb.put(src.bb);
96 } 96 }
97 97
98 public int put(JBuffer src) {
99 return put(src.asArray());
100 }
101
102 public void putQ(byte b) { 98 public void putQ(byte b) {
103 bb.put(b); 99 bb.put(b);
104 }
105
106 public void put(byte b)
107 {
108 ByteBuffer dup = bb.duplicate();
109 dup.position(bb.limit());
110 dup.limit(bb.capacity());
111 dup.put(b);
112 bb.limit(bb.limit()+1);
113 }
114
115 private int put(byte[] b, int offset, int length) {
116 ByteBuffer dup = bb.duplicate();
117 int put = bb.limit();
118 int capacity = bb.capacity();
119 dup.position(put);
120 dup.limit(capacity);
121 if( length > capacity - put )
122 length = capacity - put;
123 dup.put(b,offset,length);
124 bb.limit(put+length);
125 return length;
126 } 100 }
127 101
128 public void putQ(byte[] b) { 102 public void putQ(byte[] b) {
129 bb.put(b); 103 bb.put(b);
130 } 104 }
131 105
132 public int put(byte[] b) {
133 return put(b,0,b.length);
134 }
135
136 private final byte[] asArray() {
137 byte[] bytes = new byte[remaining()];
138 bb.duplicate().get(bytes);
139 return bytes;
140 }
141 /* 106 /*
142 @Override 107 @Override
143 public String toString() { 108 public String toString() {
144 // return toString("ISO-8859-1"); 109 // return toString("ISO-8859-1");
145 // Thread.dumpStack(); 110 // Thread.dumpStack();