Class UDMFObject

java.lang.Object
net.mtrop.doom.map.udmf.UDMFObject
All Implemented Interfaces:
Iterable<Map.Entry<String,Object>>

public class UDMFObject extends Object implements Iterable<Map.Entry<String,Object>>
Main descriptor for all UDMF objects.
Author:
Matthew Tropiano
  • Constructor Details

    • UDMFObject

      public UDMFObject()
      Creates a new UDMFObject.
  • Method Details

    • clear

      public void clear()
      Clears all attributes from the structure.
    • get

      public Object get(String attributeName)
      Gets a corresponding attribute by name.
      Parameters:
      attributeName - the name of the attribute.
      Returns:
      the corresponding value, or null if no value.
    • remove

      public Object remove(String attributeName)
      Removes a corresponding attribute by name.
      Parameters:
      attributeName - the name of the attribute.
      Returns:
      the removed value, or null if no value.
    • set

      public void set(String attributeName, Object value)
      Sets an attribute value by name.
      Parameters:
      attributeName - the name of the attribute.
      value - the value of the attribute, null to remove.
    • setBoolean

      public void setBoolean(String attributeName, Boolean value)
      Gets the boolean value of an arbitrary object attribute. Non-empty strings and non-zero numbers are true.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      value - the attribute value.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • getBoolean

      public Boolean getBoolean(String attributeName)
      Gets the boolean value of an arbitrary object attribute. Non-empty strings and non-zero numbers are true.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      Returns:
      the integer value of an object attribute, or null if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • getBoolean

      public Boolean getBoolean(String attributeName, Boolean def)
      Gets the boolean value of an arbitrary object attribute. Non-empty strings and non-zero numbers are true.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      def - the default value if one does not exist.
      Returns:
      the integer value of an object attribute, or def if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • setInteger

      public void setInteger(String attributeName, Integer value)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Integer, it is cast to an Integer.

      Strings are attempted to be parsed as integers. Floating-point values are chopped. Booleans are 1 if true, 0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      value - the attribute value.
    • getInteger

      public Integer getInteger(String attributeName)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Integer, it is cast to an Integer.

      Strings are attempted to be parsed as integers. Floating-point values are chopped. Booleans are 1 if true, 0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      Returns:
      the integer value of an object attribute, or null if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • getInteger

      public Integer getInteger(String attributeName, Integer def)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Integer, it is cast to an Integer.

      Strings are attempted to be parsed as integers. Floating-point values are chopped. Booleans are 1 if true, 0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      def - the default value if one does not exist.
      Returns:
      the integer value of an object attribute, or def if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • setFloat

      public void setFloat(String attributeName, Float value)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Float, it is cast to a Float.

      Strings are attempted to be parsed as floating point numbers. Integers are promoted. Booleans are 1.0 if true, 0.0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      value - the attribute value.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • getFloat

      public Float getFloat(String attributeName)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Float, it is cast to a Float.

      Strings are attempted to be parsed as floating point numbers. Integers are promoted. Booleans are 1.0 if true, 0.0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      Returns:
      the floating-point value of an object attribute, or null if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • getFloat

      public Float getFloat(String attributeName, Float def)
      Gets the integer value of an arbitrary object attribute. If the value is castable to Float, it is cast to a Float.

      Strings are attempted to be parsed as floating point numbers. Integers are promoted. Booleans are 1.0 if true, 0.0 if false.

      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      def - the default value if one does not exist.
      Returns:
      the floating-point value of an object attribute, or def if the attribute is not implemented nor exists.
      Throws:
      NumberFormatException - if the value was originally a String and can't be converted.
    • setString

      public void setString(String attributeName, String value)
      Sets the string value of an arbitrary object attribute. If the value is promotable to String (integers/floats/booleans), it is promoted to a String.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      value - the attribute value.
    • getString

      public String getString(String attributeName)
      Gets the string value of an arbitrary object attribute. If the value is promotable to String (integers/floats/booleans), it is promoted to a String.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      Returns:
      the string value of an object attribute, or null if the attribute is not implemented nor exists.
    • getString

      public String getString(String attributeName, String def)
      Gets the string value of an arbitrary object attribute. If the value is promotable to String (integers/floats/booleans), it is promoted to a String.
      Parameters:
      attributeName - the attribute name (may be standardized, depending on implementation).
      def - the default value if one does not exist.
      Returns:
      the string value of an object attribute, or def if the attribute is not implemented nor exists.
    • iterator

      public Iterator<Map.Entry<String,Object>> iterator()
      Specified by:
      iterator in interface Iterable<Map.Entry<String,Object>>