|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.alienfactory.javamappy.loader.ChunkLoader
public abstract class ChunkLoader
This is the base class for all ChunkLoaders.
Constructor Summary | |
---|---|
ChunkLoader()
|
Method Summary | |
---|---|
protected byte |
getByte(int index)
Returns the byte at the given index without affecting the 'inputStream'. |
int |
getBytesRemaining()
Returns the number of byte s yet to be read for this chunk. |
int |
getChunkLength()
Returns the total number of bytes in this chunk. |
java.lang.String |
getChunkName()
Returns the 4 character name of the chunk. |
protected boolean |
isLSB()
Returns true if shorts and int are stored Least Significant Byte first in the inputStream. |
abstract void |
loadChunk(Map map)
The method invoked to load the chunk. |
protected byte |
readByte()
Reads the next byte from the input stream. |
protected int |
readInt()
Reads the next 4 bytes from the Map input stream and turns them into an int . |
protected short |
readShort()
Reads the next 2 bytes from the Map input stream and turns them into a short . |
protected java.lang.String |
readString()
Reads characters until it find a terminating zero and returns the string. |
protected java.lang.String |
readString(int noOfChars)
Reads the next n bytes from the Map input stream and turns them into a String . |
protected int |
readUByte()
Reads the next byte from the input stream and returns it as
an unsigned int . |
protected void |
skip(int noOfBytes)
Skips the next n byte s from the Map input stream. |
protected void |
throwChunkException(java.lang.Object objMessage)
Throws a ChunkLoadException with a formatted message. |
java.lang.String |
toString()
Pretty print. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ChunkLoader()
Method Detail |
---|
public int getChunkLength()
public java.lang.String getChunkName()
public int getBytesRemaining()
byte
s yet to be read for this chunk.
public java.lang.String toString()
toString
in class java.lang.Object
public abstract void loadChunk(Map map) throws ChunkLoadException
ChunkLoadException
- should be thrown should anything be wrong with
the data you are loadingprotected boolean isLSB()
readShort()
or
readInt()
methods as these take care of LSB effects for you.
protected byte getByte(int index)
protected void throwChunkException(java.lang.Object objMessage) throws ChunkLoadException
ChunkLoadException
with a formatted message.
objMessage
- the error message
ChunkLoadException
- always.protected java.lang.String readString(int noOfChars) throws java.lang.IllegalArgumentException, ChunkLoadException
String
.
noOfChars
- the number of bytes to read and turn into a String
String
, read from the Map input stream
java.lang.IllegalArgumentException
- if intNoOfChars
is less than zero
ChunkLoadException
- if there are no more bytes left to read in the Chunkprotected java.lang.String readString()
String
, read from the Map input streamprotected byte readByte() throws ChunkLoadException
byte
from the input stream.
byte
(signed) from the Map input stream
ChunkLoadException
- if there are no more bytes left to read in the Chunkprotected int readUByte() throws ChunkLoadException
byte
from the input stream and returns it as
an unsigned int
.
byte
(unsigned) from the Map input stream
ChunkLoadException
- if there are no more bytes left to read in the Chunkprotected short readShort() throws ChunkLoadException
short
.
short
from the Map input stream
ChunkLoadException
- if there are no more bytes left to read in the Chunkprotected int readInt() throws ChunkLoadException
int
.
int
from the Map input stream
ChunkLoadException
- if there are no more bytes left to read in the Chunkprotected void skip(int noOfBytes) throws java.lang.IllegalArgumentException, ChunkLoadException
byte
s from the Map input stream.
noOfBytes
- the number of byte
s to skip
java.lang.IllegalArgumentException
- if lngNoOfBytes
is less than zero
ChunkLoadException
- if there are no more bytes left to read in the Chunk
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |