Class ExpandableBufferWriter
- java.lang.Object
-
- com.sun.enterprise.mgmt.transport.buffers.ExpandableBufferWriter
-
- Direct Known Subclasses:
Grizzly2ExpandableBufferWriter
public abstract class ExpandableBufferWriter extends java.lang.ObjectExpandable Buffer writer, which adopts its size during while getting more data.- Author:
- Alexey Stashok
-
-
Constructor Summary
Constructors Constructor Description ExpandableBufferWriter()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.io.OutputStreamasOutputStream()protected abstract voidensureCapacity(int delta)abstract BuffergetBuffer()abstract intposition()abstract voidposition(int pos)ExpandableBufferWriterput(byte b)Relative put method (optional operation).ExpandableBufferWriterput(byte[] src)Relative bulk put method (optional operation).ExpandableBufferWriterput(byte[] src, int offset, int length)Relative bulk put method (optional operation).ExpandableBufferWriterput(int index, byte b)Absolute put method (optional operation).ExpandableBufferWriterputChar(char value)Relative put method for writing a char value (optional operation).ExpandableBufferWriterputChar(int index, char value)Absolute put method for writing a char value (optional operation).ExpandableBufferWriterputDouble(double value)Relative put method for writing a double value (optional operation).ExpandableBufferWriterputDouble(int index, double value)Absolute put method for writing a double value (optional operation).ExpandableBufferWriterputFloat(float value)Relative put method for writing a float value (optional operation).ExpandableBufferWriterputFloat(int index, float value)Absolute put method for writing a float value (optional operation).ExpandableBufferWriterputInt(int value)Relative put method for writing an int value (optional operation).ExpandableBufferWriterputInt(int index, int value)Absolute put method for writing an int value (optional operation).ExpandableBufferWriterputLong(int index, long value)Absolute put method for writing a long value (optional operation).ExpandableBufferWriterputLong(long value)Relative put method for writing a long value (optional operation).ExpandableBufferWriterputShort(int index, short value)Absolute put method for writing a short value (optional operation).ExpandableBufferWriterputShort(short value)Relative put method for writing a short value (optional operation).voidreserve(int size)abstract BuffertoBuffer()
-
-
-
Method Detail
-
getBuffer
public abstract Buffer getBuffer()
-
toBuffer
public abstract Buffer toBuffer()
-
position
public abstract int position()
-
position
public abstract void position(int pos)
-
ensureCapacity
protected abstract void ensureCapacity(int delta)
-
reserve
public void reserve(int size)
-
put
public ExpandableBufferWriter put(byte b)
Relative put method (optional operation).Writes the given byte into this buffer at the current position, and then increments the position.
- Parameters:
b- The byte to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If this buffer's current position is not smaller than its limitjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
put
public ExpandableBufferWriter put(int index, byte b)
Absolute put method (optional operation).Writes the given byte into this buffer at the given index.
- Parameters:
index- The index at which the byte will be writtenb- The byte value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limitjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
put
public ExpandableBufferWriter put(byte[] src)
Relative bulk put method (optional operation).This method transfers the entire content of the given source byte array into this buffer. An invocation of this method of the form dst.put(a) behaves in exactly the same way as the invocation
dst.put(a, 0, a.length)
- Parameters:
src- the source byte array- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there is insufficient space in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
put
public ExpandableBufferWriter put(byte[] src, int offset, int length)
Relative bulk put method (optional operation).This method transfers bytes into this buffer from the given source array. If there are more bytes to be copied from the array than remain in this buffer, that is, if length > remaining(), then no bytes are transferred and a
BufferOverflowExceptionis thrown.Otherwise, this method copies length bytes from the given array into this buffer, starting at the given offset in the array and at the current position of this buffer. The position of this buffer is then incremented by length.
In other words, an invocation of this method of the form dst.put(src, off, len) has exactly the same effect as the loop
for (int i = off; i < off + len; i++) dst.put(a[i]);except that it first checks that there is sufficient space in this buffer and it is potentially much more efficient.- Parameters:
src- The array from which bytes are to be readoffset- The offset within the array of the first byte to be read; must be non-negative and no larger than array.lengthlength- The number of bytes to be read from the given array; must be non-negative and no larger than array.length - offset- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there is insufficient space in this bufferjava.lang.IndexOutOfBoundsException- If the preconditions on the offset and length parameters do not holdjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putChar
public ExpandableBufferWriter putChar(char value)
Relative put method for writing a char value (optional operation).Writes two bytes containing the given char value, in the current byte order, into this buffer at the current position, and then increments the position by two.
- Parameters:
value- The char value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than two bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putChar
public ExpandableBufferWriter putChar(int index, char value)
Absolute put method for writing a char value (optional operation).Writes two bytes containing the given char value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The char value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus onejava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putShort
public ExpandableBufferWriter putShort(short value)
Relative put method for writing a short value (optional operation).Writes two bytes containing the given short value, in the current byte order, into this buffer at the current position, and then increments the position by two.
- Parameters:
value- The short value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than two bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putShort
public ExpandableBufferWriter putShort(int index, short value)
Absolute put method for writing a short value (optional operation).Writes two bytes containing the given short value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The short value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus onejava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putInt
public ExpandableBufferWriter putInt(int value)
Relative put method for writing an int value (optional operation).Writes four bytes containing the given int value, in the current byte order, into this buffer at the current position, and then increments the position by four.
- Parameters:
value- The int value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than four bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putInt
public ExpandableBufferWriter putInt(int index, int value)
Absolute put method for writing an int value (optional operation).Writes four bytes containing the given int value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The int value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus threejava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putLong
public ExpandableBufferWriter putLong(long value)
Relative put method for writing a long value (optional operation).Writes eight bytes containing the given long value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
- Parameters:
value- The long value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than eight bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putLong
public ExpandableBufferWriter putLong(int index, long value)
Absolute put method for writing a long value (optional operation).Writes eight bytes containing the given long value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The long value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus sevenjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putFloat
public ExpandableBufferWriter putFloat(float value)
Relative put method for writing a float value (optional operation).Writes four bytes containing the given float value, in the current byte order, into this buffer at the current position, and then increments the position by four.
- Parameters:
value- The float value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than four bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putFloat
public ExpandableBufferWriter putFloat(int index, float value)
Absolute put method for writing a float value (optional operation).Writes four bytes containing the given float value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The float value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus threejava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putDouble
public ExpandableBufferWriter putDouble(double value)
Relative put method for writing a double value (optional operation).Writes eight bytes containing the given double value, in the current byte order, into this buffer at the current position, and then increments the position by eight.
- Parameters:
value- The double value to be written- Returns:
- This buffer writer
- Throws:
java.nio.BufferOverflowException- If there are fewer than eight bytes remaining in this bufferjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
putDouble
public ExpandableBufferWriter putDouble(int index, double value)
Absolute put method for writing a double value (optional operation).Writes eight bytes containing the given double value, in the current byte order, into this buffer at the given index.
- Parameters:
index- The index at which the bytes will be writtenvalue- The double value to be written- Returns:
- This buffer writer
- Throws:
java.lang.IndexOutOfBoundsException- If index is negative or not smaller than the buffer's limit, minus sevenjava.nio.ReadOnlyBufferException- If this buffer is read-only
-
asOutputStream
public java.io.OutputStream asOutputStream()
-
-