com.threerings.editor
Class PathProperty

java.lang.Object
  extended by com.threerings.util.DeepObject
      extended by com.threerings.editor.Property
          extended by com.threerings.editor.PathProperty
All Implemented Interfaces:
Copyable, Cloneable
Direct Known Subclasses:
ArgumentPathProperty, TranslatedPathProperty

public class PathProperty
extends Property

A property that


Nested Class Summary
protected static class PathProperty.IndexProperty
          Superclass for properties addressing components of other properties.
 
Field Summary
protected  Property[][] _paths
          The property chains for each path.
 
Fields inherited from class com.threerings.editor.Property
_argumentTypes, _configTypes, _genericArgumentTypes, _name
 
Constructor Summary
PathProperty(ConfigManager cfgmgr, String name, Object reference, String... paths)
          Creates a new path property.
 
Method Summary
protected static Object coerce(Object value, Class<?> type)
          Coerces the supplied value to the given type.
static Property[] createPath(ConfigManager cfgmgr, Object object, String path)
          Attempts to resolve the provided path into a property chain, returning null on failure.
 Object get(Object object)
          Retrieves the value of the property.
 String getColorName()
          Returns the name of the color lookup for the property.
 Type getGenericType()
          Returns the generic property type.
 double getMaximum()
          Returns the maximum value.
 int getMaxSize()
          Returns the maximum size;
 Member getMember()
          Returns the underlying member of the property (the field or method that provides the annotations).
 Object getMemberObject(Object object)
          Returns a reference to the member object (the object to whose member Property.getMember() refers, given the object one would pass to Property.get(java.lang.Object) or Property.set(java.lang.Object, java.lang.Object)).
 double getMinimum()
          Returns the minimum value.
 int getMinSize()
          Returns the minimum size.
 String getMode()
          Returns the mode string.
protected static Property getProperty(ConfigManager cfgmgr, Object object, Property base, StreamTokenizer tok)
          Provides additional handling for subscripts.
protected static Property getProperty(ConfigManager cfgmgr, Object object, StreamTokenizer tok)
          Attempts to find and return the named property, returning null on failure.
 double getScale()
          Returns the scale value.
 double getStep()
          Returns the step value.
 Class<?> getType()
          Returns the property type.
 String getUnits()
          Returns the units string.
 void set(Object object, Object value)
          Sets the value of the property.
protected  void setProperty(Object obj, Object value, Property prop, boolean coerce)
          Sets the property value.
 boolean shouldTranslateName()
          Returns whether or not we should attempt to translate the name.
 
Methods inherited from class com.threerings.editor.Property
addSubtypes, addSubtypes, getAnnotation, getAnnotation, getArgumentType, getArgumentTypes, getBoolean, getByte, getChar, getComponentSubtypes, getComponentType, getComponentTypeLabel, getDouble, getEditorTypes, getFloat, getGenericArgumentType, getGenericArgumentTypes, getGenericComponentType, getInt, getLong, getMessageBundle, getName, getShort, getSubtypes, getSubtypes, getTypeArguments, getTypeArguments, getTypeArguments, getTypeClass, getTypeLabel, getTypeLabel, isAnnotationPresent, isLegalValue, setBoolean, setByte, setChar, setDouble, setFloat, setInt, setLong, setShort, toString
 
Methods inherited from class com.threerings.util.DeepObject
clone, copy, copy, equals, hashCode
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

_paths

protected Property[][] _paths
The property chains for each path.

Constructor Detail

PathProperty

public PathProperty(ConfigManager cfgmgr,
                    String name,
                    Object reference,
                    String... paths)
             throws InvalidPathsException
Creates a new path property.

Parameters:
cfgmgr - the config manager to use when resolving references.
name - the name of the property.
reference - the reference object from which we derive our property chains.
paths - the list of paths.
Throws:
InvalidPathsException - if none of the supplied paths are valid.
Method Detail

createPath

public static Property[] createPath(ConfigManager cfgmgr,
                                    Object object,
                                    String path)
Attempts to resolve the provided path into a property chain, returning null on failure.


shouldTranslateName

public boolean shouldTranslateName()
Description copied from class: Property
Returns whether or not we should attempt to translate the name.

Overrides:
shouldTranslateName in class Property

getColorName

public String getColorName()
Description copied from class: Property
Returns the name of the color lookup for the property.

Overrides:
getColorName in class Property

getMember

public Member getMember()
Description copied from class: Property
Returns the underlying member of the property (the field or method that provides the annotations).

Specified by:
getMember in class Property

getMemberObject

public Object getMemberObject(Object object)
Description copied from class: Property
Returns a reference to the member object (the object to whose member Property.getMember() refers, given the object one would pass to Property.get(java.lang.Object) or Property.set(java.lang.Object, java.lang.Object)).

Overrides:
getMemberObject in class Property

getType

public Class<?> getType()
Description copied from class: Property
Returns the property type.

Specified by:
getType in class Property

getGenericType

public Type getGenericType()
Description copied from class: Property
Returns the generic property type.

Specified by:
getGenericType in class Property

getMode

public String getMode()
Description copied from class: Property
Returns the mode string. Usually this comes from the property annotation, but derived classes may inherit values from elsewhere.

Overrides:
getMode in class Property

getUnits

public String getUnits()
Description copied from class: Property
Returns the units string.

Overrides:
getUnits in class Property

getMinimum

public double getMinimum()
Description copied from class: Property
Returns the minimum value.

Overrides:
getMinimum in class Property

getMaximum

public double getMaximum()
Description copied from class: Property
Returns the maximum value.

Overrides:
getMaximum in class Property

getStep

public double getStep()
Description copied from class: Property
Returns the step value.

Overrides:
getStep in class Property

getScale

public double getScale()
Description copied from class: Property
Returns the scale value.

Overrides:
getScale in class Property

getMinSize

public int getMinSize()
Description copied from class: Property
Returns the minimum size.

Overrides:
getMinSize in class Property

getMaxSize

public int getMaxSize()
Description copied from class: Property
Returns the maximum size;

Overrides:
getMaxSize in class Property

get

public Object get(Object object)
Description copied from class: Property
Retrieves the value of the property.

Specified by:
get in class Property

set

public void set(Object object,
                Object value)
Description copied from class: Property
Sets the value of the property.

Specified by:
set in class Property

setProperty

protected void setProperty(Object obj,
                           Object value,
                           Property prop,
                           boolean coerce)
Sets the property value.


getProperty

protected static Property getProperty(ConfigManager cfgmgr,
                                      Object object,
                                      StreamTokenizer tok)
                               throws IOException
Attempts to find and return the named property, returning null on failure.

Throws:
IOException

getProperty

protected static Property getProperty(ConfigManager cfgmgr,
                                      Object object,
                                      Property base,
                                      StreamTokenizer tok)
                               throws IOException
Provides additional handling for subscripts.

Throws:
IOException

coerce

protected static Object coerce(Object value,
                               Class<?> type)
Coerces the supplied value to the given type.