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 Constructor Description CustomPropertyProvider()
CustomPropertyProvider(ICustomPropertyProvider propertyProviderToBeCopied)
Copy Constructor for copying instances of CustomPropertyProviders.Method Summary
Modifier and Type Method Description boolean
getBoolValue(java.lang.String propertyName)
Gets the boolean value of the custom property with the provided name.boolean
getBoolValue(java.lang.String propertyName, boolean defaultValue)
Gets the boolean value of the custom property with the provided name.byte
getByteValue(java.lang.String propertyName)
Gets the byte value of the custom property with the provided name.byte
getByteValue(java.lang.String propertyName, byte defaultValue)
Gets the byte value of the custom property with the provided name.java.awt.Color
getColorValue(java.lang.String propertyName)
Gets the color value of the custom property with the provided name.java.awt.Color
getColorValue(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.double
getDoubleValue(java.lang.String propertyName)
Gets the double value of the custom property with the provided name.double
getDoubleValue(java.lang.String propertyName, double defaultValue)
Gets the double value of the custom property with the provided name.<T extends java.lang.Enum<T>>
TgetEnumValue(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>>
TgetEnumValue(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.URL
getFileValue(java.lang.String propertyName)
Gets the file value of the custom property with the provided name.java.net.URL
getFileValue(java.lang.String propertyName, java.net.URL defaultValue)
Gets the file value of the custom property with the provided name.float
getFloatValue(java.lang.String propertyName)
Gets the float value of the custom property with the provided name.float
getFloatValue(java.lang.String propertyName, float defaultValue)
Gets the float value of the custom property with the provided name.int
getIntValue(java.lang.String propertyName)
Gets the int value of the custom property with the provided name.int
getIntValue(java.lang.String propertyName, int defaultValue)
Gets the int value of the custom property with the provided name.long
getLongValue(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 aMap
view of the custom properties for thisICustomPropertyProvider
.ICustomProperty
getProperty(java.lang.String propertyName)
short
getShortValue(java.lang.String propertyName)
Gets the short value of the custom property with the provided name.short
getShortValue(java.lang.String propertyName, short defaultValue)
Gets the short value of the custom property with the provided name.java.lang.String
getStringValue(java.lang.String propertyName)
Gets the string value of the custom property with the provided name.java.lang.String
getStringValue(java.lang.String propertyName, java.lang.String defaultValue)
Gets the string value of the custom property with the provided name.java.lang.String
getTypeOfProperty(java.lang.String propertyName)
boolean
hasCustomProperty(java.lang.String propertyName)
Checks if a custom property with the given name is present.void
removeProperty(java.lang.String propertyName)
void
setProperties(java.util.Map<java.lang.String,ICustomProperty> props)
Sets all of the custom properties on this object to the provided values.void
setTypeOfProperty(java.lang.String propertyName, java.lang.String type)
void
setValue(java.lang.String propertyName, boolean value)
Sets the value for the custom property with the given name to the given boolean.void
setValue(java.lang.String propertyName, byte value)
Sets the value for the custom property with the given name to the given byte.void
setValue(java.lang.String propertyName, double value)
Sets the value for the custom property with the given name to the given double.void
setValue(java.lang.String propertyName, float value)
Sets the value for the custom property with the given name to the given float.void
setValue(java.lang.String propertyName, int value)
Sets the value for the custom property with the given name to the given int.void
setValue(java.lang.String propertyName, long value)
Sets the value for the custom property with the given name to the given long.void
setValue(java.lang.String propertyName, short value)
Sets the value for the custom property with the given name to the given short.void
setValue(java.lang.String propertyName, ICustomProperty value)
void
setValue(java.lang.String propertyName, java.awt.Color value)
Sets the value for the custom property with the given name to the given color.void
setValue(java.lang.String propertyName, java.lang.Enum<?> value)
Sets the value for the custom property with the given name to the given enum.void
setValue(java.lang.String propertyName, java.lang.String value)
Sets the value for the custom property with the given name to the given string.void
setValue(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
CustomPropertyProvider
public CustomPropertyProvider()CustomPropertyProvider
Copy Constructor for copying instances of CustomPropertyProviders.- Parameters:
propertyProviderToBeCopied
- the PropertyProvider we want to copy
Method Details
getProperties
Description copied from interface:ICustomPropertyProvider
Returns aMap
view of the custom properties for thisICustomPropertyProvider
.- Specified by:
getProperties
in interfaceICustomPropertyProvider
- Returns:
- a
Map
view of the custom properties for thisICustomPropertyProvider
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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
setTypeOfProperty
public void setTypeOfProperty(java.lang.String propertyName, java.lang.String type)- Specified by:
setTypeOfProperty
in interfaceICustomPropertyProvider
getProperty
- Specified by:
getProperty
in interfaceICustomPropertyProvider
setValue
- Specified by:
setValue
in interfaceICustomPropertyProvider
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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- Type Parameters:
T
- the enum type to use- Parameters:
propertyName
- the name of the custom propertyenumType
- aClass
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 interfaceICustomPropertyProvider
- Type Parameters:
T
- the enum type to use- Parameters:
propertyName
- the name of the custom propertyenumType
- aClass
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 interfaceICustomPropertyProvider
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- 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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertyvalue
- the new value
setProperties
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 interfaceICustomPropertyProvider
- Parameters:
props
- the new list of properties
removeProperty
public void removeProperty(java.lang.String propertyName)- Specified by:
removeProperty
in interfaceICustomPropertyProvider
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 interfaceICustomPropertyProvider
- Parameters:
propertyName
- the name of the custom propertydefaultValue
- 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.