public abstract class Buffer extends Object
byte
array.
It will be a pure abstract class
, but it now has some static
creator methods implemented.
Those static
creator methods, allocate(int)
, copyOf(byte[])
,
copyOf(byte[], int, int)
, wrap(byte[])
, and wrap(byte[], int, int)
are implemented for compatibility for some legacy plugins calling them. They will be removed
before Embulk v1. Plugins should no longer call them, even in tests.
At the same time, a constant Buffer.EMPTY
has already been removed. Plugins cannot use it anymore.
Modifier | Constructor and Description |
---|---|
protected |
Buffer() |
protected |
Buffer(byte[] wrap,
int offset,
int capacity)
Deprecated.
|
Modifier and Type | Method and Description |
---|---|
static Buffer |
allocate(int length)
Deprecated.
This method is to be removed. Plugins should no longer call it directly.
|
abstract byte[] |
array()
Deprecated.
Accessing the internal
byte array is not safe. |
abstract int |
capacity()
Returns the capacity of this
Buffer . |
static Buffer |
copyOf(byte[] src)
Deprecated.
This method is to be removed. Plugins should no longer call it directly.
|
static Buffer |
copyOf(byte[] src,
int index,
int length)
Deprecated.
This method is to be removed. Plugins should no longer call it directly.
|
abstract void |
getBytes(int index,
Buffer dest,
int destIndex,
int length)
|
abstract void |
getBytes(int index,
byte[] dest,
int destIndex,
int length)
|
abstract int |
limit()
Returns the current limit of this
Buffer . |
abstract Buffer |
limit(int limit)
Sets the current limit of this
Buffer . |
abstract int |
offset()
Returns the current offset of this
Buffer . |
abstract Buffer |
offset(int offset)
Sets the current offset of this
Buffer . |
abstract void |
release()
Releases this
Buffer . |
abstract void |
setBytes(int index,
Buffer source,
int sourceIndex,
int length)
|
abstract void |
setBytes(int index,
byte[] source,
int sourceIndex,
int length)
|
static Buffer |
wrap(byte[] src)
Deprecated.
This method is to be removed. Plugins should no longer call it directly.
|
static Buffer |
wrap(byte[] src,
int offset,
int size)
Deprecated.
This method is to be removed. Plugins should no longer call it directly.
|
protected Buffer()
@Deprecated protected Buffer(byte[] wrap, int offset, int capacity)
@Deprecated public abstract byte[] array()
byte
array is not safe.byte
array of this Buffer
.byte
arraypublic abstract int offset()
Buffer
.public abstract Buffer offset(int offset)
Buffer
.offset
- the offset to setBuffer
itselfpublic abstract int limit()
Buffer
.public abstract Buffer limit(int limit)
Buffer
.limit
- the limit to setBuffer
itselfpublic abstract int capacity()
Buffer
.
The capacity does not change once created.
public abstract void setBytes(int index, byte[] source, int sourceIndex, int length)
index
- starting position in this destination Buffer
source
- the source arraysourceIndex
- starting position in the source arraylength
- the number of bytes to be copiedpublic abstract void setBytes(int index, Buffer source, int sourceIndex, int length)
public abstract void getBytes(int index, byte[] dest, int destIndex, int length)
index
- starting position in this source Buffer
dest
- the destination arraydestIndex
- starting position in the destination arraylength
- the number of bytes to be copiedpublic abstract void getBytes(int index, Buffer dest, int destIndex, int length)
public abstract void release()
Buffer
.@Deprecated public static Buffer allocate(int length)
Buffer
instance.@Deprecated public static Buffer copyOf(byte[] src)
Buffer
instance copied from src
.src
- the source byte arrayBuffer
@Deprecated public static Buffer copyOf(byte[] src, int index, int length)
Buffer
instance copied from src
.src
- the source byte arrayindex
- starting position in the source arraylength
- the number of bytes to be copiedBuffer
@Deprecated public static Buffer wrap(byte[] src)
Buffer
instance wrapping src
as the internal array.src
- the source byte arrayBuffer
@Deprecated public static Buffer wrap(byte[] src, int offset, int size)
Buffer
instance wrapping src
as the internal array.src
- the source byte arrayoffset
- starting position in the source arraysize
- the number of bytes to be wrappedBuffer