|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Every GameObject and GameMap has a PropertyList that holds its persistent data, in the form of properties.
Properties are mappings of strings to arbitrary values. The values can be primitive types or any Java or Jython object.
Property lists can inherit from other property lists. They have a parent pointer that can be accessed by getParent(). You can set transient property values in the list. This is useful if you want to make sure your transient value never gets saved out - for instance, if a player wears a ring of invisibility, you don't want the invisible property to be saved out, in case the server crashes after the save (the player would then be permanently invisible). Transient properties have special rules:
Note: Setting a transient property never affects the inherited property list - transient properties are always local properties, never inherited.
Field Summary | |
static java.lang.String |
PROPERTY_PACKAGE
|
Method Summary | |
void |
addProperty(java.lang.String property)
Adds a persistent boolean property to the list. |
void |
addTransientProperty(java.lang.String name)
Adds a boolean property to the transient property list. |
double |
adjustDoubleProperty(java.lang.String name,
double adjust)
Adds an adjustment value (which can be negative) to the persistent value of a double property. |
int |
adjustIntProperty(java.lang.String name,
int adjust)
Adds an adjustment value (which can be negative) to the persistent value of an int property. |
long |
adjustLongProperty(java.lang.String name,
long adjust)
Adds an adjustment value (which can be negative) to the persistent value of a long property. |
double |
adjustTransientDoubleProperty(java.lang.String name,
double adjust)
Adjusts a double property, where the adjustment is transient (meaning temporary - not saved to the XML file if the object owning this plist is saved out). |
int |
adjustTransientIntProperty(java.lang.String name,
int adjust)
Adjusts an int property, where the adjustment is transient (meaning temporary - not saved to the XML file if the object owning this plist is saved out). |
long |
adjustTransientLongProperty(java.lang.String name,
long adjust)
Adjusts a long property, where the adjustment is transient (meaning temporary - not saved to the XML file if the object owning this plist is saved out). |
int |
countLocalProperties()
Returns the number of non-inherited properties we have in our transient and persistent lists. |
double |
getDoubleProperty(java.lang.String name)
Returns the value of a double (bigint) property. |
java.lang.Object |
getInheritedProperty(java.lang.String name)
Returns the inherited value of the specified property, if any. |
int |
getIntProperty(java.lang.String name)
Returns the value of an int property. |
java.util.Set |
getLocalProperties()
Returns a Set of the names of all the transient and non-inherited persistent properties on this object. |
java.lang.Object |
getLocalProperty(java.lang.String name)
Gets the local value of a property. |
long |
getLongProperty(java.lang.String name)
Returns the value of a long (bigint) property. |
PropertyList |
getParent()
Returns the parent list for this list, if any. |
double |
getPersistentDoubleProperty(java.lang.String name)
Gets the current persistent value of a double property. |
int |
getPersistentIntProperty(java.lang.String name)
Gets the current persistent value of an int property. |
java.util.Set |
getPersistentLocalProperties()
Returns a Set of the names of all the non-inherited persistent properties on this object. |
long |
getPersistentLongProperty(java.lang.String name)
Gets the current persistent value of a long property. |
java.lang.Object |
getPersistentProperty(java.lang.String name)
Returns the persistent (i.e. normal) value for the property, if found. |
java.util.Set |
getProperties()
Returns the names of all the list's local properties. |
java.util.Set |
getProperties(boolean inherit)
Returns all the list's properties, optionally including inherited ones. |
java.util.Set |
getPropertiesIncludingTransients()
Returns the names of all the lists's local properties, including names in the transient list. |
java.util.Set |
getPropertiesIncludingTransients(boolean inherit)
Returns the names of all the lists's local properties, including names in the transient list, and optionally including inherited properties as well. |
java.lang.Object |
getProperty(java.lang.String name)
Returns the value of the requested Property. |
java.util.Set |
getSerializableProperties()
Returns the names of all the lists's local properties, including any properties that have NullValue as values - meaning someone called removeProperty() on them, and the null overrides an inherited version of the property. |
java.lang.Object |
getSerializableProperty(java.lang.String name)
Returns a local property value, but unlike its counterpart getPersistentProperty(), if the value is a NullValue placeholder for when someone called removeProperty() to override an inherited value, this method returns the NullValue. |
java.lang.String |
getStringProperty(java.lang.String name)
Returns getProperty(name) with the return value cast as a String. |
double |
getTransientDoubleProperty(java.lang.String name)
Gets the current transient value of a double property. |
int |
getTransientIntProperty(java.lang.String name)
Gets the current transient value of an int property. |
long |
getTransientLongProperty(java.lang.String name)
Gets the current transient value of a long property. |
java.util.Set |
getTransientProperties()
Returns ONLY the transient properties on this object. |
java.lang.Object |
getTransientProperty(java.lang.String name)
Returns the transient value for the property, if anyone has set one. |
boolean |
hasLocalProperty(java.lang.String name)
Checks whether a given property is local to an object. |
boolean |
hasPersistentProperty(java.lang.String name)
Checks whether the list contains the given property in the persistent property list - ignores any transient setting. |
boolean |
hasProperty(java.lang.String name)
Checks whether the list contains the given property. |
boolean |
hasTransientProperty(java.lang.String name)
Returns true if the transient list contains the specified property. |
java.lang.Object |
inheritProperty(java.lang.String name)
This is like removeProperty(), except that it just removes the property name from the local persistent property list. |
boolean |
isReadOnly()
Returns true if this property list has been marked read-only. |
boolean |
isRemoved(java.lang.String name)
A very special-purpose method, mostly for use by the Map Editor, that lets you determine if a property is explicitly suppressing its inherited value. |
boolean |
isTransientlyRemoved(java.lang.String name)
Same as isRemoved(), but checks the transient list. |
java.lang.String |
printLocalProperties()
Prints only local, persistent properties: the list returned from getProperties(false). |
java.lang.String |
printProperties()
Prints out a nicely formatted list of properties on this object. |
java.lang.String |
printProperties(boolean inherit)
Prints out a nicely formatted list of properties on this object. |
java.lang.String |
printTransientProperties()
Prints only local, transient properties from the object. |
java.lang.Object |
removeProperty(java.lang.String name)
Removes a persistent property from the list. |
java.lang.Object |
removeTransientProperty(java.lang.String name)
Removes a property from the transient list. |
void |
setDoubleProperty(java.lang.String name,
double value)
Sets the persistent value of a double property. |
void |
setIntProperty(java.lang.String name,
int value)
Sets the persistent value of an int property. |
void |
setLongProperty(java.lang.String name,
long value)
Sets the persistent value of a long property. |
void |
setParent(PropertyList parent)
Sets the parent list for this list. |
void |
setProperty(java.lang.String name,
java.lang.Object value)
Sets a persistent property on an object. |
void |
setReadOnly(boolean readOnly)
Marks the property list as read-only, so you can't set, remove, or change properties in the list. |
void |
setTransientDoubleProperty(java.lang.String name,
double value)
Sets a transient double value explicitly. |
void |
setTransientIntProperty(java.lang.String name,
int value)
Sets a transient int value explicitly. |
void |
setTransientLongProperty(java.lang.String name,
long value)
Sets a transient long value explicitly. |
void |
setTransientProperty(java.lang.String name,
java.lang.Object value)
Sets a transient property. |
java.lang.String |
toString(boolean inherit)
Returns a string representation of this PropertyList, optionally including values of inherited properties. |
java.lang.Object |
transientlyRemoveProperty(java.lang.String name)
Tells the object to temporarily act as if it doesn't have a local/persistent or inherited value for this property name. |
Field Detail |
public static final java.lang.String PROPERTY_PACKAGE
Method Detail |
public java.lang.Object getProperty(java.lang.String name)
Integer glows = (Integer) myObj.getProperty( "LightSource" );
name
- the name of the property
public java.lang.Object getTransientProperty(java.lang.String name)
name
- the name of the property
public java.lang.Object getPersistentProperty(java.lang.String name)
name
- the property name
public void setProperty(java.lang.String name, java.lang.Object value)
name
- the new property to set. If the property
already existed, replaces the old value with the new one.
Puts the property in the persistent list; has no effect
on any transient value for the property.value
- the new value for the property. If null, the property
will be removed from the list. To add a "tag" property with
no value, use the addProperty() method.
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic void setTransientProperty(java.lang.String name, java.lang.Object value)
name
- the property namevalue
- the property value. If null, calls
removeTransientProperty(name).
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic void addProperty(java.lang.String property)
java.lang.IllegalStateException
- if the list is marked read-onlypublic void addTransientProperty(java.lang.String name)
name
- the name of the property to add
java.lang.IllegalStateException
- if the list is marked read-onlypublic boolean hasProperty(java.lang.String name)
name
- the property to check for
public boolean hasPersistentProperty(java.lang.String name)
name
- the property to look for in the persistent list
public boolean hasTransientProperty(java.lang.String name)
name
- the name of the property to check for in the
transient list - ignores any persistent setting.
public boolean hasLocalProperty(java.lang.String name)
name
- the property to check for
public java.lang.Object getLocalProperty(java.lang.String name)
name
- the name of the property
public java.lang.Object getInheritedProperty(java.lang.String name)
name
- the property name
public java.lang.String getStringProperty(java.lang.String name)
name
- the property name to look up
public int getIntProperty(java.lang.String name)
name
- the property name
IllegalValueException
- if the value is not an Integer
(either in the transient list or the persistent list)public void setIntProperty(java.lang.String name, int value)
name
- the property namevalue
- the new int value for the property
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic int adjustIntProperty(java.lang.String name, int adjust)
If the property doesn't exist, it's created first with a value of zero before adjusting it. Has no effect on any transient int value for the property, if one has been set. If the property exists on an ancestor archetype, a copy will be made locally on the object before doing the adjustment.
name
- the property nameadjust
- the int value to add to the property.
java.lang.NullPointerException
- if the name is null
IllegalValueException
- if the value stored under the
passed name isn't an Integer.
java.lang.IllegalStateException
- if the list is marked read-onlypublic int getTransientIntProperty(java.lang.String name)
name
- the property name
java.lang.NullPointerException
- if the name is nullpublic void setTransientIntProperty(java.lang.String name, int value)
name
- the property namevalue
- the new transient int value for the property
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic int adjustTransientIntProperty(java.lang.String name, int adjust)
name
- the property nameadjust
- the int value to add to the property.
IllegalValueException
- if the value stored under the
passed property isn't an Integer.
java.lang.IllegalStateException
- if the list is marked read-only
java.lang.NullPointerException
- if the name is nullpublic int getPersistentIntProperty(java.lang.String name)
name
- the property name
public long getLongProperty(java.lang.String name)
name
- the property name
IllegalValueException
- if the value is not a long
(either in the transient list or the persistent list)public void setLongProperty(java.lang.String name, long value)
name
- the property namevalue
- the new long value for the property
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic long adjustLongProperty(java.lang.String name, long adjust)
If the property doesn't exist, it's created first with a value of zero before adjusting it. Has no effect on any transient long value for the property, if one has been set. If the property exists on an ancestor archetype, a copy will be made locally on the object before doing the adjustment.
name
- the property nameadjust
- the long value to add to the property.
java.lang.NullPointerException
- if the name is null
IllegalValueException
- if the value stored under the
passed name isn't a Long.
java.lang.IllegalStateException
- if the list is marked read-onlypublic long getTransientLongProperty(java.lang.String name)
name
- the property name
public void setTransientLongProperty(java.lang.String name, long value)
name
- the property namevalue
- the new transient long value for the property
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic long adjustTransientLongProperty(java.lang.String name, long adjust)
name
- the property nameadjust
- the long value to add to the property.
IllegalValueException
- if the value stored under the
passed property isn't a Long.
java.lang.IllegalStateException
- if the list is marked read-only
java.lang.NullPointerException
- if the name is nullpublic long getPersistentLongProperty(java.lang.String name)
name
- the property name
public double getDoubleProperty(java.lang.String name)
name
- the property name
If you don't want them added together, call getPersistentProperty() and getTransientProperty() on the name, and use the two Double results however you like.
IllegalValueException
- if the value is not a double
(either in the transient list or the persistent list)public void setDoubleProperty(java.lang.String name, double value)
name
- the property namevalue
- the new double value for the property
java.lang.IllegalStateException
- if the list is marked read-onlypublic double adjustDoubleProperty(java.lang.String name, double adjust)
If the property doesn't exist, it's created first with a value of zero before adjusting it. Has no effect on any transient double value for the property, if one has been set. If the property exists on an ancestor archetype, a copy will be made locally on the object before doing the adjustment.
name
- the property nameadjust
- the double value to add to the property.
IllegalValueException
- if the value stored under the
passed name isn't a Double.
java.lang.IllegalStateException
- if the list is marked read-onlypublic double getTransientDoubleProperty(java.lang.String name)
name
- the property name
public void setTransientDoubleProperty(java.lang.String name, double value)
name
- the property namevalue
- the new transient double value for the property
java.lang.NullPointerException
- if the name is null
java.lang.IllegalStateException
- if the list is marked read-onlypublic double adjustTransientDoubleProperty(java.lang.String name, double adjust)
name
- the property nameadjust
- the double value to add to the property.
IllegalValueException
- if the value stored under the
passed name isn't a Double
java.lang.IllegalStateException
- if the list is marked read-onlypublic double getPersistentDoubleProperty(java.lang.String name)
name
- the property name
public java.lang.Object removeProperty(java.lang.String name)
name
- the property to remove.
removeProperty only removes persistent properties - use removeTransientProperty to remove transient properties.
java.lang.IllegalStateException
- if the list is marked read-onlypublic java.lang.Object removeTransientProperty(java.lang.String name)
name
- the property name
java.lang.IllegalStateException
- if the list is marked read-onlypublic java.lang.Object transientlyRemoveProperty(java.lang.String name)
You can do this permanently (tell the object that it should never inherit the parent value) by calling removeProperty().
name
- the property name to hide, transiently
If the old value implemented AddRemoveNotify, its notifyRemove() method will be called before returning.
java.lang.IllegalStateException
- if you try to call this
method on a read-only property list.public java.lang.Object inheritProperty(java.lang.String name)
Note: if there's a transient value for this property, you have to call removeTransientProperty() on it as well, or you won't actually inherit the value after this call - you'll get the transient value instead.
name
- the property name
java.lang.IllegalStateException
- if you try to call this
method on a read-only property list.public java.util.Set getProperties()
Note: this returns a list of property names - for each name, there may or may not be a transient value. If you're iterating over the list and you only want persistent properties, you'll have to call getPersistentProperty() instead of getProperty().
public java.util.Set getPropertiesIncludingTransients()
public java.util.Set getProperties(boolean inherit)
inherit
- true to include inherited properties, if any.
If false, only returns local properties.public java.util.Set getPropertiesIncludingTransients(boolean inherit)
inherit
- true to include all inherited properties as well.
If false, only returns local and transient properties.
public java.util.Set getSerializableProperties()
public java.util.Set getTransientProperties()
public java.lang.Object getSerializableProperty(java.lang.String name)
name
- the property name
public java.lang.String toString(boolean inherit)
inherit
- true to include inherited properties, if any.
If false, only returns local properties.public java.lang.String printProperties()
public java.lang.String printProperties(boolean inherit)
inherit
- true to print inherited properties as well.
public java.lang.String printTransientProperties()
public java.lang.String printLocalProperties()
public int countLocalProperties()
public java.util.Set getLocalProperties()
public java.util.Set getPersistentLocalProperties()
public void setParent(PropertyList parent)
public PropertyList getParent()
public void setReadOnly(boolean readOnly)
readOnly
- true to make the list read-only, false to
allow modificationpublic boolean isReadOnly()
public boolean isRemoved(java.lang.String name)
name
- the property name to check
public boolean isTransientlyRemoved(java.lang.String name)
name
- the property name to check
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |