public class FragmentBuffer extends Object implements Serializable
Modifier and Type | Class and Description |
---|---|
static class |
FragmentBuffer.Fragment
Fragments encapsulate pairs of offset and length.
|
Constructor and Description |
---|
FragmentBuffer()
Creates a fragment buffer.
|
FragmentBuffer(int length)
Creates a fragment buffer.
|
Modifier and Type | Method and Description |
---|---|
void |
addFragment(int offset,
byte b) |
void |
addFragment(int offset,
byte[] bytes)
Adds a fragment of bytes at a specific offset to this file.
|
void |
addFragment(int offset,
byte[] bytes,
int srcOffset,
int srcLength)
Adds a fragment of bytes at a specific offset to this file.
|
boolean |
equals(Object otherObject) |
byte[] |
getBuffer() |
int |
getBufferedLength(int index)
Calculates the number of bytes left in the buffer starting from index
index . |
int |
getBytesBuffered() |
Collection<FragmentBuffer.Fragment> |
getFragments() |
int |
getLength() |
int |
getPosition() |
FragmentBuffer.Fragment |
getSmallestUnbufferedFragment(int offset,
int length)
Gets the smallest fragment that contains
offset and offset + length
that has not been buffered in this buffer. |
int |
hashCode() |
boolean |
isCoveredByFragment(int offset) |
boolean |
isCoveredByFragment(int offset,
int length) |
String |
toString() |
void |
updateFrom(FragmentBuffer other) |
public FragmentBuffer()
public FragmentBuffer(int length)
length
- the length of the bufferpublic void updateFrom(FragmentBuffer other)
public void addFragment(int offset, byte b)
public void addFragment(int offset, byte[] bytes)
offset
- the fragment offsetbytes
- the bytes from which fragment content will be copiedpublic void addFragment(int offset, byte[] bytes, int srcOffset, int srcLength)
offset
- the fragment offsetbytes
- the bytes from which fragment contents will be copiedsrcOffset
- the offset within bytes where the contents of the fragment startsrcLength
- the length of the fragmentpublic int getPosition()
public int getBytesBuffered()
public boolean isCoveredByFragment(int offset)
public boolean isCoveredByFragment(int offset, int length)
public int getBufferedLength(int index)
index
.index
- the indexpublic Collection<FragmentBuffer.Fragment> getFragments()
public byte[] getBuffer()
public int getLength()
public FragmentBuffer.Fragment getSmallestUnbufferedFragment(int offset, int length)
offset
and offset + length
that has not been buffered in this buffer.offset
- the offsetlength
- the lengthCopyright © 2016. All rights reserved.