Package org.apache.mina.util.byteaccess
Class CompositeByteArrayRelativeReader
java.lang.Object
org.apache.mina.util.byteaccess.CompositeByteArrayRelativeBase
org.apache.mina.util.byteaccess.CompositeByteArrayRelativeReader
- All Implemented Interfaces:
IoRelativeReader
public class CompositeByteArrayRelativeReader
extends CompositeByteArrayRelativeBase
implements IoRelativeReader
Provides restricted, relative, read-only access to the bytes in a
CompositeByteArray. Using this interface has the advantage
that it can be automatically determined when a component
ByteArray can no longer be read, and thus components can be
automatically freed. This makes it easier to use pooling for underlying
ByteArrays.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final booleanWhether or not to free componentCompositeByteArrays when the cursor moves past them.Fields inherited from class org.apache.mina.util.byteaccess.CompositeByteArrayRelativeBase
cba, cursor -
Constructor Summary
ConstructorsConstructorDescriptionCompositeByteArrayRelativeReader(CompositeByteArray cba, boolean autoFree) Creates a new instance of CompositeByteArrayRelativeReader. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidCalled whenever the cursor has passed from thecba's first component.byteget()voidplaces the data starting at current position into the suppliedIoBufferchargetChar()doublefloatgetFloat()intgetInt()longgetLong()shortgetShort()voidskip(int length) Advances the reader by the given number of bytes.slice(int length) Methods inherited from class org.apache.mina.util.byteaccess.CompositeByteArrayRelativeBase
append, free, getIndex, getRemaining, hasRemaining, last, orderMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.mina.util.byteaccess.IoRelativeReader
getRemaining, hasRemaining, order
-
Field Details
-
autoFree
private final boolean autoFreeWhether or not to free componentCompositeByteArrays when the cursor moves past them.
-
-
Constructor Details
-
CompositeByteArrayRelativeReader
Creates a new instance of CompositeByteArrayRelativeReader.- Parameters:
cba- The backing ByteArrayautoFree- If data should be freed once it has been passed in the list
-
-
Method Details
-
cursorPassedFirstComponent
protected void cursorPassedFirstComponent()Description copied from class:CompositeByteArrayRelativeBaseCalled whenever the cursor has passed from thecba's first component. As the first component is no longer used, this provides a good opportunity for subclasses to perform some action on it (such as freeing it).- Specified by:
cursorPassedFirstComponentin classCompositeByteArrayRelativeBase
-
skip
public void skip(int length) Advances the reader by the given number of bytes.- Specified by:
skipin interfaceIoRelativeReader- Parameters:
length- the number of bytes to skip
-
slice
- Specified by:
slicein interfaceIoRelativeReader- Parameters:
length- The number of bytes to get- Returns:
- an array with a view of part of this array.
-
get
public byte get()- Specified by:
getin interfaceIoRelativeReader- Returns:
- the byte at the current position in the buffer
-
get
places the data starting at current position into the suppliedIoBuffer- Specified by:
getin interfaceIoRelativeReader- Parameters:
bb- The IoBuffer that will contain the read bytes
-
getShort
public short getShort()- Specified by:
getShortin interfaceIoRelativeReader- Returns:
- a
shortand advances the reader.
-
getInt
public int getInt()- Specified by:
getIntin interfaceIoRelativeReader- Returns:
- an
intand advances the reader.
-
getLong
public long getLong()- Specified by:
getLongin interfaceIoRelativeReader- Returns:
- a
longand advances the reader.
-
getFloat
public float getFloat()- Specified by:
getFloatin interfaceIoRelativeReader- Returns:
- a
floatand advances the reader.
-
getDouble
public double getDouble()- Specified by:
getDoublein interfaceIoRelativeReader- Returns:
- a
doubleand advances the reader.
-
getChar
public char getChar()- Specified by:
getCharin interfaceIoRelativeReader- Returns:
- a
charand advances the reader.
-