jwadlib
Class Lump

java.lang.Object
  extended by jwadlib.Lump

public class Lump
extends java.lang.Object

The Lump class is the parent class of all lump classes that are used to virtually store lumps from WAD files that have been extracted into a Wad object.

Since:
1.0
Version:
1.0 Alpha 1
Author:
Samuel "insertwackynamehere" Horwitz

Field Summary
private  WadByteBuffer content
          The WadByteBuffer that contains the content of the lump.
protected  java.lang.String name
          The name of the lump as a String.
 
Constructor Summary
Lump(java.lang.String name)
          Creates a Lump with the specified name, of size 0.
Lump(java.lang.String name, byte[] data)
          Creates a Lump with the specified name and data.
Lump(java.lang.String name, int size)
          Creates a Lump with the specified name and size.
Lump(java.lang.String name, int size, java.nio.channels.FileChannel filechannel, int pointer)
          Creates a Lump object from the information in the WAD file's directory.
Lump(java.lang.String name, WadByteBuffer data)
          Creates a Lump with the specified name and data.
 
Method Summary
 boolean alterRawLumpData(byte[] data)
          Changes the Lump's data with the specified array of bytes.
 boolean alterRawLumpData(WadByteBuffer data)
          Changes the Lump's data with the specified WadByteBuffer.
 boolean appendRawLumpData(byte[] data)
          Append raw byte data to the content of a Lump.
 boolean appendRawLumpData(WadByteBuffer data)
          Append raw byte data to the content of a Lump.
 void changeName(java.lang.String name)
          Changes the name of the lump to an eight byte String that is specified and passed through WadByteBuffer's convertToEightByteString method.
 java.lang.String getName()
          Returns the name of the lump as a String.
 int getNumberOfBytes()
          Returns the number of bytes in the lump.
 WadByteBuffer getRawLumpData()
          Sets and returns the actual data of the lump from the WAD file.
 int getSize()
          Returns the size of the lump, in bytes.
 boolean isVirtual()
          Returns true if and only if the lump is virtual (has a declared size of zero bytes has a value of null).
 java.lang.String toString()
          Returns the name of the Lump by calling the getName() method.
 boolean writeToFile(java.io.File directory)
          Writes the Lump to a binary file with the Lump's name and the extension ".lmp".
 boolean writeToFile(java.nio.channels.FileChannel filechannel)
          Writes the Lump to a binary file.
 boolean writeToFile(java.nio.channels.FileChannel filechannel, long position)
          Writes the Lump to a binary file at the specified position.
 boolean writeToFile(java.io.File directory, java.lang.String filename)
          Writes the Lump to a binary file with a custom name and the extension ".lmp".
 boolean writeToFile(java.io.RandomAccessFile file)
          Writes the Lump to a binary file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

content

private WadByteBuffer content
The WadByteBuffer that contains the content of the lump.

Since:
1.0

name

protected java.lang.String name
The name of the lump as a String.

Since:
1.0
Constructor Detail

Lump

public Lump(java.lang.String name)
Creates a Lump with the specified name, of size 0.

Parameters:
name - the name of the Lump.
Since:
1.0

Lump

public Lump(java.lang.String name,
            int size)
Creates a Lump with the specified name and size.

Parameters:
name - the name of the Lump.
size - the size of the Lump.
Since:
1.0

Lump

public Lump(java.lang.String name,
            byte[] data)
Creates a Lump with the specified name and data.

Parameters:
name - the name of the Lump.
data - the data contained in the Lump as an array of bytes.
Since:
1.0

Lump

public Lump(java.lang.String name,
            WadByteBuffer data)
Creates a Lump with the specified name and data.

Parameters:
name - the name of the Lump.
data - the data contained in the Lump as a WadByteBuffer.
Since:
1.0

Lump

public Lump(java.lang.String name,
            int size,
            java.nio.channels.FileChannel filechannel,
            int pointer)
     throws UnableToReadWADFileException
Creates a Lump object from the information in the WAD file's directory. The actual lump data is not extracted, however the information needed to extract the data is passed into the object, along with the name of the lump and the WAD that is found in. The lump itself is actually extracted from the WAD file when Lump's getRawLumpData() method is called. This is done to save memory and time by storing only pointers to the data as opposed to the data itself, unless necessary.

Parameters:
name - the name of lump as a String.
size - the size, in bytes, of the lump data.
filechannel - the parent Wad's FileChannel.
pointer - the starting location in the WAD file of the lump data.
Throws:
UnableToReadWADFileException - if the WAD file cannot be read.
Since:
1.0
Method Detail

getName

public java.lang.String getName()
Returns the name of the lump as a String.

Returns:
the name of the lump as a String.
Since:
1.0

isVirtual

public boolean isVirtual()
Returns true if and only if the lump is virtual (has a declared size of zero bytes has a value of null).

Returns:
true if and only if the lump is virtual, otherwise false.
Since:
1.0

getRawLumpData

public WadByteBuffer getRawLumpData()
Sets and returns the actual data of the lump from the WAD file. After this method has been called, the Lump object will store the data in memory as opposed to retrieving it from the WAD file.

Returns:
the lump data as an ArrayList.
Since:
1.0

getNumberOfBytes

public int getNumberOfBytes()
Returns the number of bytes in the lump.

Returns:
the number of bytes in the lump.
Since:
1.0

getSize

public int getSize()
Returns the size of the lump, in bytes. It should be noted that this is not the number of bytes currently held in the Lump's content, but instead how many bytes the WadByteBuffer backing the Lump could hold.

Returns:
the size of the lump, in bytes.
Since:
1.0

changeName

public void changeName(java.lang.String name)
Changes the name of the lump to an eight byte String that is specified and passed through WadByteBuffer's convertToEightByteString method.

Parameters:
name - the new name as a String.
Since:
1.0

alterRawLumpData

public boolean alterRawLumpData(byte[] data)
Changes the Lump's data with the specified array of bytes.

Parameters:
data - the new lump data as a byte array.
Returns:
true when the lump data is updated.
Since:
1.0

alterRawLumpData

public boolean alterRawLumpData(WadByteBuffer data)
Changes the Lump's data with the specified WadByteBuffer.

Parameters:
data - the new lump data as a WadByteBuffer.
Returns:
true when the lump data is updated.
Since:
1.0

appendRawLumpData

public boolean appendRawLumpData(byte[] data)
Append raw byte data to the content of a Lump.

Parameters:
data - the data to be appended as an array of bytes.
Returns:
true if completed successfully.
Since:
1.0

appendRawLumpData

public boolean appendRawLumpData(WadByteBuffer data)
Append raw byte data to the content of a Lump.

Parameters:
data - the data to be appended as a WadByteBuffer.
Returns:
true if completed successfully.
Since:
1.0

writeToFile

public boolean writeToFile(java.io.File directory)
                    throws UnableToWriteLumpFileException
Writes the Lump to a binary file with the Lump's name and the extension ".lmp".

Parameters:
directory - the directory to write the lump file to.
Returns:
true if completed successfully.
Throws:
UnableToWriteLumpFileException - if the lump file cannot be written to.
Since:
1.0

writeToFile

public boolean writeToFile(java.io.File directory,
                           java.lang.String filename)
                    throws UnableToWriteLumpFileException
Writes the Lump to a binary file with a custom name and the extension ".lmp".

Parameters:
directory - the directory to write the lump file to.
filename - the filename of the lump. Do not include an extension, the extension will be ".lmp".
Returns:
true if completed successfully.
Throws:
UnableToWriteLumpFileException - if the lump file cannot be written to.
Since:
1.0

writeToFile

public boolean writeToFile(java.io.RandomAccessFile file)
                    throws UnableToWriteLumpFileException
Writes the Lump to a binary file.

Parameters:
file - the RandomAccessFile to write to.
Returns:
true if the file has been successfully written to.
Throws:
UnableToWriteLumpFileException - if the specified file cannot be written to.
Since:
1.0

writeToFile

public boolean writeToFile(java.nio.channels.FileChannel filechannel)
                    throws UnableToWriteLumpFileException
Writes the Lump to a binary file.

Parameters:
filechannel - the FileChannel to write to.
Returns:
true if the file has been successfully written to.
Throws:
UnableToWriteLumpFileException - if the specified file cannot be written to.
Since:
1.0

writeToFile

public boolean writeToFile(java.nio.channels.FileChannel filechannel,
                           long position)
                    throws UnableToWriteLumpFileException
Writes the Lump to a binary file at the specified position.

Parameters:
filechannel - the FileChannel to write to.
position - the position in the FileChannel to begin writing at.
Returns:
true if the file has been successfully written to.
Throws:
UnableToWriteLumpFileException - if the specified file cannot be written to.
Since:
1.0

toString

public java.lang.String toString()
Returns the name of the Lump by calling the getName() method. Overrides java.lang.Object's toString() method.

Overrides:
toString in class java.lang.Object
Returns:
the name of the Lump.
Since:
1.0

jwadlib WAD Library Extending API
Version 1.0 Alpha 1
Intended for developers wishing to extend jwadlib, not implement it.

© 2008 Samuel insertwackynamehere Horwitz.
jwadlib WAD Library is released under the GNU Lesser Public License with the documentation freely written into the source code. This generated output it provided for the benefit of users. All the information contained is available as part of the downloaded library.