|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.j3d.loaders.stl.LittleEndianConverter
public class LittleEndianConverter
Utility to convert little endain data to big endian data.
TODO: Extend to convert big endian to little endain data and write to
OutputStream
Constructor Summary | |
---|---|
LittleEndianConverter()
|
Method Summary | |
---|---|
static int |
convertToBigEndian(byte[] srcBuffer,
int[] destBuffer,
int srcLength,
int destOffset,
int destLength)
Converts little endian data in srcBuffer to big endian
signed integer (4 bytes long) data. |
static int |
convertToBigEndian(byte[] srcBuffer,
int[] destBuffer,
int srcLength,
int destOffset,
int destLength,
int mask)
Converts little endian data in srcBuffer to big endian
integer (4 bytes long) data. |
static int |
convertToBigEndian(byte[] srcBuffer,
short[] destBuffer,
int srcLength,
int destOffset,
int destLength)
Converts little endian data in srcBuffer to big endian
signed short (2 bytes long) data. |
static int |
convertToBigEndian(byte[] srcBuffer,
short[] destBuffer,
int srcLength,
int destOffset,
int destLength,
short mask)
Converts little endian data in srcBuffer to big endian
short (2 bytes long) data. |
static int |
convertToBigEndian(int blockSize,
byte[] srcBuffer,
int[] destBuffer,
int srcLength,
int destOffset,
int destLength)
Converts little endian data in srcBuffer to big endian
signed integer data with a user defined block size of 2, 3, or 4 bytes. |
static int |
convertToBigEndian(int blockSize,
byte[] srcBuffer,
int[] destBuffer,
int srcLength,
int destOffset,
int destLength,
int mask)
Converts little endian data in srcBuffer to big endian
signed integer data with a user defined block size of 2, 3, or 4 bytes. |
static int |
read(byte[] readBuffer,
int[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream)
Reads little endian data from an InputStream and converts
it to big endian signed int (4 bytes long) data. |
static int |
read(byte[] readBuffer,
int[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream,
int mask)
Reads little endian data from an InputStream and converts
it to big endian int (4 bytes long) data. |
static int |
read(byte[] readBuffer,
short[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream)
Reads little endian data from an InputStream and converts
it to big endian signed short (2 bytes long) data. |
static int |
read(byte[] readBuffer,
short[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream,
short mask)
Reads little endian data from an InputStream and converts
it to big endian short (2 bytes long) data. |
static int |
read(int blockSize,
byte[] readBuffer,
int[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream)
Reads little endian data from an InputStream and converts
it to to big endian signed integer data with a user defined block size
of 1, 2, 3, or 4 bytes (1 is here for conveniance). |
static int |
read(int blockSize,
byte[] readBuffer,
int[] destBuffer,
int destOffset,
int destLength,
java.io.InputStream stream,
int mask)
Reads little endian data from an InputStream and converts
it to to big endian signed integer data with a user defined block size
of 1, 2, 3, or 4 bytes (1 is here for conveniance). |
static int |
read2ByteBlock(java.io.InputStream stream)
Reads 2 bytes in little endian format and converts it to a signed int. |
static int |
read3ByteBlock(java.io.InputStream stream)
Reads 3 bytes in little endian format and converts it to a signed int. |
static int |
read4ByteBlock(java.io.InputStream stream)
Reads 4 bytes in little endian format and converts it to a signed int. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public LittleEndianConverter()
Method Detail |
---|
public static int convertToBigEndian(byte[] srcBuffer, short[] destBuffer, int srcLength, int destOffset, int destLength)
srcBuffer
to big endian
signed short (2 bytes long) data.
srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least 2.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
public static int convertToBigEndian(byte[] srcBuffer, short[] destBuffer, int srcLength, int destOffset, int destLength, short mask)
srcBuffer
to big endian
short (2 bytes long) data. Significant bits can be masked, e. g. to
get unsigned 7 bit values use 0x7F
as mask.
srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least 2.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
mask
- Mask for significant bits. Set significant bits to 1.
public static int convertToBigEndian(byte[] srcBuffer, int[] destBuffer, int srcLength, int destOffset, int destLength)
srcBuffer
to big endian
signed integer (4 bytes long) data.
srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least 4.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Maximum number of data to be written in
destBuffer
public static int convertToBigEndian(byte[] srcBuffer, int[] destBuffer, int srcLength, int destOffset, int destLength, int mask)
srcBuffer
to big endian
integer (4 bytes long) data. Significant bits can be masked, e. g. to
get unsigned 31 bit values use 0x7FFFFFFF
as mask.
srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least 4.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Maximum number of data to be written in
destBuffer
mask
- Mask for significant bits. Set significant bits to 1.
public static int convertToBigEndian(int blockSize, byte[] srcBuffer, int[] destBuffer, int srcLength, int destOffset, int destLength)
srcBuffer
to big endian
signed integer data with a user defined block size of 2, 3, or 4 bytes.
srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least blockSize
.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Maximum number of data to be written in
destBuffer
blockSize
- May be 2, 3 or 4.
blockSize
)public static int convertToBigEndian(int blockSize, byte[] srcBuffer, int[] destBuffer, int srcLength, int destOffset, int destLength, int mask)
srcBuffer
to big endian
signed integer data with a user defined block size of 2, 3, or 4 bytes.
Significant bits can be masked, e. g. to get unsigned 16 bit values use
0xFFFF
as mask.
blockSize
- May be 2, 3 or 4.srcBuffer
- Data in little endian format which shall be converted.
The size of the array must be at least blockSize
.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.srcLength
- Number of bytes of srcBuffer
which shall
be processed. Must be <= length of srcBuffer
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Maximum number of data to be written in
destBuffer
mask
- Mask for significant bits. Set significant bits to 1.
blockSize
)public static int read(byte[] readBuffer, short[] destBuffer, int destOffset, int destLength, java.io.InputStream stream) throws java.io.IOException
InputStream
and converts
it to big endian signed short (2 bytes long) data.
readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 2)
depending on the size of the stream. The size of the array must be
at least 2.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read(byte[] readBuffer, short[] destBuffer, int destOffset, int destLength, java.io.InputStream stream, short mask) throws java.io.IOException
InputStream
and converts
it to big endian short (2 bytes long) data. Significant bits can be
masked, e. g. to get unsigned 7 bit values use 0x7F
as mask.
readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 2)
depending on the size of the stream. The size of the array must be
at least 2.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.mask
- Mask for significant bits. Set significant bits to 1.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read(byte[] readBuffer, int[] destBuffer, int destOffset, int destLength, java.io.InputStream stream) throws java.io.IOException
InputStream
and converts
it to big endian signed int (4 bytes long) data.
readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 4)
depending on the size of the stream. The size of the array must be
at least 4.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read(byte[] readBuffer, int[] destBuffer, int destOffset, int destLength, java.io.InputStream stream, int mask) throws java.io.IOException
InputStream
and converts
it to big endian int (4 bytes long) data. Significant bits can be masked,
e. g. to get unsigned 31 bit values use 0x7FFFFFFF
as mask.
readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 4)
depending on the size of the stream. The size of the array must be
at least 4.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.mask
- Mask for significant bits. Set significant bits to 1.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read(int blockSize, byte[] readBuffer, int[] destBuffer, int destOffset, int destLength, java.io.InputStream stream) throws java.io.IOException
InputStream
and converts
it to to big endian signed integer data with a user defined block size
of 1, 2, 3, or 4 bytes (1 is here for conveniance).
blockSize
- May be 1, 2, 3 or 4.readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 4)
depending on the size of the stream. The size of the array must be
at least blockSize
.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read(int blockSize, byte[] readBuffer, int[] destBuffer, int destOffset, int destLength, java.io.InputStream stream, int mask) throws java.io.IOException
InputStream
and converts
it to to big endian signed integer data with a user defined block size
of 1, 2, 3, or 4 bytes (1 is here for conveniance). Significant bits can
be masked, e. g. to get unsigned 16 bit values use 0xFFFF
as mask.
blockSize
- May be 1, 2, 3 or 4.readBuffer
- Auxilary Buffer to be used to read from
stream
. Choose an appropriate size (multiple of 4)
depending on the size of the stream. The size of the array must be
at least blockSize
.destBuffer
- Buffer to store the converted data. The size of the
array must be at least destOffset
+
destLength
.destOffset
- Offset for writing converted data in
destBuffer
.destLength
- Max. number of data to be written in
destBuffer
stream
- InputStream
to read from.mask
- Mask for significant bits. Set significant bits to 1.
destBuffer
(will be <= destLength).
java.io.IOException
public static int read4ByteBlock(java.io.InputStream stream) throws java.io.IOException
java.io.IOException
- if EOF occurs and only one, 2 or 3 bytes were read or
if error during reading occurspublic static int read2ByteBlock(java.io.InputStream stream) throws java.io.IOException
To Convert it to an unsigned int &
the result with
0xFFFF
.
java.io.IOException
- if EOF occurs and only one bytes was read or
if error during reading occurspublic static int read3ByteBlock(java.io.InputStream stream) throws java.io.IOException
To Convert it to an unsigned int &
the result with
0xFFFFFF
.
java.io.IOException
- if EOF occurs and only one or 2 bytes were read or
if error during reading occurs
|
j3d.org Code | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |