public class PropertyDesc extends java.lang.Object implements PropertyInfo
| Modifier and Type | Class and Description |
|---|---|
static class |
PropertyDesc.TypeCode |
PropertyInfo.Edit, PropertyInfo.ExpandState| Modifier and Type | Field and Description |
|---|---|
static boolean |
debug |
static int |
INHERITABLE |
static int |
READ_ONLY |
static int |
REGULAR |
| Constructor and Description |
|---|
PropertyDesc(PropertyDesc prop,
java.lang.Class<?> hostClass)
Creates a new PropertyDesc by copying an existing one and updating it for
a specified host class.
|
PropertyDesc(java.lang.String name,
java.lang.Class<?> hostClass)
Creates a new PropertyDesc object with a specific property name and host
class.
|
PropertyDesc(java.lang.String name,
java.lang.Class<?> hostClass,
java.lang.Class<?> valueClass)
Creates a new PropertyDesc for a property with a specified name, host
class, and value class.
|
| Modifier and Type | Method and Description |
|---|---|
static PropertyDesc |
create(java.lang.String nameAndMethods,
java.lang.Class<?> hostClass,
java.lang.String descriptor,
java.lang.Object defaultValue,
java.lang.String options,
int propType) |
Property |
createHandle(HasProperties host)
Creates a handle to the property for a specified host object.
|
java.lang.Object |
createInstance(HasProperties host) |
boolean |
getAutoWrite()
Returns true if auto-writing is enabled for this property.
|
PropertyMode |
getDefaultMode()
Returns the default inheritance mode for the property.
|
NumericInterval |
getDefaultNumericRange()
Returns a default numeric range for this property, if any.
|
java.lang.Object |
getDefaultValue()
Returns the default value for the property, or
Property.VoidValue if there is not default value. |
java.lang.String |
getDescription()
Returns a text description of the property.
|
int |
getDimension()
Returns the numeric dimension of this property, or -1 if the property is
not numeric or does not have a fixed dimension.
|
PropertyInfo.Edit |
getEditing()
Returns information describing the conditions under which this property
should be interactively edited.
|
NumberFormat |
getFormat()
Returns the formatter used to convert numeric components of the property's
value into text.
|
java.lang.Class<?> |
getHostClass()
Returns the host class of the property.
|
PropertyMode |
getMode(HasProperties host) |
java.lang.String |
getName()
Returns the name of the property associated with this descriptor.
|
boolean |
getNullValueOK()
Returns true if the property value may be null.
|
java.lang.String |
getPrintFormat()
Returns a format string used to convert numeric components of the
property's value into text.
|
Range |
getRange(HasProperties host) |
static PropertyDesc.TypeCode |
getTypeCode(java.lang.Class<?> cls) |
java.lang.Object |
getValue(HasProperties host) |
java.lang.Class<?> |
getValueClass()
Returns the class type for the property's value.
|
PropertyInfo.ExpandState |
getWidgetExpandState() |
boolean |
hasRestrictedRange()
Returns true if the property has a restricted value range.
|
boolean |
isInheritable()
Returns true if the property is a
inheritable property. |
boolean |
isReadOnly()
Returns true if the property is read-only.
|
boolean |
isSharable()
Returns true if the value of this property is sharable among several
hosts.
|
java.lang.Object |
scanValue(ReaderTokenizer rtok)
Scans a value of the type associated with the property from a
ReaderTokenizer.
|
void |
setAutoWrite(boolean enable) |
void |
setDefaultValue(java.lang.Object value) |
void |
setDescription(java.lang.String text)
Sets a text description for the property.
|
void |
setDimension(int dim) |
void |
setEditing(PropertyInfo.Edit edit) |
void |
setFormat(NumberFormat fmt)
Directly sets the formatter used to convert numeric components of the
property's value into text.
|
void |
setGetMethod(java.lang.String methodName) |
void |
setGetModeMethod(java.lang.String methodName) |
void |
setMode(HasProperties host,
PropertyMode mode) |
void |
setName(java.lang.String name)
Sets the name of the property associated with this descriptor.
|
void |
setNullValueOK(boolean allowed) |
void |
setNumericRange(NumericInterval rng)
Sets a NumericRange for this property.
|
void |
setPrintFormat(java.lang.String fmtStr)
Sets the formatter used to convert numeric components of the property's
value into text.
|
void |
setSetMethod(java.lang.String methodName) |
void |
setSetModeMethod(java.lang.String methodName) |
void |
setValue(HasProperties host,
java.lang.Object value) |
void |
setWidgetExpandState(PropertyInfo.ExpandState state) |
boolean |
valueEqualsDefault(java.lang.Object value)
Returns true if a specified value equals the default value of the
property.
|
boolean |
writeIfNonDefault(HasProperties host,
java.io.PrintWriter pw,
NumberFormat fmt) |
void |
writeValue(java.lang.Object value,
java.io.PrintWriter pw,
NumberFormat fmt)
Writes a value of the type associated with the property out to a
PrintWriter.
|
public static boolean debug
public static final int REGULAR
public static final int READ_ONLY
public static final int INHERITABLE
public PropertyDesc(java.lang.String name,
java.lang.Class<?> hostClass)
name - name of the property.hostClass - host class for the property.public PropertyDesc(java.lang.String name,
java.lang.Class<?> hostClass,
java.lang.Class<?> valueClass)
name - property namehostClass - class object for the host class.valueClass - class object for the value.public PropertyDesc(PropertyDesc prop, java.lang.Class<?> hostClass)
public static PropertyDesc.TypeCode getTypeCode(java.lang.Class<?> cls)
public java.lang.Class<?> getValueClass()
getValueClass in interface PropertyInfopublic java.lang.String getName()
getName in interface PropertyInfopublic void setName(java.lang.String name)
name - new name of the propertypublic java.lang.String getDescription()
getDescription in interface PropertyInfosetDescription(java.lang.String)public void setDescription(java.lang.String text)
text - new text descriptiongetDescription()public java.lang.Class<?> getHostClass()
getHostClass in interface PropertyInfopublic void setPrintFormat(java.lang.String fmtStr)
printf-style
format string. For a description of the format string syntax, see
NumberFormat. The format should be
consistent with the numeric type (e.g., %d or
%x for integers, %g, $f or
%e for floats).fmtStr - numeric format string for the propertyjava.lang.IllegalArgumentException - if the format string syntax is invalidgetFormat()public void setFormat(NumberFormat fmt)
fmt - numeric formatter for the propertygetFormat(),
setPrintFormat(String)public NumberFormat getFormat()
setFormat(NumberFormat),
setPrintFormat(String)public java.lang.String getPrintFormat()
getPrintFormat in interface PropertyInfosetFormat(NumberFormat),
setPrintFormat(String)public boolean getAutoWrite()
PropertyList.writeProps.getAutoWrite in interface PropertyInfopublic void setAutoWrite(boolean enable)
public boolean getNullValueOK()
getNullValueOK in interface PropertyInfopublic void setNullValueOK(boolean allowed)
public PropertyInfo.Edit getEditing()
getEditing in interface PropertyInfopublic void setEditing(PropertyInfo.Edit edit)
public PropertyInfo.ExpandState getWidgetExpandState()
getWidgetExpandState in interface PropertyInfopublic void setWidgetExpandState(PropertyInfo.ExpandState state)
public boolean isReadOnly()
Property.set method. getAutoWrite should return
false for read-only properties, since it makes no sense to try to save
such properties in persistent storage.isReadOnly in interface PropertyInfopublic boolean hasRestrictedRange()
Property.getRange()
method can be used to obtain a Range object to
determine whether or not a particular value is legal.hasRestrictedRange in interface PropertyInfopublic int getDimension()
getDimension in interface PropertyInfopublic void setDimension(int dim)
public boolean isSharable()
PropertyInfoisSharable in interface PropertyInfopublic void setGetMethod(java.lang.String methodName)
public void setSetMethod(java.lang.String methodName)
public void setGetModeMethod(java.lang.String methodName)
public void setSetModeMethod(java.lang.String methodName)
public void setDefaultValue(java.lang.Object value)
public java.lang.Object getDefaultValue()
PropertyInfoProperty.VoidValue if there is not default value.getDefaultValue in interface PropertyInfopublic Property createHandle(HasProperties host)
getHostClass).createHandle in interface PropertyInfopublic java.lang.Object createInstance(HasProperties host) throws java.lang.InstantiationException, java.lang.IllegalAccessException
java.lang.InstantiationExceptionjava.lang.IllegalAccessExceptionpublic java.lang.Object getValue(HasProperties host)
public Range getRange(HasProperties host)
public void setValue(HasProperties host, java.lang.Object value)
public PropertyMode getMode(HasProperties host)
public void setMode(HasProperties host, PropertyMode mode)
public static PropertyDesc create(java.lang.String nameAndMethods, java.lang.Class<?> hostClass, java.lang.String descriptor, java.lang.Object defaultValue, java.lang.String options, int propType)
public boolean valueEqualsDefault(java.lang.Object value)
PropertyInfovalueEqualsDefault in interface PropertyInfovalue - value to check against the defaultpublic NumericInterval getDefaultNumericRange()
If a getRangeMethod is not defined for the property, and
the property has a numeric type, then the default numeric range is
returned by the property's
getRange method. The
default numeric range is also used to determine bounds on slider widgets
for manipulating the property's value, in case the upper or lower limits
returned by the getRange method are unbounded.
getDefaultNumericRange in interface PropertyInfosetNumericRange(maspack.util.NumericInterval)public void setNumericRange(NumericInterval rng)
rng - new numeric range for this property (value is copied).public boolean writeIfNonDefault(HasProperties host, java.io.PrintWriter pw, NumberFormat fmt) throws java.io.IOException
java.io.IOExceptionpublic void writeValue(java.lang.Object value,
java.io.PrintWriter pw,
NumberFormat fmt)
throws java.io.IOException
writeValue in interface PropertyInfovalue - value to be writtenpw - PrintWriter to which value is writtenfmt - Numeric formatting information. This is only used when the value to be
writtem is itself Scannable, in which case
it is passed to that value's write
method.java.io.IOException - if an I/O error occurred, or the value has a type which PropertyInfo does
not know aboutpublic java.lang.Object scanValue(ReaderTokenizer rtok) throws java.io.IOException
scanValue in interface PropertyInfortok - ReaderTokenizer supplying input tokens used to specify the property valuejava.io.IOException - if the input is not in the correct format, an I/O error occurred, or the
value has a type which PropertyInfo does not know aboutpublic boolean isInheritable()
inheritable property.isInheritable in interface PropertyInfopublic PropertyMode getDefaultMode()
getDefaultMode in interface PropertyInfo