Class CustomPropertyProvider

java.lang.Object
de.gurkenlabs.litiengine.environment.tilemap.xml.CustomPropertyProvider
All Implemented Interfaces:
ICustomPropertyProvider
Direct Known Subclasses:
GameInfo, Layer, MapImage, MapObject, Material, Terrain, Tile, Tileset, TilesetEntry, TmxMap

public class CustomPropertyProvider
extends java.lang.Object
implements ICustomPropertyProvider
  • Constructor Summary

    Constructors 
    ConstructorDescription
    CustomPropertyProvider() 
    CustomPropertyProvider​(ICustomPropertyProvider propertyProviderToBeCopied)
    Copy Constructor for copying instances of CustomPropertyProviders.
  • Method Summary

    Modifier and TypeMethodDescription
    booleangetBoolValue​(java.lang.String propertyName)
    Gets the boolean value of the custom property with the provided name.
    booleangetBoolValue​(java.lang.String propertyName, boolean defaultValue)
    Gets the boolean value of the custom property with the provided name.
    bytegetByteValue​(java.lang.String propertyName)
    Gets the byte value of the custom property with the provided name.
    bytegetByteValue​(java.lang.String propertyName, byte defaultValue)
    Gets the byte value of the custom property with the provided name.
    java.awt.ColorgetColorValue​(java.lang.String propertyName)
    Gets the color value of the custom property with the provided name.
    java.awt.ColorgetColorValue​(java.lang.String propertyName, java.awt.Color defaultValue)
    Gets the color value of the custom property with the provided name.
    java.util.List<java.lang.String>getCommaSeparatedStringValues​(java.lang.String propertyName, java.lang.String defaultValue)
    Gets a list of strings stored in a single comma-separated property.
    doublegetDoubleValue​(java.lang.String propertyName)
    Gets the double value of the custom property with the provided name.
    doublegetDoubleValue​(java.lang.String propertyName, double defaultValue)
    Gets the double value of the custom property with the provided name.
    <T extends java.lang.Enum<T>>
    T
    getEnumValue​(java.lang.String propertyName, java.lang.Class<T> enumType)
    Gets the enum value of the custom property with the provided name.
    <T extends java.lang.Enum<T>>
    T
    getEnumValue​(java.lang.String propertyName, java.lang.Class<T> enumType, T defaultValue)
    Gets the enum value of the custom property with the provided name.
    java.net.URLgetFileValue​(java.lang.String propertyName)
    Gets the file value of the custom property with the provided name.
    java.net.URLgetFileValue​(java.lang.String propertyName, java.net.URL defaultValue)
    Gets the file value of the custom property with the provided name.
    floatgetFloatValue​(java.lang.String propertyName)
    Gets the float value of the custom property with the provided name.
    floatgetFloatValue​(java.lang.String propertyName, float defaultValue)
    Gets the float value of the custom property with the provided name.
    intgetIntValue​(java.lang.String propertyName)
    Gets the int value of the custom property with the provided name.
    intgetIntValue​(java.lang.String propertyName, int defaultValue)
    Gets the int value of the custom property with the provided name.
    longgetLongValue​(java.lang.String propertyName, long defaultValue)
    Gets the long value of the custom property with the provided name.
    java.util.Map<java.lang.String,​ICustomProperty>getProperties()
    Returns a Map view of the custom properties for this ICustomPropertyProvider.
    ICustomPropertygetProperty​(java.lang.String propertyName) 
    shortgetShortValue​(java.lang.String propertyName)
    Gets the short value of the custom property with the provided name.
    shortgetShortValue​(java.lang.String propertyName, short defaultValue)
    Gets the short value of the custom property with the provided name.
    java.lang.StringgetStringValue​(java.lang.String propertyName)
    Gets the string value of the custom property with the provided name.
    java.lang.StringgetStringValue​(java.lang.String propertyName, java.lang.String defaultValue)
    Gets the string value of the custom property with the provided name.
    java.lang.StringgetTypeOfProperty​(java.lang.String propertyName) 
    booleanhasCustomProperty​(java.lang.String propertyName)
    Checks if a custom property with the given name is present.
    voidremoveProperty​(java.lang.String propertyName) 
    voidsetProperties​(java.util.Map<java.lang.String,​ICustomProperty> props)
    Sets all of the custom properties on this object to the provided values.
    voidsetTypeOfProperty​(java.lang.String propertyName, java.lang.String type) 
    voidsetValue​(java.lang.String propertyName, boolean value)
    Sets the value for the custom property with the given name to the given boolean.
    voidsetValue​(java.lang.String propertyName, byte value)
    Sets the value for the custom property with the given name to the given byte.
    voidsetValue​(java.lang.String propertyName, double value)
    Sets the value for the custom property with the given name to the given double.
    voidsetValue​(java.lang.String propertyName, float value)
    Sets the value for the custom property with the given name to the given float.
    voidsetValue​(java.lang.String propertyName, int value)
    Sets the value for the custom property with the given name to the given int.
    voidsetValue​(java.lang.String propertyName, long value)
    Sets the value for the custom property with the given name to the given long.
    voidsetValue​(java.lang.String propertyName, short value)
    Sets the value for the custom property with the given name to the given short.
    voidsetValue​(java.lang.String propertyName, ICustomProperty value) 
    voidsetValue​(java.lang.String propertyName, java.awt.Color value)
    Sets the value for the custom property with the given name to the given color.
    voidsetValue​(java.lang.String propertyName, java.lang.Enum<?> value)
    Sets the value for the custom property with the given name to the given enum.
    voidsetValue​(java.lang.String propertyName, java.lang.String value)
    Sets the value for the custom property with the given name to the given string.
    voidsetValue​(java.lang.String propertyName, java.net.URL value)
    Sets the value for the custom property with the given name to the given file.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface de.gurkenlabs.litiengine.environment.tilemap.ICustomPropertyProvider

    getLongValue
  • Constructor Details

  • Method Details

    • getProperties

      public java.util.Map<java.lang.String,​ICustomProperty> getProperties()
      Description copied from interface: ICustomPropertyProvider
      Returns a Map view of the custom properties for this ICustomPropertyProvider.
      Specified by:
      getProperties in interface ICustomPropertyProvider
      Returns:
      a Map view of the custom properties for this ICustomPropertyProvider
    • hasCustomProperty

      public boolean hasCustomProperty​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Checks if a custom property with the given name is present.
      Specified by:
      hasCustomProperty in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      true if a custom property with the given name is present. False otherwise.
    • getTypeOfProperty

      public java.lang.String getTypeOfProperty​(java.lang.String propertyName)
      Specified by:
      getTypeOfProperty in interface ICustomPropertyProvider
    • setTypeOfProperty

      public void setTypeOfProperty​(java.lang.String propertyName, java.lang.String type)
      Specified by:
      setTypeOfProperty in interface ICustomPropertyProvider
    • getProperty

      public ICustomProperty getProperty​(java.lang.String propertyName)
      Specified by:
      getProperty in interface ICustomPropertyProvider
    • setValue

      public void setValue​(java.lang.String propertyName, ICustomProperty value)
      Specified by:
      setValue in interface ICustomPropertyProvider
    • getStringValue

      public java.lang.String getStringValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the string value of the custom property with the provided name.
      Specified by:
      getStringValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the string value of the custom property
    • getStringValue

      public java.lang.String getStringValue​(java.lang.String propertyName, java.lang.String defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the string value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getStringValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the string value of the custom property, if present. Otherwise, the provided default value is returned.
    • getIntValue

      public int getIntValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the int value of the custom property with the provided name.
      Specified by:
      getIntValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the int value of the custom property
    • getIntValue

      public int getIntValue​(java.lang.String propertyName, int defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the int value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getIntValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the int value of the custom property, if present. Otherwise, the provided default value is returned.
    • getLongValue

      public long getLongValue​(java.lang.String propertyName, long defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the long value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getLongValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the long value of the custom property, if present. Otherwise, the provided default value is returned.
    • getShortValue

      public short getShortValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the short value of the custom property with the provided name.
      Specified by:
      getShortValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the short value of the custom property
    • getShortValue

      public short getShortValue​(java.lang.String propertyName, short defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the short value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getShortValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the short value of the custom property, if present. Otherwise, the provided default value is returned.
    • getByteValue

      public byte getByteValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the byte value of the custom property with the provided name.
      Specified by:
      getByteValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the byte value of the custom property
    • getByteValue

      public byte getByteValue​(java.lang.String propertyName, byte defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the byte value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getByteValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the byte value of the custom property, if present. Otherwise, the provided default value is returned.
    • getBoolValue

      public boolean getBoolValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the boolean value of the custom property with the provided name.
      Specified by:
      getBoolValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the boolean value of the custom property
    • getBoolValue

      public boolean getBoolValue​(java.lang.String propertyName, boolean defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the boolean value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getBoolValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the boolean value of the custom property, if present. Otherwise, the provided default value is returned.
    • getFloatValue

      public float getFloatValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the float value of the custom property with the provided name.
      Specified by:
      getFloatValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the float value of the custom property
    • getFloatValue

      public float getFloatValue​(java.lang.String propertyName, float defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the float value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getFloatValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the float value of the custom property, if present. Otherwise, the provided default value is returned.
    • getDoubleValue

      public double getDoubleValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the double value of the custom property with the provided name.
      Specified by:
      getDoubleValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the double value of the custom property
    • getDoubleValue

      public double getDoubleValue​(java.lang.String propertyName, double defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the double value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getDoubleValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the double value of the custom property, if present. Otherwise, the provided default value is returned.
    • getColorValue

      public java.awt.Color getColorValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the color value of the custom property with the provided name.
      Specified by:
      getColorValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the color value of the custom property
    • getColorValue

      public java.awt.Color getColorValue​(java.lang.String propertyName, java.awt.Color defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the color value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getColorValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the color value of the custom property, if present. Otherwise, the provided default value is returned.
    • getEnumValue

      public <T extends java.lang.Enum<T>> T getEnumValue​(java.lang.String propertyName, java.lang.Class<T> enumType)
      Description copied from interface: ICustomPropertyProvider
      Gets the enum value of the custom property with the provided name.
      Specified by:
      getEnumValue in interface ICustomPropertyProvider
      Type Parameters:
      T - the enum type to use
      Parameters:
      propertyName - the name of the custom property
      enumType - a Class object for <T>
      Returns:
      the enum value of the custom property
    • getEnumValue

      public <T extends java.lang.Enum<T>> T getEnumValue​(java.lang.String propertyName, java.lang.Class<T> enumType, T defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the enum value of the custom property with the provided name. If the value is null, the provided default value is used as a fallback.
      Specified by:
      getEnumValue in interface ICustomPropertyProvider
      Type Parameters:
      T - the enum type to use
      Parameters:
      propertyName - the name of the custom property
      enumType - a Class object for <T>
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the enum value of the custom property, if present. Otherwise, the provided default value is returned.
    • getFileValue

      public java.net.URL getFileValue​(java.lang.String propertyName)
      Description copied from interface: ICustomPropertyProvider
      Gets the file value of the custom property with the provided name. If the property is not a file, null is returned instead.
      Specified by:
      getFileValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      Returns:
      the file value of the custom property, if present.
    • getFileValue

      public java.net.URL getFileValue​(java.lang.String propertyName, java.net.URL defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets the file value of the custom property with the provided name. If the value is null or the property is not a file, the provided default value is used as a fallback.
      Specified by:
      getFileValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the file value of the custom property, if present. Otherwise, the provided default value is returned.
    • setValue

      public void setValue​(java.lang.String propertyName, java.net.URL value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given file.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, java.lang.String value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given string.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, boolean value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given boolean.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, byte value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given byte.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, short value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given short.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, int value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given int.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, long value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given long.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, float value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given float.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, double value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given double.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, java.awt.Color value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given color.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setValue

      public void setValue​(java.lang.String propertyName, java.lang.Enum<?> value)
      Description copied from interface: ICustomPropertyProvider
      Sets the value for the custom property with the given name to the given enum.
      Specified by:
      setValue in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      value - the new value
    • setProperties

      public void setProperties​(java.util.Map<java.lang.String,​ICustomProperty> props)
      Description copied from interface: ICustomPropertyProvider
      Sets all of the custom properties on this object to the provided values. Properties are added when they only exist in the provided properties, and deleted when they only exist in the current properties.
      Specified by:
      setProperties in interface ICustomPropertyProvider
      Parameters:
      props - the new list of properties
    • removeProperty

      public void removeProperty​(java.lang.String propertyName)
      Specified by:
      removeProperty in interface ICustomPropertyProvider
    • getCommaSeparatedStringValues

      public java.util.List<java.lang.String> getCommaSeparatedStringValues​(java.lang.String propertyName, java.lang.String defaultValue)
      Description copied from interface: ICustomPropertyProvider
      Gets a list of strings stored in a single comma-separated property.
      Specified by:
      getCommaSeparatedStringValues in interface ICustomPropertyProvider
      Parameters:
      propertyName - the name of the custom property
      defaultValue - the fallback value in case the property value is null.
      Returns:
      the list of comma-separated strings in the custom property, if present. Otherwise, the provided default value is returned.