Class LittleEndianAccessor
java.lang.Object
tools.data.LittleEndianAccessor
Provides a interface to a Little Endian stream of bytes.
- Since:
- Revision 323
-
Constructor Summary
ConstructorsConstructorDescriptionClass constructor - Wraps the accessor around a stream of bytes. -
Method Summary
Modifier and TypeMethodDescriptionfinal longReturns the number of bytes available from the stream.final longGets the number of bytes read from the stream so far.final longGet the current position of the pointer.final byte[]read(int num) Readsnumbytes off the stream.final StringreadAsciiString(int n) Reads an ASCII string from the stream with lengthn.final bytereadByte()Read a single byte from the stream.intfinal charreadChar()Reads a single character from the stream.final doubleReads a double-precision integer from the stream.final floatReads a floating point integer from the stream.final intreadInt()Reads an integer from the stream.final longreadLong()Reads a long integer from the stream.final StringReads a MapleStory convention lengthed ASCII string.final PointreadPos()Reads a MapleStory Position information.final shortReads a short integer from the stream.final intfinal longreadUInt()final intfinal voidseek(long offset) Seek the pointer tooffsetfinal voidskip(int num) Skipnumnumber of bytes in the stream.final StringtoString()final StringtoString(boolean b)
-
Constructor Details
-
LittleEndianAccessor
Class constructor - Wraps the accessor around a stream of bytes.- Parameters:
bs- The byte stream to wrap the accessor around.
-
-
Method Details
-
readByteAsInt
public int readByteAsInt() -
readByte
public final byte readByte()Read a single byte from the stream.- Returns:
- The byte read.
-
readInt
public final int readInt()Reads an integer from the stream.- Returns:
- The integer read.
-
readUInt
public final long readUInt() -
readShort
public final short readShort()Reads a short integer from the stream.- Returns:
- The short read.
-
readUShort
public final int readUShort() -
readShortAsInt
public final int readShortAsInt() -
readChar
public final char readChar()Reads a single character from the stream.- Returns:
- The character read.
-
readLong
public final long readLong()Reads a long integer from the stream.- Returns:
- The long integer read.
-
readFloat
public final float readFloat()Reads a floating point integer from the stream.- Returns:
- The float-type integer read.
-
readDouble
public final double readDouble()Reads a double-precision integer from the stream.- Returns:
- The double-type integer read.
-
readAsciiString
Reads an ASCII string from the stream with lengthn.- Parameters:
n- Number of characters to read.- Returns:
- The string read.
-
getBytesRead
public final long getBytesRead()Gets the number of bytes read from the stream so far.- Returns:
- A long integer representing the number of bytes read.
-
readMapleAsciiString
Reads a MapleStory convention lengthed ASCII string. This consists of a short integer telling the length of the string, then the string itself.- Returns:
- The string read.
-
readPos
Reads a MapleStory Position information. This consists of 2 short integer.- Returns:
- The Position read.
-
read
public final byte[] read(int num) Readsnumbytes off the stream.- Parameters:
num- The number of bytes to read.- Returns:
- An array of bytes with the length of
num
-
available
public final long available()Returns the number of bytes available from the stream. -
toString
-
toString
-
seek
public final void seek(long offset) Seek the pointer tooffset- Parameters:
offset- The offset to seek to.
-
getPosition
public final long getPosition()Get the current position of the pointer.- Returns:
- The current position of the pointer as a long integer.
-
skip
public final void skip(int num) Skipnumnumber of bytes in the stream.- Parameters:
num- The number of bytes to skip.
-