Class MapInfoData

java.lang.Object
net.mtrop.doom.text.data.MapInfoData
All Implemented Interfaces:
Iterable<MapInfoData>

public class MapInfoData extends Object implements 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
  • Constructor Details

    • MapInfoData

      public MapInfoData(String name)
      Creates MapInfoData with a specific name.
      Parameters:
      name - the name of the data.
    • MapInfoData

      public MapInfoData(String name, MapInfoData.Value... values)
      Creates MapInfoData with a specific name and values.
      Parameters:
      name - the name of the data.
      values - the values.
  • Method Details

    • setName

      public void setName(String name)
      Sets this data's name.
      Parameters:
      name - the new name.
    • setValues

      public void setValues(MapInfoData.Value... values)
      Sets/replaces the values on this data.
      Parameters:
      values - the values to set.
    • getName

      public String getName()
      Returns:
      this item's name, or null if no name.
    • getValues

      public MapInfoData.Value[] getValues()
      Returns:
      the array of values, or null if purely a data structure or directive.
    • addChild

      public MapInfoData addChild(String type, MapInfoData.Value... typeValues)
      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

      public MapInfoData 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.
      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

      public MapInfoData getChildAt(int index)
      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

      public MapInfoData removeChildAt(int index)
      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

      public Iterator<MapInfoData> iterator()
      Specified by:
      iterator in interface Iterable<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

      public MapInfoData.Value getValue(int valueIndex)
      Gets the value at a particular index.
      Parameters:
      valueIndex - the value's index.
      Returns:
      the corresponding value, or null if no value.
    • getValue

      public MapInfoData.Value getValue()
      Returns:
      the first value.
    • toString

      public String toString()
      Overrides:
      toString in class Object