mirror of
https://github.com/jetty/jetty.project.git
synced 2025-03-03 20:39:18 +00:00
Removed constructors that take the "compressed" parameter (compression has been removed from the specification).
Added constructor that takes byte[], offset and length.
This commit is contained in:
parent
f9a917f538
commit
4b29f18703
@ -23,39 +23,44 @@ import java.nio.ByteBuffer;
|
||||
*/
|
||||
public class BytesDataInfo extends DataInfo
|
||||
{
|
||||
private byte[] bytes;
|
||||
private int offset;
|
||||
private final byte[] bytes;
|
||||
private final int offset;
|
||||
private final int length;
|
||||
private int index;
|
||||
|
||||
public BytesDataInfo(byte[] bytes, boolean close)
|
||||
{
|
||||
this(bytes, close, false);
|
||||
this(bytes, 0, bytes.length, close);
|
||||
}
|
||||
|
||||
public BytesDataInfo(byte[] bytes, boolean close, boolean compress)
|
||||
public BytesDataInfo(byte[] bytes, int offset, int length, boolean close)
|
||||
{
|
||||
super(close, compress);
|
||||
super(close, false);
|
||||
this.bytes = bytes;
|
||||
this.offset = offset;
|
||||
this.length = length;
|
||||
this.index = offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int length()
|
||||
{
|
||||
return bytes.length;
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available()
|
||||
{
|
||||
return length() - offset;
|
||||
return length - index + offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int readInto(ByteBuffer output)
|
||||
{
|
||||
int space = output.remaining();
|
||||
int length = Math.min(available(), space);
|
||||
output.put(bytes, offset, length);
|
||||
offset += length;
|
||||
return length;
|
||||
int chunk = Math.min(available(), space);
|
||||
output.put(bytes, index, chunk);
|
||||
index += chunk;
|
||||
return chunk;
|
||||
}
|
||||
}
|
||||
|
@ -25,11 +25,6 @@ public class StringDataInfo extends BytesDataInfo
|
||||
{
|
||||
public StringDataInfo(String string, boolean close)
|
||||
{
|
||||
this(string, close, false);
|
||||
}
|
||||
|
||||
public StringDataInfo(String string, boolean close, boolean compress)
|
||||
{
|
||||
super(string.getBytes(Charset.forName("UTF-8")), close, compress);
|
||||
super(string.getBytes(Charset.forName("UTF-8")), close);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user