Top Description Methods
com.amazon.ion.impl

pack-priv Interface ByteBuffer

Known Direct Implementers
com.amazon.ion.impl.SimpleByteBuffer
Imports
java.io.IOException, .OutputStream

This is a general purpose interface to support operations over byte sources for Ion operations. The implementations are resposible for managing container state during operations as well as the underlying data in the buffer itself.

Method Summary

Modifier and TypeMethod and Description
public byte[]

Returns:

a copy of the buffer in a new byte array
getBytes
()

wraps up the current buffer as a new byte array and passed ownership of the copy to the caller.

public int

Returns:

number of bytes actually copied
getBytes
(byte[]
users byte array to copy into
buffer
,
int
first byte of the array to use
offset
,
int
length of the byte array available to copy into
length
)

copies the contents of the buffer into a user supplied byte array.

public ByteReader

Returns:

a new reader
getReader
()

creates a reader and sets it to the beginning of the buffer under managment here for use.

public ByteWriter

Returns:

a new writer
getWriter
()

creates a writer and sets it to the beginning of the buffer under managment here for use.

public void
writeBytes(OutputStream
stream to write into
out
)

copies the contents of the buffer into and output stream.

Method Detail

getBytesback to summary
public byte[] getBytes()

wraps up the current buffer as a new byte array and passed ownership of the copy to the caller.

Returns:byte[]

a copy of the buffer in a new byte array

getBytesback to summary
public int getBytes(byte[] buffer, int offset, int length)

copies the contents of the buffer into a user supplied byte array. It copies into the user buffer starting at the supplied offset and attempts to copy no more than length bytes. If the implmentation cannot determine the length to be copied before copying it may overwrite some of the user buffer and will throw at the end of the copy. (note that is may throw an out of bounds exception if the write extends beyond the length of the callers array)

Parameters
buffer:byte[]

users byte array to copy into

offset:int

first byte of the array to use

length:int

length of the byte array available to copy into

Returns:int

number of bytes actually copied

getReaderback to summary
public ByteReader getReader()

creates a reader and sets it to the beginning of the buffer under managment here for use.

Returns:ByteReader

a new reader

getWriterback to summary
public ByteWriter getWriter()

creates a writer and sets it to the beginning of the buffer under managment here for use.

Returns:ByteWriter

a new writer

writeBytesback to summary
public void writeBytes(OutputStream out) throws IOException

copies the contents of the buffer into and output stream.

Parameters
out:OutputStream

stream to write into