|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jwadlib.WadByteBuffer
public class WadByteBuffer
A wrapper class for the ByteBuffer
class that
specifically is designed to work with WAD file data. All data is read in little endian
mode.
Field Summary | |
---|---|
private java.nio.ByteBuffer |
bytebuffer
The ByteBuffer that backs the WadByteBuffer . |
private int |
length
The number of bytes this WadByteBuffer contains in
it's ByteBuffer . |
Constructor Summary | |
---|---|
WadByteBuffer(byte[] bytearray)
Creates a WadByteBuffer from an array of bytes. |
|
WadByteBuffer(java.nio.channels.FileChannel bufferchannel)
Creates a WadByteBuffer from a FileChannel from the beginning to the end of the channel. |
|
WadByteBuffer(java.nio.channels.FileChannel bufferchannel,
int bufferlength)
Creates a WadByteBuffer from a FileChannel from the beginning of the channel until the number of specified bytes are read. |
|
WadByteBuffer(java.nio.channels.FileChannel bufferchannel,
int bufferlength,
int position)
Creates a WadByteBuffer from a FileChannel from the indicated position until the number of specified bytes are read. |
|
WadByteBuffer(int buffersize)
Creates an empty WadByteBuffer of a set size. |
|
WadByteBuffer(WadByteBuffer bytebuffer)
Creates a WadByteBuffer from another WadByteBuffer . |
Method Summary | |
---|---|
boolean |
alterBufferSize(int newsize)
Changes the size of the WadByteBuffer's backing
ByteBuffer . |
static java.lang.String |
convertToEightByteString(java.lang.String string)
Converts a String to a new eight byte String by padding Strings less
than eight characters and truncating Strings greater
than eight characters. |
private byte[] |
getArray()
Returns an array of bytes containing the contents of the ByteBuffer . |
byte |
getByte()
A wrapper class for ByteBuffer's get() method; gets the next byte in the WadByteBuffer . |
byte |
getByte(int index)
A wrapper class for ByteBuffer's get(int) method; gets the next byte in the WadByteBuffer , starting at the specified position. |
java.nio.ByteBuffer |
getByteBuffer()
Returns the backing ByteBuffer of the WadByteBuffer . |
WadByteBuffer |
getByteBuffer(int offset,
int length)
Gets a sub- WadByteBuffer out of the current one,
by getting a specified number of bytes starting at a specified position in
the buffer. |
int |
getCapacity()
Returns the capacity of the ByteBuffer . |
java.lang.String |
getEightByteString()
Gets the next eight bytes in the WadByteBuffer as a
String . |
java.lang.String |
getEightByteString(int index)
Gets the next eight bytes in the WadByteBuffer as a
String , starting at the specified position. |
int |
getInt()
A wrapper class for ByteBuffer's getInt() method; gets the next integer in the WadByteBuffer . |
int |
getInt(int index)
A wrapper class for ByteBuffer's getInt(int) method; gets the next integer in the WadByteBuffer , starting at the specified position. |
int |
getLength()
Returns the length of the WadByteBuffer . |
int |
getPosition()
A wrapper class for ByteBuffer's position() method; returns the WadByteBuffer's position. |
short |
getShort()
A wrapper class for ByteBuffer's getShort() method; gets the next short in the WadByteBuffer . |
short |
getShort(int index)
A wrapper class for ByteBuffer's getShort(int) method; gets the next short in the WadByteBuffer , starting at the specified position. |
boolean |
hasRemaining()
A wrapper class for ByteBuffer's hasRemaining() method; returns true
if the WadByteBuffer has any values left past the
current position. |
WadByteBuffer |
put(byte b)
A wrapper class for ByteBuffer's put(byte) method; puts a single byte into
the WadByteBuffer . |
WadByteBuffer |
put(int index,
byte b)
A wrapper class for ByteBuffer's put(int, byte) method; puts a single byte into
the WadByteBuffer at the specified position. |
WadByteBuffer |
put(WadByteBuffer src)
A wrapper class for ByteBuffer's put(ByteBuffer) method; puts a ByteBuffer into the WadByteBuffer . |
WadByteBuffer |
putEightByteString(char[] value)
Puts eight bytes in the WadByteBuffer as an array
of characters. |
WadByteBuffer |
putEightByteString(int index,
char[] value)
Puts eight bytes in the WadByteBuffer as an array
of characters, at the specified position. |
WadByteBuffer |
putEightByteString(int index,
java.lang.String value)
Puts eight bytes in the WadByteBuffer as a
String at the specified position. |
WadByteBuffer |
putEightByteString(java.lang.String value)
Puts eight bytes in the WadByteBuffer as a
String . |
WadByteBuffer |
putInt(int value)
A wrapper class for ByteBuffer's putInt(int) method; puts an integer into
the WadByteBuffer . |
WadByteBuffer |
putInt(int index,
int value)
A wrapper class for ByteBuffer's putInt(int) method; puts an integer into
the WadByteBuffer . |
WadByteBuffer |
putShort(int index,
short value)
A wrapper class for ByteBuffer's putShort(short) method; puts a short into
the WadByteBuffer . |
WadByteBuffer |
putShort(short value)
A wrapper class for ByteBuffer's putShort(short) method; puts a short into
the WadByteBuffer . |
WadByteBuffer |
setPosition(int index)
A wrapper class for ByteBuffer's position(int) method; sets the WadByteBuffer's position to the specified integer and returns
the WadByteBuffer object that called it. |
boolean |
writeToFile(java.nio.channels.FileChannel filechannel)
Writes this WadByteBuffer's data to the specified channel. |
boolean |
writeToFile(java.nio.channels.FileChannel filechannel,
long position)
Writes this WadByteBuffer's data to the specified channel,
at the specified position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.nio.ByteBuffer bytebuffer
ByteBuffer
that backs the WadByteBuffer
.
private int length
WadByteBuffer
contains in
it's ByteBuffer
.
Constructor Detail |
---|
public WadByteBuffer(int buffersize)
WadByteBuffer
of a set size.
buffersize
- the size, in bytes, to allocate for the buffer.public WadByteBuffer(java.nio.channels.FileChannel bufferchannel) throws UnableToReadWADFileException
WadByteBuffer
from a FileChannel
from the beginning to the end of the channel.
bufferchannel
- the FileChannel
to read from.
UnableToReadWADFileException
- if the WAD file cannot be read from or to
the specified points.public WadByteBuffer(java.nio.channels.FileChannel bufferchannel, int bufferlength) throws UnableToReadWADFileException
WadByteBuffer
from a FileChannel
from the beginning of the channel until the number of specified bytes are read.
bufferchannel
- the FileChannel
to read from.bufferlength
- the number of bytes to read from the starting position
of the FileChannel
.
UnableToReadWADFileException
- if the WAD file cannot be read from or to
the specified points.public WadByteBuffer(java.nio.channels.FileChannel bufferchannel, int bufferlength, int position) throws UnableToReadWADFileException
WadByteBuffer
from a FileChannel
from the indicated position until the number of specified bytes are read.
bufferchannel
- the FileChannel
to read from.bufferlength
- the number of bytes to read from the starting position
of the FileChannel
.position
- the starting position to read from the FileChannel
.
UnableToReadWADFileException
- if the WAD file cannot be read from or to
the specified points.public WadByteBuffer(WadByteBuffer bytebuffer)
WadByteBuffer
from another WadByteBuffer
.
bytebuffer
- the WadByteBuffer
to create the new
WadByteBuffer
from.public WadByteBuffer(byte[] bytearray)
WadByteBuffer
from an array of bytes.
bytearray
- the array of bytes to create the WadByteBuffer
from.Method Detail |
---|
private byte[] getArray()
ByteBuffer
.
ByteBuffer
.public byte getByte()
ByteBuffer's
get()
method; gets the next byte in the WadByteBuffer
.
WadByteBuffer
.public byte getByte(int index)
ByteBuffer's
get(int)
method; gets the next byte in the WadByteBuffer
, starting at the specified position.
Unlike the method it wraps, this method increments the position counter.
index
- the starting position of the of the WadByteBuffer
.
WadByteBuffer
, from
the specified position.public WadByteBuffer getByteBuffer(int offset, int length)
WadByteBuffer
out of the current one,
by getting a specified number of bytes starting at a specified position in
the buffer.
offset
- the starting position for getting bytes in the current
WadByteBuffer
.length
- the number of bytes to get from the starting position in the
WadByteBuffer
.
WadByteBuffer
consisting of the bytes
from the starting position to the ending position based on the number of bytes
to get.public short getShort()
ByteBuffer's
getShort()
method; gets the next short in the WadByteBuffer
.
WadByteBuffer
.public short getShort(int index)
ByteBuffer's
getShort(int)
method; gets the next short in the WadByteBuffer
, starting at the specified position.
Unlike the method it wraps, this method increments the position counter.
index
- the starting position of the of the WadByteBuffer
.
WadByteBuffer
, from
the specified position.public int getInt()
ByteBuffer's
getInt()
method; gets the next integer in the WadByteBuffer
.
WadByteBuffer
.public int getInt(int index)
ByteBuffer's
getInt(int)
method; gets the next integer in the WadByteBuffer
, starting at the specified position.
Unlike the method it wraps, this method increments the position counter.
index
- the starting position of the of the WadByteBuffer
.
WadByteBuffer
, from
the specified position.public java.lang.String getEightByteString(int index)
WadByteBuffer
as a
String
, starting at the specified position. Each
byte is a new character.
index
- the starting position of the of the WadByteBuffer
.
String
, from the
specified position.public java.lang.String getEightByteString()
WadByteBuffer
as a
String
. Each byte is a new character.
String
.public WadByteBuffer put(byte b) throws java.nio.BufferOverflowException, java.nio.ReadOnlyBufferException
ByteBuffer's
put(byte)
method; puts a single byte into
the WadByteBuffer
.
b
- the byte to insert into the WadByteBuffer
.
WadByteBuffer
.
java.nio.BufferOverflowException
- if the current position is not smaller
than the limit of the ByteBuffer
.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer put(int index, byte b) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
ByteBuffer's
put(int, byte)
method; puts a single byte into
the WadByteBuffer
at the specified position.
Unlike the method it wraps, this method increments the position counter.
index
- the position to insert the byte.b
- the byte to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer put(WadByteBuffer src) throws java.nio.BufferOverflowException, java.lang.IllegalArgumentException, java.nio.ReadOnlyBufferException
ByteBuffer's
put(ByteBuffer)
method; puts a ByteBuffer
into the WadByteBuffer
.
src
- the WadByteBuffer
to insert.
WadByteBuffer
.
java.nio.BufferOverflowException
- if the current position is not smaller
than the limit of the ByteBuffer
.
java.lang.IllegalArgumentException
- if the source buffer and this buffer are
the same.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putShort(short value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
ByteBuffer's
putShort(short)
method; puts a short into
the WadByteBuffer
.
value
- the short to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putShort(int index, short value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
ByteBuffer's
putShort(short)
method; puts a short into
the WadByteBuffer
.
Unlike the method it wraps, this method increments the position counter.
index
- the position to insert the value.value
- the short to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putInt(int value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
ByteBuffer's
putInt(int)
method; puts an integer into
the WadByteBuffer
.
value
- the integer to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putInt(int index, int value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
ByteBuffer's
putInt(int)
method; puts an integer into
the WadByteBuffer
.
Unlike the method it wraps, this method increments the position counter.
index
- the position to insert the value.value
- the integer to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putEightByteString(int index, java.lang.String value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
WadByteBuffer
as a
String
at the specified position. Each byte is a
new character.
index
- the position to insert the value.value
- the String
to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putEightByteString(java.lang.String value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
WadByteBuffer
as a
String
. Each byte is a new character.
value
- the String
to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putEightByteString(int index, char[] value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
WadByteBuffer
as an array
of characters, at the specified position. Each byte is a new character.
index
- the position to insert the value.value
- the character array to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public WadByteBuffer putEightByteString(char[] value) throws java.lang.IndexOutOfBoundsException, java.nio.ReadOnlyBufferException
WadByteBuffer
as an array
of characters. Each byte is a new character.
value
- the character array to insert into the WadByteBuffer
.
WadByteBuffer
.
java.lang.IndexOutOfBoundsException
- if index is not positive or out of
the ByteBuffer's
limit.
java.nio.ReadOnlyBufferException
- if the ByteBuffer
cannot
be written to.public boolean hasRemaining()
ByteBuffer's
hasRemaining()
method; returns true
if the WadByteBuffer
has any values left past the
current position.
WadByteBuffer
has any values left past the
current position, otherwise false.public int getPosition()
ByteBuffer's
position()
method; returns the WadByteBuffer's
position.
WadByteBuffer
.public WadByteBuffer setPosition(int index) throws java.lang.IllegalArgumentException
ByteBuffer's
position(int)
method; sets the WadByteBuffer's
position to the specified integer and returns
the WadByteBuffer
object that called it.
index
- the integer to set the WadByteBuffer's
position to.
WadByteBuffer
object that called it.
java.lang.IllegalArgumentException
- if the index is negative or larger
than the current limit.public int getLength()
WadByteBuffer
.
WadByteBuffer
.public int getCapacity()
ByteBuffer
.
ByteBuffer
.public java.nio.ByteBuffer getByteBuffer()
ByteBuffer
of the WadByteBuffer
.
ByteBuffer
of the WadByteBuffer
.public boolean writeToFile(java.nio.channels.FileChannel filechannel) throws java.io.IOException
WadByteBuffer's
data to the specified channel.
filechannel
- the FileChannel
to
write to.
java.io.IOException
- if the data cannot be written to the file.public boolean writeToFile(java.nio.channels.FileChannel filechannel, long position) throws java.io.IOException
WadByteBuffer's
data to the specified channel,
at the specified position.
filechannel
- the FileChannel
to
write to.position
- the position in the file to start writing the data.
java.io.IOException
- if the data cannot be written to the file.public boolean alterBufferSize(int newsize)
WadByteBuffer's
backing
ByteBuffer
.
newsize
- the size the new ByteBuffer
should
be.
public static java.lang.String convertToEightByteString(java.lang.String string)
String
to a new eight byte String
by padding Strings
less
than eight characters and truncating Strings
greater
than eight characters. All the letters are converted to uppercase and all
illegal characters are trimmed out. The legal characters are capital A through
Z and 0 through 9 along with "[", "]", "-", "_", "\" and the null character.
string
- the String
to convert to an eight
byte String
.
String
.
|
jwadlib WAD Library Extending API Version 1.0 Alpha 1 Intended for developers wishing to extend jwadlib, not implement it. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |