Class PatchNames
java.lang.Object
net.mtrop.doom.texture.PatchNames
- All Implemented Interfaces:
Iterable<String>,BinaryObject,Sizable
A list of names of available patch entries for texture composition.
Texture patches use indices that reference this list.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject> -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintAdds a patch entry.intAdds a patch entry.voidclear()Clears this list of patches.get(int index) Gets the patch entry at a specific index.intGets the index of a patch name in this lump by its name.booleanisEmpty()Returns if this object contains no objects.iterator()voidreadBytes(InputStream in) Reads from anInputStreamand sets this object's fields.booleanAttempts to remove an entry by its name.removeIndex(int index) Removes an entry at an index.intsize()voidwriteBytes(OutputStream out) Writes this object to anOutputStream.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.mtrop.doom.object.BinaryObject
fromBytes, readFile, toBytes, writeFile, writeFileMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
nameList
List of names.
-
-
Constructor Details
-
PatchNames
public PatchNames()Creates a new PatchNames with a default starting capacity.
-
-
Method Details
-
clear
public void clear()Clears this list of patches. -
add
Adds a patch entry.- Parameters:
name- the entry name.- Returns:
- the index of the added entry, or an existing index if it was already in the list.
- Throws:
IllegalArgumentException- if the provided name is not a valid entry name.- See Also:
-
add
Adds a patch entry.- Parameters:
name- the entry name.allowDuplicates- if true, allow a duplicate entry.- Returns:
- the index of the added entry, or an existing index if it was already in the list and
allowDuplicatesisfalse. - Throws:
IllegalArgumentException- if the provided name is not a valid entry name.- Since:
- 2.18.0
- See Also:
-
get
Gets the patch entry at a specific index.- Parameters:
index- the index to look up.- Returns:
- the corresponding index or
nullif no corresponding entry.
-
indexOf
Gets the index of a patch name in this lump by its name. Search is sequential.- Parameters:
name- the name of the patch.- Returns:
- a valid index if found, or -1 if not.
-
remove
Attempts to remove an entry by its name. Note that this will shift the indices of the other entries.- Parameters:
name- the name of the entry.- Returns:
- true if removed, false if not.
-
removeIndex
Removes an entry at an index. Note that this will shift the indices of the other entries.- Parameters:
index- the index to use.- Returns:
- the entry removed, or
nullif no entry at that index.
-
readBytes
Description copied from interface:BinaryObjectReads from anInputStreamand sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!- Specified by:
readBytesin interfaceBinaryObject- Parameters:
in- theInputStreamto read from.- Throws:
IOException- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObjectWrites this object to anOutputStream.- Specified by:
writeBytesin interfaceBinaryObject- Parameters:
out- theOutputStreamto write to.- Throws:
IOException- if a write error occurs.
-
iterator
-
size
-
isEmpty
public boolean isEmpty()Description copied from interface:SizableReturns if this object contains no objects. The general policy of this method is that this returns true if and only ifSizable.size()returns 0.
-