Class WadFile.Adder
java.lang.Object
net.mtrop.doom.WadFile.Adder
- All Implemented Interfaces:
- AutoCloseable
- Enclosing class:
- WadFile
Bulk add mechanism for WadFile.
 All methods on this object manipulate the WadFile it is created from, and
 defers the final writing of the entry list until it is closed. This object is meant
 to be created via a try-with-resources block, like so:
 
 try (WadFile.Adder adder = wad.createAdder())
 {
     adder.addData(....);
     ...
 }
  
 ...upon which the entries are committed on close. This will still commit the list
 even on an error occurring during add, unless the the writing of the list results
 in an error as well.- Since:
- 2.7.0
- Author:
- Matthew Tropiano
- 
Method SummaryModifier and TypeMethodDescriptionAdds data to this Wad, usingentryNameas the name of the new entry.<BO extends BinaryObject>
 WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.<BO extends BinaryObject>
 WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.Adds data to this Wad, usingentryNameas the name of the new entry.addData(String entryName, InputStream in) Adds data to this Wad, usingentryNameas the name of the new entry.addData(String entryName, InputStream in, int maxLength) Adds data to this Wad, usingentryNameas the name of the new entry.<TO extends TextObject>
 WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.<BO extends BinaryObject>
 WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.<BO extends BinaryObject>
 WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.Adds data to this Wad, usingentryNameas the name of the new entry.addDataAt(int index, String entryName, InputStream in) Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.addDataAt(int index, String entryName, InputStream in, int maxLength) Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.<TO extends TextObject>
 WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.Adds a new entry to the Wad, but with an explicit offset and size.Adds an entry marker to the Wad (entry with 0 size, arbitrary offset).addMarkerAt(int index, String entryName) Adds an entry marker to the Wad (entry with 0 size, arbitrary offset).voidclose()
- 
Method Details- 
close- Specified by:
- closein interface- AutoCloseable
- Throws:
- IOException
 
- 
addEntryAdds a new entry to the Wad, but with an explicit offset and size. Exercise caution with this method, since you can reference anywhere in the Wad!NOTE: The entry is not written until close()is called (or theWadFile.Adderis closed automatically).- Parameters:
- entryName- the name of the entry.
- offset- the entry's content start byte.
- length- the entry's length in bytes.
- Returns:
- the entry that was created.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name, or the offset/size is negative.
- IOException- if the entry cannot be written.
- NullPointerException- if- nameis- null.
 
- 
addMarkerAdds an entry marker to the Wad (entry with 0 size, arbitrary offset).- Parameters:
- entryName- the name of the entry.
- Returns:
- the entry that was added.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the entry cannot be written.
- NullPointerException- if- nameis- null.
 
- 
addMarkerAtAdds an entry marker to the Wad (entry with 0 size, arbitrary offset).- Parameters:
- index- the index at which to add the marker.
- entryName- the name of the entry.
- Returns:
- the entry that was added.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the entry cannot be written.
- NullPointerException- if- nameis- null.
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- entryName- the name of the entry to add this as.
- data- the bytes of data to add as this wad's data.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- BO- a BinaryObject type.
- Parameters:
- entryName- the name of the entry to add this as.
- data- the BinaryObject to add as this wad's data (converted via- BinaryObject.toBytes()).
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The BinaryObjects provided have all of their converted data concatenated together as one blob of contiguous data. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- BO- a BinaryObject type.
- Parameters:
- entryName- the name of the entry to add this as.
- data- the BinaryObjects to add as this wad's data (converted via- BinaryObject.toBytes()).
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDatapublic <TO extends TextObject> WadEntry addData(String entryName, TO data, Charset encoding) throws IOException Adds data to this Wad, usingentryNameas the name of the new entry. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- TO- a TextObject type.
- Parameters:
- entryName- the name of the entry to add this as.
- data- the TextObject to add as this wad's data (converted via- TextObject.toText(), then- String.getBytes(Charset)).
- encoding- the encoding type for the data written to the Wad.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- dataor- encodingis- null.
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The provided File is read until the end of the file is reached. The overhead for multiple individual additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- entryName- the name of the entry to add this as.
- fileToAdd- the file to add the contents of.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- FileNotFoundException- if the file path refers to a file that is a directory or doesn't exist.
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- dataor- encodingis- null.
- Since:
- 2.7.0
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The provided input stream is read until the end of the stream is reached. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- entryName- the name of the entry to add this as.
- in- the input stream to read.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- dataor- encodingis- null.
 
- 
addDataAdds data to this Wad, usingentryNameas the name of the new entry. The provided input stream is read until the end of the stream is reached ormaxLengthbytes are read. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- entryName- the name of the entry to add this as.
- in- the input stream to read.
- maxLength- the maximum amount of bytes to read from the InputStream, or a value < 0 to keep reading until end-of-stream.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- dataor- encodingis- null.
 
- 
addDataAtAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The rest of the entries in the wad are shifted down one index. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- data- the bytes of data to add as this wad's data.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAtpublic <BO extends BinaryObject> WadEntry addDataAt(int index, String entryName, BO data) throws IOException Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The rest of the entries in the wad are shifted down one index. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- BO- a BinaryObject type.
- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- data- the BinaryObject to add as this wad's data (converted via- BinaryObject.toBytes()).
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAtpublic <BO extends BinaryObject> WadEntry addDataAt(int index, String entryName, BO[] data) throws IOException Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The rest of the entries in the wad are shifted down one index. The BinaryObjects provided have all of their converted data concatenated together as one blob of contiguous data. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- BO- a BinaryObject type.
- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- data- the BinaryObjects to add as this wad's data (converted via- BinaryObject.toBytes()).
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAtpublic <TO extends TextObject> WadEntry addDataAt(int index, String entryName, TO data, Charset encoding) throws IOException Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The rest of the entries in the wad are shifted down one index. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Type Parameters:
- TO- a TextObject type.
- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- data- the TextObject to add as this wad's data (converted via- TextObject.toText(), then- String.getBytes(Charset)).
- encoding- the encoding type for the data written to the Wad.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAtAdds data to this Wad, usingentryNameas the name of the new entry. The provided File is read until the end of the file is reached. The overhead for multiple individual additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- fileToAdd- the file to add the contents of.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- FileNotFoundException- if the file path refers to a file that is a directory or doesn't exist.
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- dataor- encodingis- null.
- Since:
- 2.7.0
 
- 
addDataAtAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The provided input stream is read until the end of the stream is reached. The rest of the entries in the wad are shifted down one index. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- in- the input stream to read.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- datais- null.
 
- 
addDataAtpublic WadEntry addDataAt(int index, String entryName, InputStream in, int maxLength) throws IOException Adds data to this Wad at a particular entry offset, usingentryNameas the name of the entry. The provided input stream is read until the end of the stream is reached ormaxLengthbytes are read. The rest of the entries in the wad are shifted down one index. The overhead for multiple additions may be expensive I/O-wise depending on the Wad implementation.- Parameters:
- index- the index at which to add the entry.
- entryName- the name of the entry to add this as.
- in- the input stream to read.
- maxLength- the maximum amount of bytes to read from the InputStream, or a value < 0 to keep reading until end-of-stream.
- Returns:
- a WadEntry that describes the added data.
- Throws:
- IllegalArgumentException- if the provided name is not a valid name.
- IndexOutOfBoundsException- if the provided index < 0 or >- getEntryCount().
- IOException- if the data cannot be written or the stream could not be read.
- NullPointerException- if- entryNameor- datais- null.
 
 
-