APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.tools.javac.util

public Class ByteBuffer

extends Object
Class Inheritance
Imports
java.io.*

A byte buffer is a flexible array which grows when elements are appended. There are also methods to append names to byte buffers and to convert byte buffers to names.

This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
ByteBuffer.UnderflowException

Thrown when trying to read past the end of the buffer.

Field Summary

Modifier and TypeField and Description
public byte[]
elems

An array holding the bytes in this buffer; can be grown.

public int
length

The current number of defined bytes in this buffer.

Constructor Summary

AccessConstructor and Description
public
ByteBuffer()

Create a new byte buffer.

public
ByteBuffer(int initialSize)

Create a new byte buffer with an initial elements array of given size.

public
ByteBuffer(byte[] elems)

Create a new byte buffer using the given array for storage.

Method Summary

Modifier and TypeMethod and Description
public void
appendByte(int b)

Append byte to this buffer.

public void
appendBytes(byte[] bs, int start, int len)

Append `len' bytes from byte array, starting at given `start' offset.

public void
appendBytes(byte[] bs)

Append all bytes from given byte array.

public void
appendChar(int x)

Append a character as a two byte number.

public void
appendDouble(double x)

Append a double as a eight byte number.

public void
appendFloat(float x)

Append a float as a four byte number.

public void
appendInt(int x)

Append an integer as a four byte number.

public void
appendLong(long x)

Append a long as an eight byte number.

public void
appendName(Name name)

Append a name encoded in Modified UTF-8.

public void
appendStream(InputStream input)

Append the content of the given input stream.

public ByteBuffer
asByteBuffer()

Create a java.nio.ByteBuffer view of this instance.

public byte
getByte(int
starting offset
bp
)

Extract a byte at position bp from elems.

public char
getChar(int
starting offset
bp
)

Extract a character at position bp from elems.

public double
getDouble(int
starting offset
bp
)

Extract a double at position bp from elems.

public float
getFloat(int
starting offset
bp
)

Extract a float at position bp from elems.

public int
getInt(int
starting offset
bp
)

Extract an integer at position bp from elems.

public long
getLong(int
starting offset
bp
)

Extract a long integer at position bp from elems.

public void
reset()

Reset to zero length.

public Name
toName(Names names)

Convert contents to name.

public void
verifyRange(int
starting offset
off
,
int
required length
len
)

Verify there are at least the specified number of bytes in this buffer at the specified offset.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

elemsback to summary
public byte[] elems

An array holding the bytes in this buffer; can be grown.

lengthback to summary
public int length

The current number of defined bytes in this buffer.

Constructor Detail

ByteBufferback to summary
public ByteBuffer()

Create a new byte buffer.

ByteBufferback to summary
public ByteBuffer(int initialSize)

Create a new byte buffer with an initial elements array of given size.

ByteBufferback to summary
public ByteBuffer(byte[] elems)

Create a new byte buffer using the given array for storage.

Method Detail

appendByteback to summary
public void appendByte(int b)

Append byte to this buffer.

appendBytesback to summary
public void appendBytes(byte[] bs, int start, int len)

Append `len' bytes from byte array, starting at given `start' offset.

appendBytesback to summary
public void appendBytes(byte[] bs)

Append all bytes from given byte array.

appendCharback to summary
public void appendChar(int x)

Append a character as a two byte number.

appendDoubleback to summary
public void appendDouble(double x)

Append a double as a eight byte number.

appendFloatback to summary
public void appendFloat(float x)

Append a float as a four byte number.

appendIntback to summary
public void appendInt(int x)

Append an integer as a four byte number.

appendLongback to summary
public void appendLong(long x)

Append a long as an eight byte number.

appendNameback to summary
public void appendName(Name name)

Append a name encoded in Modified UTF-8.

appendStreamback to summary
public void appendStream(InputStream input) throws IOException

Append the content of the given input stream.

asByteBufferback to summary
public ByteBuffer asByteBuffer()

Create a java.nio.ByteBuffer view of this instance.

If this instance is modified, the returned buffer may no longer reflect it.

getByteback to summary
public byte getByte(int bp) throws UnderflowException

Extract a byte at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
getCharback to summary
public char getChar(int bp) throws UnderflowException

Extract a character at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
getDoubleback to summary
public double getDouble(int bp) throws UnderflowException

Extract a double at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
getFloatback to summary
public float getFloat(int bp) throws UnderflowException

Extract a float at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
getIntback to summary
public int getInt(int bp) throws UnderflowException

Extract an integer at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
getLongback to summary
public long getLong(int bp) throws UnderflowException

Extract a long integer at position bp from elems.

Parameters
bp:int

starting offset

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if bp is negative
resetback to summary
public void reset()

Reset to zero length.

toNameback to summary
public Name toName(Names names) throws InvalidUtfException

Convert contents to name.

Exceptions
InvalidUtfException:
if invalid Modified UTF-8 is encountered
verifyRangeback to summary
public void verifyRange(int off, int len) throws UnderflowException

Verify there are at least the specified number of bytes in this buffer at the specified offset.

Parameters
off:int

starting offset

len:int

required length

Exceptions
UnderflowException:
if there is not enough data in this buffer
IllegalArgumentException:
if off or len is negative
com.sun.tools.javac.util back to summary

public Class ByteBuffer.UnderflowException

extends Exception
Class Inheritance

Thrown when trying to read past the end of the buffer.

Field Summary

Modifier and TypeField and Description
private final int
private static final long

Constructor Summary

AccessConstructor and Description
public
UnderflowException(int length)

Method Summary

Modifier and TypeMethod and Description
public int
getLength()

Get the length of the buffer, which apparently is not long enough.

Field Detail

lengthback to summary
private final int length
serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.Exception.serialVersionUID.

Constructor Detail

UnderflowExceptionback to summary
public UnderflowException(int length)

Method Detail

getLengthback to summary
public int getLength()

Get the length of the buffer, which apparently is not long enough.