Package net.mtrop.doom.text.data
Class MapInfoData
java.lang.Object
net.mtrop.doom.text.data.MapInfoData
- All Implemented Interfaces:
Iterable<MapInfoData>
An abstraction of MapInfo data.
MapInfo data is mostly a mapping of names to values, however they are stored in an order that
may matter to the host program (especially structures).
- Since:
- 2.19.0
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionMapInfoData
(String name) Creates MapInfoData with a specific name.MapInfoData
(String name, MapInfoData.Value... values) Creates MapInfoData with a specific name and values. -
Method Summary
Modifier and TypeMethodDescriptionaddChild
(String type, MapInfoData.Value... typeValues) Creates a new, empty value set at the end of the list of sets.addChildAt
(int index, String type, MapInfoData.Value... typeValues) Creates a new, empty value set to add to at a specific index in the list of sets.getChildAt
(int index) Gets a specific typed value set from this MapInfo by its index.int
getName()
getValue()
getValue
(int valueIndex) Gets the value at a particular index.boolean
Checks if this data has child data.boolean
Checks if this item is a directive (has no values/children attached to it).boolean
isValues()
Checks if this is just values (just values, no children);iterator()
removeChildAt
(int index) Removes a value set at a specific index.void
Sets this data's name.void
setValues
(MapInfoData.Value... values) Sets/replaces the values on this data.toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
MapInfoData
Creates MapInfoData with a specific name.- Parameters:
name
- the name of the data.
-
MapInfoData
Creates MapInfoData with a specific name and values.- Parameters:
name
- the name of the data.values
- the values.
-
-
Method Details
-
setName
Sets this data's name.- Parameters:
name
- the new name.
-
setValues
Sets/replaces the values on this data.- Parameters:
values
- the values to set.
-
getName
- Returns:
- this item's name, or null if no name.
-
getValues
- Returns:
- the array of values, or null if purely a data structure or directive.
-
addChild
Creates a new, empty value set at the end of the list of sets.- Parameters:
type
- the set type.typeValues
- the set type's values (if any).- Returns:
- the created empty set.
- Throws:
IndexOutOfBoundsException
- if the index is less than 0 or greater than or equal to the amount of sets in this MapInfo.
-
addChildAt
Creates a new, empty value set to add to at a specific index in the list of sets.- Parameters:
index
- the index to add to.type
- the set type.typeValues
- the set type's values (if any).- Returns:
- the created empty set.
- Throws:
IndexOutOfBoundsException
- if the index is less than 0 or greater than or equal to the amount of sets in this MapInfo.
-
getChildAt
Gets a specific typed value set from this MapInfo by its index.- Parameters:
index
- the index of the value set.- Returns:
- the value set at the index.
- Throws:
IndexOutOfBoundsException
- if the index is less than 0 or greater than or equal to the amount of sets in this MapInfo.
-
removeChildAt
Removes a value set at a specific index.- Parameters:
index
- the index.- Returns:
- the removed set.
- Throws:
IndexOutOfBoundsException
- if the index is less than 0 or greater than or equal to the amount of sets in this MapInfo.
-
getChildCount
public int getChildCount()- Returns:
- the amount of data sets in this MapInfo.
-
iterator
- Specified by:
iterator
in interfaceIterable<MapInfoData>
-
hasChildren
public boolean hasChildren()Checks if this data has child data.- Returns:
- true if so, false if not.
-
isDirective
public boolean isDirective()Checks if this item is a directive (has no values/children attached to it).- Returns:
- true if so, false if not.
-
isValues
public boolean isValues()Checks if this is just values (just values, no children);- Returns:
- true if so, false if not.
-
getValue
Gets the value at a particular index.- Parameters:
valueIndex
- the value's index.- Returns:
- the corresponding value, or null if no value.
-
getValue
- Returns:
- the first value.
-
toString
-