Package net.mtrop.doom.texture
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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
Adds a patch entry.void
clear()
Clears this list of patches.get
(int index) Gets the patch entry at a specific index.int
Gets the index of a patch name in this lump by its name.boolean
isEmpty()
Returns if this object contains no objects.iterator()
void
readBytes
(InputStream in) Reads from anInputStream
and sets this object's fields.boolean
Attempts to remove an entry by its name.removeIndex
(int index) Removes an entry at an index.int
size()
void
writeBytes
(OutputStream out) Writes this object to anOutputStream
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.mtrop.doom.object.BinaryObject
fromBytes, readFile, toBytes, writeFile, writeFile
Methods 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:
-
get
Gets the patch entry at a specific index.- Parameters:
index
- the index to look up.- Returns:
- the corresponding index or
null
if 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
null
if no entry at that index.
-
readBytes
Description copied from interface:BinaryObject
Reads from anInputStream
and 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:
readBytes
in interfaceBinaryObject
- Parameters:
in
- theInputStream
to read from.- Throws:
IOException
- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObject
Writes this object to anOutputStream
.- Specified by:
writeBytes
in interfaceBinaryObject
- Parameters:
out
- theOutputStream
to write to.- Throws:
IOException
- if a write error occurs.
-
iterator
-
size
public int size() -
isEmpty
public boolean isEmpty()Description copied from interface:Sizable
Returns if this object contains no objects. The general policy of this method is that this returns true if and only ifSizable.size()
returns 0.
-