|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PList
This class implements a Property list. Properties are requested by by name, and the value can be any arbitrary Java object.
The accessor methods of this class will first check the list for the specified property. If it isn't found, the method will look for a parent link, recursively, until it finds a top-level archetype with no parent.
If you call removeProperty() on an object, you normally don't want it to inherit the parent's value for that property anymore. For instance, if the parent is an archetype with the "cursed" property, then after you call removeProperty("cursed") on your object, you expect hasProperty("cursed") to return false. So the system keeps an internal value for the property on your object that indicates: "this property is null - don't inherit it from the parent." You can override this behavior by calling inheritProperty(name), in which case, the object will get the inherited value from then on.
Every object has a transient property list. Transient props are not written out to disk when you save the object. You can temporarily tell an object not to inherit the parent's value by calling transientlyRemoveProperty(name), and it will put a placeholder in the transient list, so that for the rest of that session, the getProperty(), hasProperty(), getIntProperty(), etc. will return null, zero, or false as appropriate, even if the parent list or local list has the property.
If you call removeTransientProperty(name), then it just removes the name from the transient property list. This means that the object will use its local (persistent) value, or if there isn't one, the inherited value.
Property names are case-sensitive. Following the standard naming conventions (all lower-case, with hyphens) will help reduce errors related to misspelling the property name.
Field Summary | |
protected boolean |
readOnly_
Set this for system archetypes, when you want them to throw an exception if you try to set a property on them. |
Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
Constructor Summary | |
PList()
Constructs a new PList |
Method Summary | |
void |
addProperty(java.lang.String name)
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. |
java.lang.String |
debugProperties()
Prints out the property list, showing which ones are inherited and which ones are local. |
void |
dismantlePropertyList()
Dismantles the property list, in anticipation of it going away forever. |
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. |
static java.lang.Integer |
getInteger(int value)
Returns a new Integer object for the specified int value. |
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. |
static java.lang.String |
getProfilingInfo()
Returns profiling info. |
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()
Returns a string representation of this PropertyList. |
java.lang.String |
toString(boolean inherit)
Returns a string represenation of this property list. |
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. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected boolean readOnly_
Constructor Detail |
public PList()
Method Detail |
public final java.lang.Object getProperty(java.lang.String name)
PropertyList
Integer glows = (Integer) myObj.getProperty( "LightSource" );
getProperty
in interface PropertyList
name
- the name of the property
public final java.lang.Object getTransientProperty(java.lang.String name)
PropertyList
getTransientProperty
in interface PropertyList
name
- the name of the property
public final java.lang.Object getPersistentProperty(java.lang.String name)
PropertyList
getPersistentProperty
in interface PropertyList
name
- the property name
public final void setProperty(java.lang.String name, java.lang.Object value)
PropertyList
setProperty
in interface PropertyList
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.public final void setTransientProperty(java.lang.String name, java.lang.Object value)
PropertyList
setTransientProperty
in interface PropertyList
name
- the property namevalue
- the property value. If null, calls
removeTransientProperty(name).public final void addProperty(java.lang.String name)
PropertyList
addProperty
in interface PropertyList
public final void addTransientProperty(java.lang.String name)
PropertyList
addTransientProperty
in interface PropertyList
name
- the name of the property to addpublic final boolean hasProperty(java.lang.String name)
PropertyList
hasProperty
in interface PropertyList
name
- the property to check for
public final boolean hasPersistentProperty(java.lang.String name)
PropertyList
hasPersistentProperty
in interface PropertyList
name
- the property to look for in the persistent list
public final boolean hasTransientProperty(java.lang.String name)
PropertyList
hasTransientProperty
in interface PropertyList
name
- the name of the property to check for in the
transient list - ignores any persistent setting.
public final boolean hasLocalProperty(java.lang.String name)
PropertyList
hasLocalProperty
in interface PropertyList
name
- the property to check for
public final java.lang.Object getLocalProperty(java.lang.String name)
PropertyList
getLocalProperty
in interface PropertyList
name
- the name of the property
public final java.lang.Object getInheritedProperty(java.lang.String name)
PropertyList
getInheritedProperty
in interface PropertyList
name
- the property name
public final boolean isRemoved(java.lang.String name)
PropertyList
isRemoved
in interface PropertyList
name
- the property name to check
public final boolean isTransientlyRemoved(java.lang.String name)
PropertyList
isTransientlyRemoved
in interface PropertyList
name
- the property name to check
public final int countLocalProperties()
PropertyList
countLocalProperties
in interface PropertyList
public final java.util.Set getLocalProperties()
PropertyList
getLocalProperties
in interface PropertyList
public final java.util.Set getPersistentLocalProperties()
PropertyList
getPersistentLocalProperties
in interface PropertyList
public final java.lang.String getStringProperty(java.lang.String name)
PropertyList
getStringProperty
in interface PropertyList
name
- the property name to look up
public final int getIntProperty(java.lang.String name)
PropertyList
getIntProperty
in interface PropertyList
name
- the property name
public final void setIntProperty(java.lang.String name, int value)
PropertyList
setIntProperty
in interface PropertyList
name
- the property namevalue
- the new int value for the propertypublic final int adjustIntProperty(java.lang.String name, int adjust)
PropertyList
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.
adjustIntProperty
in interface PropertyList
name
- the property nameadjust
- the int value to add to the property.
public final int getTransientIntProperty(java.lang.String name)
PropertyList
getTransientIntProperty
in interface PropertyList
name
- the property name
public final void setTransientIntProperty(java.lang.String name, int value)
PropertyList
setTransientIntProperty
in interface PropertyList
name
- the property namevalue
- the new transient int value for the propertypublic final int adjustTransientIntProperty(java.lang.String name, int adjust)
PropertyList
adjustTransientIntProperty
in interface PropertyList
name
- the property nameadjust
- the int value to add to the property.
public final int getPersistentIntProperty(java.lang.String name)
PropertyList
getPersistentIntProperty
in interface PropertyList
name
- the property name
public final long getLongProperty(java.lang.String name)
PropertyList
getLongProperty
in interface PropertyList
name
- the property name
public final void setLongProperty(java.lang.String name, long value)
PropertyList
setLongProperty
in interface PropertyList
name
- the property namevalue
- the new long value for the propertypublic final long adjustLongProperty(java.lang.String name, long adjust)
PropertyList
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.
adjustLongProperty
in interface PropertyList
name
- the property nameadjust
- the long value to add to the property.
public final long getTransientLongProperty(java.lang.String name)
PropertyList
getTransientLongProperty
in interface PropertyList
name
- the property name
public final void setTransientLongProperty(java.lang.String name, long value)
PropertyList
setTransientLongProperty
in interface PropertyList
name
- the property namevalue
- the new transient long value for the propertypublic final long adjustTransientLongProperty(java.lang.String name, long adjust)
PropertyList
adjustTransientLongProperty
in interface PropertyList
name
- the property nameadjust
- the long value to add to the property.public final long getPersistentLongProperty(java.lang.String name)
PropertyList
getPersistentLongProperty
in interface PropertyList
name
- the property name
public final double getDoubleProperty(java.lang.String name)
PropertyList
getDoubleProperty
in interface PropertyList
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.
public final void setDoubleProperty(java.lang.String name, double value)
PropertyList
setDoubleProperty
in interface PropertyList
name
- the property namevalue
- the new double value for the propertypublic final double adjustDoubleProperty(java.lang.String name, double adjust)
PropertyList
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.
adjustDoubleProperty
in interface PropertyList
name
- the property nameadjust
- the double value to add to the property.
public final double getTransientDoubleProperty(java.lang.String name)
PropertyList
getTransientDoubleProperty
in interface PropertyList
name
- the property name
public final void setTransientDoubleProperty(java.lang.String name, double value)
PropertyList
setTransientDoubleProperty
in interface PropertyList
name
- the property namevalue
- the new transient double value for the propertypublic final double adjustTransientDoubleProperty(java.lang.String name, double adjust)
PropertyList
adjustTransientDoubleProperty
in interface PropertyList
name
- the property nameadjust
- the double value to add to the property.public final double getPersistentDoubleProperty(java.lang.String name)
PropertyList
getPersistentDoubleProperty
in interface PropertyList
name
- the property name
public final java.lang.Object removeProperty(java.lang.String name)
PropertyList
removeProperty
in interface PropertyList
name
- the property to remove.
removeProperty only removes persistent properties - use removeTransientProperty to remove transient properties.
public final java.lang.Object removeTransientProperty(java.lang.String name)
PropertyList
removeTransientProperty
in interface PropertyList
name
- the property name
public final java.lang.Object transientlyRemoveProperty(java.lang.String name)
PropertyList
You can do this permanently (tell the object that it should never inherit the parent value) by calling removeProperty().
transientlyRemoveProperty
in interface PropertyList
name
- the property name to hide, transiently
If the old value implemented AddRemoveNotify, its notifyRemove() method will be called before returning.
public final java.lang.Object inheritProperty(java.lang.String name)
PropertyList
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.
inheritProperty
in interface PropertyList
name
- the property name
public final java.util.Set getProperties()
PropertyList
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().
getProperties
in interface PropertyList
public final java.util.Set getPropertiesIncludingTransients()
PropertyList
getPropertiesIncludingTransients
in interface PropertyList
public final java.util.Set getProperties(boolean inherit)
PropertyList
getProperties
in interface PropertyList
inherit
- true to include inherited properties, if any.
If false, only returns local properties.public final java.util.Set getPropertiesIncludingTransients(boolean inherit)
PropertyList
getPropertiesIncludingTransients
in interface PropertyList
inherit
- true to include all inherited properties as well.
If false, only returns local and transient properties.
public final java.util.Set getSerializableProperties()
PropertyList
getSerializableProperties
in interface PropertyList
public final java.util.Set getTransientProperties()
PropertyList
getTransientProperties
in interface PropertyList
public final java.lang.Object getSerializableProperty(java.lang.String name)
PropertyList
getSerializableProperty
in interface PropertyList
name
- the property name
public final void dismantlePropertyList()
public java.lang.String toString()
public java.lang.String toString(boolean inherit)
toString
in interface PropertyList
inherit
- true to include inherited properties in the list
public java.lang.String printProperties()
PropertyList
printProperties
in interface PropertyList
public java.lang.String printProperties(boolean inherit)
PropertyList
printProperties
in interface PropertyList
inherit
- true to print inherited properties as well.
public java.lang.String printTransientProperties()
PropertyList
printTransientProperties
in interface PropertyList
public java.lang.String printLocalProperties()
PropertyList
printLocalProperties
in interface PropertyList
public final java.lang.String debugProperties()
public final PropertyList getParent()
PropertyList
getParent
in interface PropertyList
public final void setParent(PropertyList parent)
PropertyList
setParent
in interface PropertyList
public final void setReadOnly(boolean readOnly)
PropertyList
setReadOnly
in interface PropertyList
readOnly
- true to make the list read-only, false to
allow modificationpublic final boolean isReadOnly()
PropertyList
isReadOnly
in interface PropertyList
public static final java.lang.Integer getInteger(int value)
value
- an int value
public static java.lang.String getProfilingInfo()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |