Class WadEntry

java.lang.Object
net.mtrop.doom.WadEntry

public class WadEntry extends Object
Abstraction of a single entry from a WAD. This entry contains NO DATA - this is a descriptor for the data in the originating WAD.
Author:
Matthew Tropiano
  • Field Details

  • Method Details

    • create

      public static WadEntry create(String name)
      Creates an empty WadEntry with an offset of 12 (beginning of content) and size zero. These empty entries are called "marker" entries.
      Parameters:
      name - the name of the entry.
      Returns:
      the constructed WadEntry.
      Throws:
      IllegalArgumentException - if the name is invalid or the offset or size is negative.
      Since:
      2.9.0
    • create

      public static WadEntry create(String name, int offset, int size)
      Creates a WadEntry.
      Parameters:
      name - the name of the entry.
      offset - the offset into the WAD in bytes.
      size - the size of the entry in bytes.
      Returns:
      the constructed WadEntry.
      Throws:
      IllegalArgumentException - if the name is invalid or the offset or size is negative.
    • create

      public static WadEntry create(byte[] b) throws IOException
      Creates a WadEntry.
      Parameters:
      b - the entry as serialized bytes.
      Returns:
      the constructed WadEntry.
      Throws:
      IOException - if an entry cannot be read.
      IllegalArgumentException - if the name is invalid or the offset or size is negative.
    • withNewName

      public WadEntry withNewName(String name)
      Makes a copy of this entry with a new name.
      Parameters:
      name - the new name.
      Returns:
      the new entry.
      Throws:
      IllegalArgumentException - if the name is invalid.
      Since:
      2.1.0
    • withNewOffset

      public WadEntry withNewOffset(int offset)
      Makes a copy of this entry with a new offset.
      Parameters:
      offset - the new offset.
      Returns:
      the new entry.
      Throws:
      IllegalArgumentException - if the offset is negative.
      Since:
      2.1.0
    • withNewSize

      public WadEntry withNewSize(int size)
      Makes a copy of this entry with a new size.
      Parameters:
      size - the new offset.
      Returns:
      the new entry.
      Throws:
      IllegalArgumentException - if the size is negative.
      Since:
      2.1.0
    • getName

      public String getName()
      Returns:
      the name of the entry.
    • getOffset

      public int getOffset()
      Returns:
      the offset into the original WAD for the start of the data.
    • getSize

      public int getSize()
      Returns:
      the size of the entry content in bytes.
    • isMarker

      public boolean isMarker()
      Tests if this entry is a "marker" entry. Marker entries have 0 size.
      Returns:
      true if size = 0, false if not.
    • getNameBytes

      public byte[] getNameBytes()
      Returns this entry's name as how it is represented in a WAD.
      Returns:
      a byte array of length 8 containing the output data.
    • toString

      public String toString()
      Overrides:
      toString in class Object