Interface Wad
All entries in a WAD are abstracted as WadEntry objects, which contain the name and offsets for the corresponding data in a WAD file. Note that there may be several entries in a WAD that have the same name; entry "equality" should be determined by name, size and offset.
Entries are by no means attached to their source WADs. Attempting to retrieve content from one WAD using entry data from another WAD may have unintended consequences!
There may be some implementations of this structure that do not support certain operations, so in those cases, those
methods may throw an UnsupportedOperationException. Also, certain implementations may be more suited for
better tasks, so be sure to figure out which implementation suits your needs!
Most of the common methods are "defaulted" in this interface. Implementors are encouraged to override these if your implementation can provide a more performant version than the one-size-fits-all methods here.
All methods in Wad implementations cannot be guaranteed to be thread-safe.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default <BO extends BinaryObject>
WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default <BO extends BinaryObject>
WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default WadEntryaddData(String entryName, InputStream in) Adds data to this Wad, usingentryNameas the name of the new entry.default WadEntryaddData(String entryName, InputStream in, int maxLength) Adds data to this Wad, usingentryNameas the name of the new entry.default <TO extends TextObject>
WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.default <BO extends BinaryObject>
WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.default <BO extends BinaryObject>
WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.default WadEntryAdds data to this Wad, usingentryNameas the name of the new entry.default WadEntryaddDataAt(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.default <TO extends TextObject>
WadEntryAdds data to this Wad at a particular entry offset, usingentryNameas the name of the entry.default WadEntryAdds a new entry to the Wad, but with an explicit offset and size.default WadEntryAdds a new entry to the Wad.default WadEntryaddEntryAt(int index, String entryName, int offset, int length) Adds a new entry to the Wad at a specific index, but with an explicit offset and size.addEntryAt(int index, WadEntry entry) Adds a new entry to the Wad.default voidTakes entries and their data from another Wad and adds it to this one.default voidTakes entries and their data from another Wad and adds it to this one.default voidTakes entries and their data from another Wad and adds it to this one at a specific index.default voidTakes entries and their data from another Wad and adds it to this one at a specific index.default WadEntryAdds an entry marker to the Wad (entry with 0 size, arbitrary offset).default WadEntryaddMarkerAt(int index, String entryName) Adds an entry marker to the Wad (entry with 0 size, arbitrary offset).voidclose()Closes this Wad.default booleanChecks if this Wad contains a particular entry, false otherwise.default booleanChecks if this Wad contains a particular entry from a starting entry index, false otherwise.default booleanChecks if this Wad contains a particular entry from a starting entry (by name), false otherwise.deleteEntry(int index) Deletes a Wad's entry and its contents.voidfetchContent(int offset, int length, byte[] out, int outOffset) Fetches a series of bytes from an arbitrary place in the Wad and puts them into a provided array.default intfetchData(int n, byte[] out, int offset) Retrieves the data of a particular entry index and puts it in a provided array and puts it in a provided array.default intRetrieves the data of the first occurrence of a particular entry and puts it in a provided array.default intRetrieves the data of the first occurrence of a particular entry from a starting index and puts it in a provided array.default intRetrieves the data of the first occurrence of a particular entry from a starting entry (by name) and puts it in a provided array.default intFetches the data of the specified entry and puts it in a provided array.default WadEntry[]Returns all WadEntry objects (in a new array).default WadEntry[]getAllEntries(String entryName) Returns all WadEntry objects namedentryName.default int[]getAllEntryIndices(String entryName) Gets the indices of all WadEntry objects namedentryName.default byte[]getContent(int offset, int length) Gets a series of bytes representing the data at an arbitrary place in the Wad.intdefault byte[]getData(int n) Retrieves the data of a particular entry index.default byte[]Retrieves the data of the first occurrence of a particular entry.default byte[]Retrieves the data of the first occurrence of a particular entry from a starting index.default byte[]Retrieves the data of the first occurrence of a particular entry from a starting entry (by name).default byte[]Retrieves the data of the specified entry.default <BO extends BinaryObject>
BORetrieves the data of an entry at a particular index as a deserialized lump.default <BO extends BinaryObject>
BO[]Retrieves the data of an entry at a particular index as a deserialized lump of multiple objects.default <BO extends BinaryObject>
BORetrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump.default <BO extends BinaryObject>
BO[]Retrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump of multiple objects.default <BO extends BinaryObject>
BORetrieves the data of the first occurrence of a particular entry as a deserialized lump.default <BO extends BinaryObject>
BO[]Retrieves the data of the first occurrence of a particular entry as a deserialized lump of multiple objects.default <BO extends BinaryObject>
BORetrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump.default <BO extends BinaryObject>
BO[]Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump of multiple objects.default <BO extends BinaryObject>
BORetrieves the data of the specified entry as a deserialized lump.default <BO extends BinaryObject>
BO[]Retrieves the data of the specified entry as a deserialized lump of multiple objects.default <BO extends BinaryObject>
List<BO> getDataAsList(int n, Class<BO> type, int objectLength) Retrieves the data of an entry at a particular index as a deserialized lump of multiple objects.default <BO extends BinaryObject>
List<BO> getDataAsList(String entryName, int start, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump of multiple objects.default <BO extends BinaryObject>
List<BO> getDataAsList(String entryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry as a deserialized lump of multiple objects.default <BO extends BinaryObject>
List<BO> getDataAsList(String entryName, String startEntryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump of multiple objects.default <BO extends BinaryObject>
List<BO> getDataAsList(WadEntry entry, Class<BO> type, int objectLength) Retrieves the data of the specified entry as a deserialized lump of multiple objects.getEntry(int n) Gets the WadEntry at index n.default WadEntryGets the first WadEntry namedentryName.default WadEntryZ Gets the first WadEntry namedentryName, starting from a particular index.default WadEntryGets the first WadEntry namedentryName, starting from a particular entry's index.intdefault <BO extends BinaryObject>
BinaryObject.InlineScanner<BO> getInlineScanner(int n, Class<BO> type, int objectLength) Retrieves the data of a particular entry at a specific index and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.default <BO extends BinaryObject>
BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, int start, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.default <BO extends BinaryObject>
BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.default <BO extends BinaryObject>
BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, String startEntryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.default <BO extends BinaryObject>
BinaryObject.InlineScanner<BO> getInlineScanner(WadEntry entry, Class<BO> type, int objectLength) Retrieves the data of the specified entry and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.default InputStreamgetInputStream(int n) Retrieves the data of a particular entry index and returns it as a stream.default InputStreamgetInputStream(String entryName) Retrieves the data of the first occurrence of a particular entry and returns it as a stream.default InputStreamgetInputStream(String entryName, int start) Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a stream.default InputStreamgetInputStream(String entryName, String startEntryName) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a stream.default InputStreamgetInputStream(WadEntry entry) Retrieves the data of the specified entry from a starting index and returns it as a stream.default WadEntrygetLastEntry(String entryName) Gets the last WadEntry namedentryName.default WadEntrygetNthEntry(String entryName, int n) Gets the n-th WadEntry namedentryName.default ReaderRetrieves a Reader for an entry at a particular index as a decoded stream of characters.default ReaderRetrieves a Reader for the first occurrence of a particular entry from a starting index as a decoded stream of characters.default ReaderRetrieves a Reader for the first occurrence of a particular entry from a starting entry (by name) as a decoded stream of characters.default ReaderRetrieves a Reader for the first occurrence of a particular entry as a decoded stream of characters.default ReaderRetrieves a Reader for the specified entry as a decoded stream of characters.default <BO extends BinaryObject>
BinaryObject.Scanner<BO> getScanner(int n, Class<BO> type, int objectLength) Retrieves the data of a particular entry at a specific index and returns it as a deserializing scanner iterator that returns independent instances of objects.default <BO extends BinaryObject>
BinaryObject.Scanner<BO> getScanner(String entryName, int start, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a deserializing scanner iterator that returns independent instances of objects.default <BO extends BinaryObject>
BinaryObject.Scanner<BO> getScanner(String entryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry and returns it as a deserializing scanner iterator that returns independent instances of objects.default <BO extends BinaryObject>
BinaryObject.Scanner<BO> getScanner(String entryName, String startEntryName, Class<BO> type, int objectLength) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a deserializing scanner iterator that returns independent instances of objects.default <BO extends BinaryObject>
BinaryObject.Scanner<BO> getScanner(WadEntry entry, Class<BO> type, int objectLength) Retrieves the data of the specified entry and returns it as a deserializing scanner iterator that returns independent instances of objects.default StringgetTextData(int n, Charset charset) Retrieves the data of an entry at a particular index as a decoded string of characters.default StringgetTextData(String entryName, int start, Charset charset) Retrieves the data of the first occurrence of a particular entry from a starting index as a decoded string of characters.default StringgetTextData(String entryName, String startEntryName, Charset charset) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a decoded string of characters.default StringgetTextData(String entryName, Charset charset) Retrieves the data of the first occurrence of a particular entry as a decoded string of characters.default StringgetTextData(WadEntry entry, Charset charset) Retrieves the data of the specified entry as a decoded string of characters.default <TO extends TextObject>
TOgetTextDataAs(int n, Charset charset, Class<TO> type) Retrieves the text data of an entry at a particular index as an interpreted text-originating object.default <TO extends TextObject>
TOgetTextDataAs(String entryName, int start, Charset charset, Class<TO> type) Retrieves the data of the first occurrence of a particular entry from a starting index as an interpreted text-originating object.default <TO extends TextObject>
TOgetTextDataAs(String entryName, String startEntryName, Charset charset, Class<TO> type) Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as an interpreted text-originating object.default <TO extends TextObject>
TOgetTextDataAs(String entryName, Charset charset, Class<TO> type) Retrieves the data of the first occurrence of a particular entry as an interpreted text-originating object.default <TO extends TextObject>
TOgetTextDataAs(WadEntry entry, Charset charset, Class<TO> type) Retrieves the data of the specified entry as an interpreted text-originating object.default intGets the first index of an entry of nameentryName.default intGets the first index of an entry of name "entryName" from a starting point.default intGets the first index of an entry of name "entryName" from a starting point entry "startEntryName".booleanisIWAD()Checks if this WAD is an Internal WAD.booleanisPWAD()Checks if this WAD is a Patch WAD.static booleanChecks if a file is a valid WAD file.default intlastIndexOf(String entryName) Gets the last index of an entry of nameentryName.default WadEntry[]mapEntries(int startIndex, int maxLength) Retrieves a contiguous set of entries from this Wad, starting from a desired index.removeEntry(int index) Remove a Wad's entry (but not contents).voidrenameEntry(int index, String newName) Renames the entry at an index in the Wad.voidreplaceEntry(int index, byte[] data) Replaces the entry at an index in the Wad.default <BO extends BinaryObject>
voidreplaceEntry(int index, BO data) Replaces the entry at an index in the Wad.default <BO extends BinaryObject>
voidreplaceEntry(int index, BO[] data) Replaces the entry at an index in the Wad.default <TO extends TextObject>
voidreplaceEntry(int index, TO data, Charset encoding) Replaces the entry at an index in the Wad.voidsetEntries(WadEntry... entryList) Completely replaces the list of entries in this Wad with a completely different set of entries.default voidReplaces an entry in the Wad - no content, just descriptor.default <BO extends BinaryObject>
voidtransformData(int n, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) Retrieves the data of a particular entry index as a deserialized lump of multiple objects, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
voidtransformData(int n, Class<BO> type, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry index, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, int start, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, int start, Class<BO> type, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, Class<BO> type, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, String startEntryName, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <BO extends BinaryObject>
booleantransformData(String entryName, String startEntryName, Class<BO> type, BinaryObject.Transformer<BO> transformer) Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.default <TO extends TextObject>
voidtransformTextData(int n, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) Retrieves the decoded data of a particular entry index, optionally transforms it, then writes it back to the Wad.default <TO extends TextObject>
booleantransformTextData(String entryName, int start, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.default <TO extends TextObject>
booleantransformTextData(String entryName, String startEntryName, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.default <TO extends TextObject>
booleantransformTextData(String entryName, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.voidunmapEntries(int startIndex, WadEntry... entryList) Replaces a series of WadEntry objects in this Wad, using the provided list of entries as the replacement list.Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Field Details
-
NO_ENTRIES
-
NO_DATA
static final byte[] NO_DATA
-
-
Method Details
-
isWAD
Checks if a file is a valid WAD file. This opens the provided file for reading only, inspects the first four bytes for a valid header, and then closes it.- Parameters:
file- the file to inspect.- Returns:
- true if the file exists, is a file, and is a WAD file, or false otherwise.
- Throws:
IOException- if the file cannot be read.SecurityException- if you don't have permission to read the file.- Since:
- 2.3.0
-
isIWAD
boolean isIWAD()Checks if this WAD is an Internal WAD.- Returns:
- true if so, false if not.
-
isPWAD
boolean isPWAD()Checks if this WAD is a Patch WAD.- Returns:
- true if so, false if not.
-
getEntryCount
int getEntryCount()- Returns:
- the number of entries in this Wad.
-
getContentLength
int getContentLength()- Returns:
- the amount of content data in this Wad in bytes.
-
getEntry
Gets the WadEntry at index n.- Parameters:
n- the index of the entry in the entry list.- Returns:
- the entry at
n. - Throws:
ArrayIndexOutOfBoundsException- if n < 0 or >= size.
-
getEntry
-
getEntry
Z Gets the first WadEntry namedentryName, starting from a particular index.The name is case-insensitive.
- Parameters:
entryName- the name of the entry.start- the index with which to start the search (a value less than 0 is considered 0).- Returns:
- the first entry named
entryNameornullif not found.
-
getEntry
Gets the first WadEntry namedentryName, starting from a particular entry's index. IfstartEntryNameis not found, the search returns null.The names are case-insensitive.
- Parameters:
entryName- the name of the entry.startEntryName- the name of the starting entry to find (first occurrence).- Returns:
- the first entry named
entryNameornullifentryNameorstartEntryNamenot found. - Throws:
NullPointerException- ifentryNameorstartEntryNameisnull.
-
getNthEntry
Gets the n-th WadEntry namedentryName.The name is case-insensitive.
- Parameters:
entryName- the name of the entry.n- the n-th occurrence to find, 0-based (0 is first, 1 is second, and so on).- Returns:
- the n-th entry named
entryNameornullif not found.
-
getLastEntry
-
getAllEntries
Returns all WadEntry objects (in a new array).- Returns:
- an array of all of the WadEntry objects.
-
getAllEntries
-
getAllEntryIndices
Gets the indices of all WadEntry objects namedentryName.The name is case-insensitive.
- Parameters:
entryName- the name of the entry.- Returns:
- an array of all of the WadEntry objects with the name
entryName.
-
indexOf
Gets the first index of an entry of nameentryName.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.- Returns:
- the index of the entry in this file, or -1 if not found.
-
indexOf
Gets the first index of an entry of name "entryName" from a starting point.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search (a value less than 0 is considered 0).- Returns:
- the index of the entry in this file, or -1 if not found.
- Throws:
ArrayIndexOutOfBoundsException- if start < 0 or >= size.
-
indexOf
Gets the first index of an entry of name "entryName" from a starting point entry "startEntryName". IfstartEntryNameis not found, the search returns null.The names are case-insensitive.
- Parameters:
entryName- the name of the entry.startEntryName- the name of the starting entry to find (first occurrence).- Returns:
- the index of the entry named
entryNamein this file, or -1 ifentryNameorstartEntryNamenot found.
-
lastIndexOf
Gets the last index of an entry of nameentryName.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.- Returns:
- the index of the entry in this file, or -1 if not found.
-
fetchContent
Fetches a series of bytes from an arbitrary place in the Wad and puts them into a provided array. This is will attempt to get the full provided length, throwing an exception if it does not.- Parameters:
offset- the offset byte into that data to start at.length- the amount of bytes to fetch.out- the destination array of bytes.outOffset- the offset into the destination array to put the bytes into.- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the destination array.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
fetchData
Retrieves the data of a particular entry index and puts it in a provided array and puts it in a provided array.- Parameters:
n- the index of the entry in the Wad.out- the output array of bytes.offset- the offset into the array to to put the read bytes.- Returns:
- the amount of bytes read.
- Throws:
ArrayIndexOutOfBoundsException- if n < 0 or >= size.IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
fetchData
Retrieves the data of the first occurrence of a particular entry and puts it in a provided array.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.out- the output array of bytes.offset- the offset into the array to to put the read bytes.- Returns:
- the amount of bytes read, or -1 if the entry could not be found.
- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
fetchData
Retrieves the data of the first occurrence of a particular entry from a starting index and puts it in a provided array.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.out- the output array of bytes.offset- the offset into the array to to put the read bytes.- Returns:
- the amount of bytes read, or -1 if the entry could not be found.
- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
fetchData
default int fetchData(String entryName, String startEntryName, byte[] out, int offset) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and puts it in a provided array.The names are case-insensitive.
- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.out- the output array of bytes.offset- the offset into the array to to put the read bytes.- Returns:
- the amount of bytes read, or -1 if the entry could not be found.
- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
fetchData
Fetches the data of the specified entry and puts it in a provided array.- Parameters:
entry- the entry to use.out- the output array of bytes.offset- the offset into the array to to put the read bytes.- Returns:
- the amount of bytes read.
- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.NullPointerException- if out is null.- Since:
- 2.4.0
-
getInputStream
Retrieves the data of a particular entry index and returns it as a stream.- Parameters:
n- the index of the entry in the file.- Returns:
- an open input stream of the data, or null if it can't be retrieved.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.
-
getInputStream
Retrieves the data of the first occurrence of a particular entry and returns it as a stream.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.- Returns:
- an open input stream of the data, or null if it can't be retrieved.
- Throws:
IOException- if the data couldn't be retrieved.NullPointerException- ifentryNameisnull.
-
getInputStream
Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a stream.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.- Returns:
- an open input stream of the data, or null if it can't be retrieved.
- Throws:
IOException- if the data couldn't be retrieved.NullPointerException- ifentryNameisnull.ArrayIndexOutOfBoundsException- if start < 0 or >= size.
-
getInputStream
Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a stream.The names are case-insensitive.
- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry with which to start the search.- Returns:
- an open input stream of the data, or null if it can't be retrieved.
- Throws:
IOException- if the data couldn't be retrieved.NullPointerException- ifentryNameisnull.ArrayIndexOutOfBoundsException- if start < 0 or >= size.
-
getInputStream
Retrieves the data of the specified entry from a starting index and returns it as a stream.- Parameters:
entry- the entry to use.- Returns:
- an open input stream of the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.
-
getReader
Retrieves a Reader for an entry at a particular index as a decoded stream of characters.- Parameters:
n- the index of the entry in the Wad.charset- the source charset encoding.- Returns:
- a Reader for reading the character stream.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getReader
Retrieves a Reader for the first occurrence of a particular entry as a decoded stream of characters.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.charset- the source charset encoding.- Returns:
- a Reader for reading the character stream, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getReader
Retrieves a Reader for the first occurrence of a particular entry from a starting index as a decoded stream of characters.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the starting index to search from.charset- the source charset encoding.- Returns:
- a Reader for reading the character stream, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getReader
default Reader getReader(String entryName, String startEntryName, Charset charset) throws IOException Retrieves a Reader for the first occurrence of a particular entry from a starting entry (by name) as a decoded stream of characters.The names are case-insensitive.
- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.charset- the source charset encoding.- Returns:
- a Reader for reading the character stream, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getReader
Retrieves a Reader for the specified entry as a decoded stream of characters.- Parameters:
entry- the entry to use.charset- the source charset encoding.- Returns:
- a Reader for reading the character stream.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getContent
Gets a series of bytes representing the data at an arbitrary place in the Wad.- Parameters:
offset- the offset byte into that data to start at.length- the amount of bytes to return.- Returns:
- a copy of the byte data as an array of bytes.
- Throws:
IndexOutOfBoundsException- if offset plus length will go past the end of the content area.IOException- if an error occurs during read.- Since:
- 2.2.0
-
getData
Retrieves the data of a particular entry index.- Parameters:
n- the index of the entry in the Wad.- Returns:
- a byte array of the data.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.
-
getData
Retrieves the data of the first occurrence of a particular entry.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.- Returns:
- a byte array of the data, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved.
-
getData
Retrieves the data of the first occurrence of a particular entry from a starting index.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.- Returns:
- a byte array of the data, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved.NullPointerException- ifentryNameisnull.ArrayIndexOutOfBoundsException- if start < 0 or >= size.
-
getData
Retrieves the data of the first occurrence of a particular entry from a starting entry (by name).The names are case-insensitive.
- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.- Returns:
- a byte array of the data, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved.NullPointerException- ifentryNameorstartEntryNameisnull.
-
getData
Retrieves the data of the specified entry.- Parameters:
entry- the entry to use.- Returns:
- a byte array of the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.
-
getTextData
Retrieves the data of an entry at a particular index as a decoded string of characters.- Parameters:
n- the index of the entry in the Wad.charset- the source charset encoding.- Returns:
- the data, decoded.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getTextData
Retrieves the data of the first occurrence of a particular entry as a decoded string of characters.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.charset- the source charset encoding.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextData
Retrieves the data of the first occurrence of a particular entry from a starting index as a decoded string of characters.The name is case-insensitive.
- Parameters:
entryName- the name of the entry to find.start- the starting index to search from.charset- the source charset encoding.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextData
default String getTextData(String entryName, String startEntryName, Charset charset) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a decoded string of characters.The names are case-insensitive.
- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.charset- the source charset encoding.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextData
Retrieves the data of the specified entry as a decoded string of characters.- Parameters:
entry- the entry to use.charset- the source charset encoding.- Returns:
- the data, decoded.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getTextDataAs
default <TO extends TextObject> TO getTextDataAs(int n, Charset charset, Class<TO> type) throws IOException Retrieves the text data of an entry at a particular index as an interpreted text-originating object.- Type Parameters:
TO- the result type.- Parameters:
n- the index of the entry in the Wad.charset- the source charset encoding.type- the object type to convert the text data to.- Returns:
- the data, decoded.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getTextDataAs
default <TO extends TextObject> TO getTextDataAs(String entryName, Charset charset, Class<TO> type) throws IOException Retrieves the data of the first occurrence of a particular entry as an interpreted text-originating object.The name is case-insensitive.
- Type Parameters:
TO- the result type.- Parameters:
entryName- the name of the entry to find.charset- the source charset encoding.type- the object type to convert the text data to.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextDataAs
default <TO extends TextObject> TO getTextDataAs(String entryName, int start, Charset charset, Class<TO> type) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index as an interpreted text-originating object.The name is case-insensitive.
- Type Parameters:
TO- the result type.- Parameters:
entryName- the name of the entry to find.start- the starting index to search from.charset- the source charset encoding.type- the object type to convert the text data to.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextDataAs
default <TO extends TextObject> TO getTextDataAs(String entryName, String startEntryName, Charset charset, Class<TO> type) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as an interpreted text-originating object.The names are case-insensitive.
- Type Parameters:
TO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.charset- the source charset encoding.type- the object type to convert the text data to.- Returns:
- the data, decoded, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getTextDataAs
default <TO extends TextObject> TO getTextDataAs(WadEntry entry, Charset charset, Class<TO> type) throws IOException Retrieves the data of the specified entry as an interpreted text-originating object.- Type Parameters:
TO- the result type.- Parameters:
entry- the entry to use.charset- the source charset encoding.type- the type to decode to.- Returns:
- the data, decoded.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getDataAs
Retrieves the data of an entry at a particular index as a deserialized lump.Note that if the lump ordinarily as multiple amounts of the object type in question, this will read only the first one.
- Type Parameters:
BO- the result type.- Parameters:
n- the index of the entry in the Wad.type- the class type to deserialize into.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getDataAs
Retrieves the data of the first occurrence of a particular entry as a deserialized lump.The name is case-insensitive.
Note that if the lump ordinarily as multiple amounts of the object type in question, this will read only the first one.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO getDataAs(String entryName, int start, Class<BO> type) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump.The name is case-insensitive.
Note that if the lump ordinarily as multiple amounts of the object type in question, this will read only the first one.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO getDataAs(String entryName, String startEntryName, Class<BO> type) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump.The names are case-insensitive.
Note that if the lump ordinarily as multiple amounts of the object type in question, this will read only the first one.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
Retrieves the data of the specified entry as a deserialized lump.Note that if the lump ordinarily as multiple amounts of the object type in question, this will read only the first one.
- Type Parameters:
BO- the result type.- Parameters:
entry- the entry to use.type- the class type to deserialize into.- Returns:
- the data, deserialized.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO[] getDataAs(int n, Class<BO> type, int objectLength) throws IOException Retrieves the data of an entry at a particular index as a deserialized lump of multiple objects.- Type Parameters:
BO- the result type.- Parameters:
n- the index of the entry in the Wad.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO[] getDataAs(String entryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry as a deserialized lump of multiple objects.The name is case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO[] getDataAs(String entryName, int start, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump of multiple objects.The name is case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO[] getDataAs(String entryName, String startEntryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump of multiple objects.The names are case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAs
default <BO extends BinaryObject> BO[] getDataAs(WadEntry entry, Class<BO> type, int objectLength) throws IOException Retrieves the data of the specified entry as a deserialized lump of multiple objects.- Type Parameters:
BO- the result type.- Parameters:
entry- the entry to use.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getDataAsList
default <BO extends BinaryObject> List<BO> getDataAsList(int n, Class<BO> type, int objectLength) throws IOException Retrieves the data of an entry at a particular index as a deserialized lump of multiple objects.- Type Parameters:
BO- the result type.- Parameters:
n- the index of the entry in the Wad.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- See Also:
-
getDataAsList
default <BO extends BinaryObject> List<BO> getDataAsList(String entryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry as a deserialized lump of multiple objects.The name is case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAsList
default <BO extends BinaryObject> List<BO> getDataAsList(String entryName, int start, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index as a deserialized lump of multiple objects.The name is case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAsList
default <BO extends BinaryObject> List<BO> getDataAsList(String entryName, String startEntryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) as a deserialized lump of multiple objects.The names are case-insensitive.
- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized, or null if the entry doesn't exist.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryNameisnull.- See Also:
-
getDataAsList
default <BO extends BinaryObject> List<BO> getDataAsList(WadEntry entry, Class<BO> type, int objectLength) throws IOException Retrieves the data of the specified entry as a deserialized lump of multiple objects.- Type Parameters:
BO- the result type.- Parameters:
entry- the entry to use.type- the class type to deserialize into.objectLength- the length of each individual object in bytes.- Returns:
- the data, deserialized.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.- See Also:
-
getScanner
default <BO extends BinaryObject> BinaryObject.Scanner<BO> getScanner(int n, Class<BO> type, int objectLength) throws IOException Retrieves the data of a particular entry at a specific index and returns it as a deserializing scanner iterator that returns independent instances of objects.Use of this to iterate through objects may be preferable when all of them in a lump do not need to be scanned or deserialized.
If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
n- the index of the entry.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.ArrayIndexOutOfBoundsException- if n < 0 or >= size.
-
getScanner
default <BO extends BinaryObject> BinaryObject.Scanner<BO> getScanner(String entryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry and returns it as a deserializing scanner iterator that returns independent instances of objects.Use of this to iterate through objects may be preferable when all of them in a lump do not need to be scanned or deserialized.
The name is case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.Scanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getScanner
default <BO extends BinaryObject> BinaryObject.Scanner<BO> getScanner(String entryName, int start, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a deserializing scanner iterator that returns independent instances of objects.Use of this to iterate through objects may be preferable when all of them in a lump do not need to be scanned or deserialized.
The name is case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.Scanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getScanner
default <BO extends BinaryObject> BinaryObject.Scanner<BO> getScanner(String entryName, String startEntryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a deserializing scanner iterator that returns independent instances of objects.Use of this to iterate through objects may be preferable when all of them in a lump do not need to be scanned or deserialized.
The names are case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.Scanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getScanner
default <BO extends BinaryObject> BinaryObject.Scanner<BO> getScanner(WadEntry entry, Class<BO> type, int objectLength) throws IOException Retrieves the data of the specified entry and returns it as a deserializing scanner iterator that returns independent instances of objects.Use of this to iterate through objects may be preferable when all of them in a lump do not need to be scanned or deserialized.
If you don't intend to read the entirety of the entry via the
BinaryObject.Scanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entry- the entry to use.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.
-
getInlineScanner
default <BO extends BinaryObject> BinaryObject.InlineScanner<BO> getInlineScanner(int n, Class<BO> type, int objectLength) throws IOException Retrieves the data of a particular entry at a specific index and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.This is useful for when you would want to quickly scan through a set of serialized objects while ensuring low memory use. Do NOT store the references returned by
next()anywhere as the contents of that reference will be changed by the next call tonext().If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
n- the index of the entry.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.ArrayIndexOutOfBoundsException- if n < 0 or >= size.
-
getInlineScanner
default <BO extends BinaryObject> BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.This is useful for when you would want to quickly scan through a set of serialized objects while ensuring low memory use. Do NOT store the references returned by
next()anywhere as the contents of that reference will be changed by the next call tonext().The name is case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getInlineScanner
default <BO extends BinaryObject> BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, int start, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting index and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.This is useful for when you would want to quickly scan through a set of serialized objects while ensuring low memory use. Do NOT store the references returned by
next()anywhere as the contents of that reference will be changed by the next call tonext().The name is case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getInlineScanner
default <BO extends BinaryObject> BinaryObject.InlineScanner<BO> getInlineScanner(String entryName, String startEntryName, Class<BO> type, int objectLength) throws IOException Retrieves the data of the first occurrence of a particular entry from a starting entry (by name) and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.This is useful for when you would want to quickly scan through a set of serialized objects while ensuring low memory use. Do NOT store the references returned by
next()anywhere as the contents of that reference will be changed by the next call tonext().The names are case-insensitive.
If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data, or null if the entry can't be found.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.
-
getInlineScanner
default <BO extends BinaryObject> BinaryObject.InlineScanner<BO> getInlineScanner(WadEntry entry, Class<BO> type, int objectLength) throws IOException Retrieves the data of the specified entry and returns it as a deserializing scanner iterator that returns the same object instance with its contents changed.This is useful for when you would want to quickly scan through a set of serialized objects while ensuring low memory use. Do NOT store the references returned by
next()anywhere as the contents of that reference will be changed by the next call tonext().If you don't intend to read the entirety of the entry via the
BinaryObject.InlineScanner, close it after you finish (or use a try-with-resources block)!- Type Parameters:
BO- the result type.- Parameters:
entry- the entry to use.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.- Returns:
- a scanner for the data.
- Throws:
IOException- if the data couldn't be retrieved or the entry's offsets breach the file extents.NullPointerException- ifentryisnull.
-
transformData
default <BO extends BinaryObject> void transformData(int n, Class<BO> type, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry index, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
n- the index of the entry in the Wad.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, Class<BO> type, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, int start, Class<BO> type, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, String startEntryName, Class<BO> type, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> void transformData(int n, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the data of a particular entry index as a deserialized lump of multiple objects, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
n- the index of the entry in the Wad.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.transformer- the transformer function to use - called on each object read.- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, int start, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer, false
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformData
default <BO extends BinaryObject> boolean transformData(String entryName, String startEntryName, Class<BO> type, int objectLength, BinaryObject.Transformer<BO> transformer) throws IOException Retrieves the deserialized data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
BO- the data type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.type- the class type to deserialize into.objectLength- the length of each object in the entry in bytes.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer, false
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformTextData
default <TO extends TextObject> void transformTextData(int n, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) throws IOException Retrieves the decoded data of a particular entry index, optionally transforms it, then writes it back to the Wad.- Type Parameters:
TO- the data type.- Parameters:
n- the index of the entry in the Wad.charset- the source charset encoding.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformTextData
default <TO extends TextObject> boolean transformTextData(String entryName, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) throws IOException Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
TO- the data type.- Parameters:
entryName- the name of the entry to find.charset- the source charset encoding.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformTextData
default <TO extends TextObject> boolean transformTextData(String entryName, int start, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) throws IOException Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
TO- the data type.- Parameters:
entryName- the name of the entry to find.start- the index with which to start the search.charset- the source charset encoding.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
transformTextData
default <TO extends TextObject> boolean transformTextData(String entryName, String startEntryName, Charset charset, Class<TO> type, TextObject.Transformer<TO> transformer) throws IOException Retrieves the decoded data of a particular entry, optionally transforms it, then writes it back to the Wad.- Type Parameters:
TO- the data type.- Parameters:
entryName- the name of the entry to find.startEntryName- the starting entry (by name) with which to start the search.charset- the source charset encoding.type- the class type to deserialize into.transformer- the transformer function to use - called on each object read.- Returns:
- true if the entry was found and the transformer function was called at least once, false otherwise.
- Throws:
IOException- if the data couldn't be retrieved.ArrayIndexOutOfBoundsException- if n < 0 or >= size.- Since:
- 2.1.0
-
contains
Checks if this Wad contains a particular entry, false otherwise.The name is case-insensitive.
- Parameters:
entryName- the name of the entry.- Returns:
- true if so, false if not.
-
contains
Checks if this Wad contains a particular entry from a starting entry index, false otherwise.The name is case-insensitive.
- Parameters:
entryName- the name of the entry.index- the index to start from.- Returns:
- true if so, false if not.
-
contains
Checks if this Wad contains a particular entry from a starting entry (by name), false otherwise.The names are case-insensitive.
- Parameters:
entryName- the name of the entry.startEntryName- the starting entry (by name).- Returns:
- true if so, false if not.
-
addEntry
Adds 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!- 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- ifnameisnull.
-
addEntry
Adds a new entry to the Wad. Exercise caution with this method, as this entry is added as-is, and an entry can reference anywhere in the Wad!- Parameters:
entry- the entry to add.- Returns:
- the entry added.
- Throws:
IOException- if the entry cannot be written.NullPointerException- ifentryisnull.- Since:
- 2.9.0
-
addEntryAt
Adds a new entry to the Wad at a specific index, but with an explicit offset and size. The rest of the entries afterward are shifted an index forward. Exercise caution with this method, since you can reference anywhere in the Wad!- Parameters:
index- the index at which to add the entry.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- ifnameisnull.- Since:
- 2.7.0
-
addEntryAt
Adds a new entry to the Wad. Exercise caution with this method, as this entry is added as-is, and an entry can reference anywhere in the Wad!- Parameters:
index- the index at which to add the entry.entry- the entry to add.- Returns:
- the entry added.
- Throws:
IOException- if the entry cannot be written.NullPointerException- ifentryisnull.- Since:
- 2.9.0
-
addMarker
Adds 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- ifnameisnull.
-
addMarkerAt
Adds 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- ifnameisnull.
-
addData
Adds data to this Wad, usingentryNameas the name of the new entry. 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.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- ifentryNameordataisnull.
-
addData
Adds data to this Wad, usingentryNameas the name of the new entry. The overhead for multiple individual 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 viaBinaryObject.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- ifentryNameordataisnull.- Since:
- 2.2.0
-
addData
Adds 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 individual 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 viaBinaryObject.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- ifentryNameordataisnull.- Since:
- 2.2.0
-
addData
default <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 individual 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 viaTextObject.toText(), thenString.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- ifentryNameordataorencodingisnull.- Since:
- 2.2.0
-
addData
Adds 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- ifentryNameorfileToAddisnull.- Since:
- 2.7.0
-
addData
Adds 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 input stream is NOT CLOSED, afterward. 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.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- ifentryNameorinisnull.- Since:
- 2.7.0
-
addData
Adds 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 input stream is NOT CLOSED, afterward. 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.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- ifentryNameorinisnull.- Since:
- 2.7.0
-
addDataAt
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 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.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- ifentryNameordataisnull.
-
addDataAt
default <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 individual 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 viaBinaryObject.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- ifentryNameordataisnull.- Since:
- 2.2.0
-
addDataAt
default <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 individual 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 viaBinaryObject.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- ifentryNameordataisnull.- Since:
- 2.2.0
-
addDataAt
default <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 individual 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 viaTextObject.toText(), thenString.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- ifentryNameordataisnull.- Since:
- 2.2.0
-
addDataAt
Adds 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- ifentryNameorfileToAddisnull.- Since:
- 2.7.0
-
addDataAt
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. The input stream is NOT CLOSED, afterward. The rest of the entries in the wad are shifted down one index. 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.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- ifentryNameorinisnull.- Since:
- 2.7.0
-
addDataAt
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 input stream is NOT CLOSED, afterward. The rest of the entries in the wad are shifted down one index. 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.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- ifentryNameorinisnull.- Since:
- 2.7.0
-
addFrom
Takes entries and their data from another Wad and adds it to this one.- Parameters:
source- the the source Wad.startIndex- the starting entry index.maxLength- the maximum amount of entries from the starting index to copy.- Throws:
IOException- if an error occurs on read from the source Wad or write to this Wad.- Since:
- 2.5.0
-
addFrom
Takes entries and their data from another Wad and adds it to this one.- Parameters:
source- the the source Wad.entries- the entries to copy over.- Throws:
IOException- if an error occurs on read from the source Wad or write to this Wad.- Since:
- 2.5.0
-
addFromAt
Takes entries and their data from another Wad and adds it to this one at a specific index.- Parameters:
destIndex- the index at which to add the entries.source- the the source Wad.startIndex- the starting entry index.maxLength- the maximum amount of entries from the starting index to copy.- Throws:
IndexOutOfBoundsException- if the provided index < 0 or >getEntryCount().IOException- if an error occurs on read from the source Wad or write to this Wad.- Since:
- 2.5.0
-
addFromAt
Takes entries and their data from another Wad and adds it to this one at a specific index.- Parameters:
destIndex- the index at which to add the entries.source- the the source Wad.entries- the entries to copy over.- Throws:
IndexOutOfBoundsException- if the provided index < 0 or >getEntryCount().IOException- if an error occurs on read from the source Wad or write to this Wad.- Since:
- 2.5.0
-
replaceEntry
Replaces the entry at an index in the Wad. If the incoming data is the same size as the entry at the index, this will change the data in-place without deleting and adding.- Parameters:
index- the index of the entry to replace.data- the data to replace the entry with.- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be replaced.NullPointerException- ifdataisnull.
-
replaceEntry
Replaces the entry at an index in the Wad. If the incoming data is the same size as the entry at the index, this will change the data in-place without deleting and adding.- Type Parameters:
BO- the BinaryObject type.- Parameters:
index- the index of the entry to replace.data- the data to replace the entry with.- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be replaced.NullPointerException- ifdataisnull.- Since:
- 2.4.0
-
replaceEntry
Replaces the entry at an index in the Wad. If the incoming data is the same size as the entry at the index, this will change the data in-place without deleting and adding.- Type Parameters:
BO- the BinaryObject type.- Parameters:
index- the index of the entry to replace.data- the BinaryObjects to replace as this wad's data (converted viaBinaryObject.toBytes()).- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be replaced.NullPointerException- ifdataisnull.- Since:
- 2.4.0
-
replaceEntry
default <TO extends TextObject> void replaceEntry(int index, TO data, Charset encoding) throws IOException Replaces the entry at an index in the Wad. If the incoming data is the same size as the entry at the index, this will change the data in-place without deleting and adding.- Type Parameters:
TO- a TextObject type.- Parameters:
index- the index of the entry to replace.data- the TextObject to add as this Wad's data (converted viaTextObject.toText(), thenString.getBytes(Charset)).encoding- the encoding type for the data written to the Wad.- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be replaced.NullPointerException- ifdataisnull.- Since:
- 2.4.0
-
renameEntry
Renames the entry at an index in the Wad.- Parameters:
index- the index of the entry to rename.newName- the new name of the entry.- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be renamed.
-
removeEntry
Remove a Wad's entry (but not contents). This will leave abandoned, un-addressed data in a Wad file and will not be removed until the data is purged.- Parameters:
index- the index of the entry to delete.- Returns:
- the entry removed from the Wad.
- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be removed.
-
deleteEntry
Deletes a Wad's entry and its contents. The overhead for multiple deletions may be expensive I/O-wise.- Parameters:
index- the index of the entry to delete.- Returns:
- the entry deleted.
- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the entry cannot be deleted.
-
setEntry
Replaces an entry in the Wad - no content, just descriptor. Exercise caution with this method, as this entry is added as-is, and an entry can reference anywhere in the Wad!This is equivalent to:
unmapEntries(index, entry).- Parameters:
index- the index of the entry to change.entry- the entry to set.- Throws:
IndexOutOfBoundsException- if index < 0 or >= size.IOException- if the file cannot be altered in such a manner.- Since:
- 2.9.0
- See Also:
-
mapEntries
Retrieves a contiguous set of entries from this Wad, starting from a desired index. If the amount of entries desired goes outside the Wad's potential set of entries, this will retrieve up to those entries (for example,mapEntries(5, 10)in an 8-entry Wad will only return 3 entries: 5, 6, and 7).- Parameters:
startIndex- the starting index to map from (inclusive).maxLength- the amount of entries to retrieve from the index position.- Returns:
- an array of references to
WadEntryobjects. - Throws:
IllegalArgumentException- if startIndex is less than 0.
-
unmapEntries
Replaces a series of WadEntry objects in this Wad, using the provided list of entries as the replacement list. If the list of entries plus the starting index would breach the original list of entries, the excess is appended to the Wad.- Parameters:
startIndex- the starting index to replace from (inclusive).entryList- the set of entries to replace (in order) from the starting index.- Throws:
IOException- if the entries could not be written.IllegalArgumentException- if startIndex is less than 0.
-
setEntries
Completely replaces the list of entries in this Wad with a completely different set of entries.- Parameters:
entryList- the set of entries that will make up this Wad.- Throws:
IOException- if the entries could not be written.IllegalArgumentException- if startIndex is less than 0.
-
close
Closes this Wad. Does nothing on some implementations.- Throws:
IOException- if an error occurred during close.
-