public class PropertyList extends java.lang.Object implements PropertyInfoList
Constructor and Description |
---|
PropertyList(java.lang.Class<?> hostClass)
Creates an empty property list for a specified exporting host class.
|
PropertyList(java.lang.Class<?> hostClass,
java.lang.Class<?> superClass)
Creates a property list for a specified exporting host class.
|
Modifier and Type | Method and Description |
---|---|
void |
add(PropertyDesc desc)
Adds a new property to this list.
|
PropertyDesc |
add(java.lang.String nameAndMethods,
java.lang.String description,
java.lang.Object defaultValue)
Adds a new property to this list, creating the appropriate description
from the supplied arguments.
|
PropertyDesc |
add(java.lang.String nameAndMethods,
java.lang.String description,
java.lang.Object defaultValue,
java.lang.String options)
Adds a new property to this list, creating the appropriate description
from the supplied arguments.
|
PropertyDesc |
addInheritable(java.lang.String nameAndMethods,
java.lang.String description,
java.lang.Object defaultValue)
Adds a new inheritable property to this list, creating the appropriate
description from the supplied arguments.
|
PropertyDesc |
addInheritable(java.lang.String nameAndMethods,
java.lang.String description,
java.lang.Object defaultValue,
java.lang.String options)
Adds a new inheritable property to this list, creating the appropriate
description from the supplied arguments.
|
PropertyDesc |
addReadOnly(java.lang.String nameAndMethods,
java.lang.String description)
Adds a new read-only property to this list, creating the appropriate
description from the supplied arguments.
|
PropertyDesc |
addReadOnly(java.lang.String nameAndMethods,
java.lang.String description,
java.lang.String options)
Adds a new read-only property to this list, creating the appropriate
description from the supplied arguments.
|
static PropertyInfoList |
findPropertyInfoList(java.lang.Class<?> hostClass) |
PropertyDesc |
get(int idx)
Gets a descriptor for a specific property by index, where index describes
the numeric location of the property within this list.
|
PropertyDesc |
get(java.lang.String name)
Gets a descriptor for a specific named propertreturn myProps;y.
|
static Property |
getProperty(java.lang.String pathName,
HasProperties host)
Recursively locates a property within this list and creates a handle for
it.
|
boolean |
hasNoInheritableProperties()
Returns tree if any properties in this list are inheritable.
|
java.util.Iterator<PropertyInfo> |
iterator()
Returns an iterator over all PropertyInfo structures contained in this
list.
|
boolean |
remove(PropertyDesc desc)
Removes a specific property from this list.
|
boolean |
remove(java.lang.String name)
Removes a specific named property from this list.
|
void |
scanNamedProp(HasProperties host,
java.lang.String name,
ReaderTokenizer rtok) |
boolean |
scanProp(HasProperties host,
ReaderTokenizer rtok)
Scans a property from a ReaderTokenizer.
|
void |
setDefaultModes(HasProperties host) |
void |
setDefaultValue(java.lang.String name,
java.lang.Object value) |
void |
setDefaultValues(HasProperties host) |
void |
setDefaultValuesAndModes(HasProperties host) |
void |
setOptions(java.lang.String name,
java.lang.String optionStr)
Sets options for a specifed property within this list.
|
int |
size()
Returns the number of properties described in this list.
|
PropertyDesc[] |
toArray()
Returns an array of all the PropertyDesc objects in this list.
|
boolean |
writeNonDefaultProps(HasProperties host,
java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes properties in this list whose current values differ from their
default values to a PrintWriter.
|
boolean |
writeNonDefaultProps(HasProperties host,
java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref,
java.lang.String[] exclude)
Identical to
writeNonDefaultProps(host,pw,fmt,obj)
but also takes an optional array of property names which are
to be excluded. |
void |
writeProps(HasProperties host,
java.io.PrintWriter pw,
NumberFormat fmt,
java.lang.Object ref)
Writes properties in this list to a PrintWriter.
|
public PropertyList(java.lang.Class<?> hostClass)
hostClass
- class exporting the propertiespublic PropertyList(java.lang.Class<?> hostClass, java.lang.Class<?> superClass)
hostClass
- class exporting the propertiessuperClass
- ancestor class containing properties to copypublic static PropertyInfoList findPropertyInfoList(java.lang.Class<?> hostClass)
public void add(PropertyDesc desc)
desc
- descriptor for the property to be exportedpublic PropertyDesc add(java.lang.String nameAndMethods, java.lang.String description, java.lang.Object defaultValue, java.lang.String options)
nameAndMethods
- a string giving the name of the property, optionally followed by the names
of host class get and set methods which should be used to get and set the
property's value. The property and method names should be separated by
whitespace. If the method names are absent, or are specified using the
character `*
`, then the default method names
get
Prop or set
Prop will be
used, as appropriate, where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.defaultValue
- a default value for the property. Generally, this should be the value
assigned to the property when the class is initialized.options
- a string setting various property options, having the same format as that
used by setOptions
.public PropertyDesc add(java.lang.String nameAndMethods, java.lang.String description, java.lang.Object defaultValue)
nameAndMethods
- a string giving the name of the property, optionally followed by the names
of host class get and set methods which should be used to get and set the
property's value. The property and method names should be separated by
whitespace. If the method names are absent, or are specified using the
character `*
`, then the default method names
get
Prop or set
Prop will be
used, as appropriate, where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.defaultValue
- a default value for the property. Generally, this should be the value
assigned to the property when the class is initialized.public void setOptions(java.lang.String name, java.lang.String optionStr)
NE
, NeverEdit
Disables interactive editing.
This will cause PropertyInfo.getEditing
to return
Edit.Never
.
AE
, AlwaysEdit
Enables interactive editing.
This will cause PropertyInfo.getEditing
to return
Edit.Always
.
1E
, SingleEdit
Enables interactive editing
for one property host at a time. This will cause
PropertyInfo.getEditing
to return Edit.Single
.
NW
, NoAutoWrite
Disable auto-write. This
will cause PropertyInfo.getAutoWrite
to return false.
AW
, AutoWrite
Enables auto-write. This will
cause PropertyInfo.getAutoWrite
to return true, if the property is not
read-only.
SH
, Sharable
Indicates that the property
value can be shared among several hosts.
[l,u]
Sets a numeric range with a lower bound of
l
and an upper bound of u
. The numeric
range is returned by
PropertyInfo.getDefaultNumericRange
.
fmt
Sets a print format, using a printf-style format string
beginning with '%
'. The print format is returned by
PropertyInfo.getPrintFormat
and is used for printing numeric property
values.
name
- name of the property for which options are to be setoptionStr
- option string, conforming to the format described abovejava.lang.IllegalArgumentException
- if the specified property is not found, or if one of the tokens in the
option string is not recognized.public void setDefaultValue(java.lang.String name, java.lang.Object value)
public PropertyDesc addInheritable(java.lang.String nameAndMethods, java.lang.String description, java.lang.Object defaultValue, java.lang.String options)
nameAndMethods
- a string giving the name of the property, optionally followed by the names
of host class get and set methods for both the propertie's value and its
mode. The property and method names should be separated by whitespace. If
the method names are absent, or are specified using the character `*
`,
then the default method names get
Prop,
set
Prop, get
PropMode
,
and set
PropMode
will be used, as
appropriate, where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.defaultValue
- a default value for the property. Generally, this should be the value
assigned to the property when the class is initialized.options
- a string setting various property options, having the same format as that
used by setOptions
.public PropertyDesc addInheritable(java.lang.String nameAndMethods, java.lang.String description, java.lang.Object defaultValue)
nameAndMethods
- a string giving the name of the property, optionally followed by the names
of host class get and set methods for both the propertie's value and its
mode. The property and method names should be separated by whitespace. If
the method names are absent, or are specified using the character `*
`,
then the default method names get
Prop,
set
Prop, get
PropMode
,
and set
PropMode
will be used, as
appropriate, where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.defaultValue
- a default value for the property. Generally, this should be the value
assigned to the property when the class is initialized.public PropertyDesc addReadOnly(java.lang.String nameAndMethods, java.lang.String description, java.lang.String options)
nameAndMethods
- a string giving the name of the property, optionally followed by the name
of the host class get method which should be used to get the property's
value. The property and method names should be separated by whitespace. If
the method names are absent, or are specified using the character `*
`,
then the default method name get
Prop will be used,
where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.options
- a string setting various property options, having the same format as that
used by setOptions
.public PropertyDesc addReadOnly(java.lang.String nameAndMethods, java.lang.String description)
nameAndMethods
- a string giving the name of the property, optionally followed by the name
of the host class get method which should be used to get the property's
value. The property and method names should be separated by whitespace. If
the method names are absent, or are specified using the character `*
`,
then the default method name get
Prop will be used,
where Prop is the capitalized property name.description
- a textual description of the property, for use in constructing
documentation or GUI tool-tips, etc.public boolean remove(PropertyDesc desc)
desc
- descriptor of the property to removepublic boolean remove(java.lang.String name)
name
- name of the property to removepublic PropertyDesc get(java.lang.String name)
null
is returned.get
in interface PropertyInfoList
name
- name of the propertypublic PropertyDesc get(int idx)
idx
- index of the property within this listjava.lang.ArrayIndexOutOfBoundsException
- if index is not in the range [0, size()
-1].public static Property getProperty(java.lang.String pathName, HasProperties host)
HasProperties.getProperty
.pathName
- property namehost
- host object exporting the propertypublic java.util.Iterator<PropertyInfo> iterator()
iterator
in interface java.lang.Iterable<PropertyInfo>
iterator
in interface PropertyInfoList
public PropertyDesc[] toArray()
public void writeProps(HasProperties host, java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
PropertyInfo.getAutoWrite
returns true are written. Properties are
written in the format
<propertyName> = <value>i.e., the property name, followed by an
=
sign, followed by
the property's current value.host
- class exporting the propertiespw
- PrintWriter to which properties are 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.ref
- Reference object. 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 writing to the streampublic boolean writeNonDefaultProps(HasProperties host, java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref) throws java.io.IOException
writeProps
; in particular only those
properties for which PropertyInfo.getAutoWrite
returns true are written.writeNonDefaultProps
in interface PropertyInfoList
host
- class exporting the propertiespw
- PrintWriter to which properties are writtenfmt
- Numeric formatting information. This is only used when the value to be
written is itself Scannable
, in which case
it is passed to that value's write
method.ref
- Reference object. This is only used when the value to be
written is itself Scannable
, in which case
it is passed to that value's write
method.java.io.IOException
- if an I/O error occurred writing to the streampublic boolean writeNonDefaultProps(HasProperties host, java.io.PrintWriter pw, NumberFormat fmt, java.lang.Object ref, java.lang.String[] exclude) throws java.io.IOException
writeNonDefaultProps(host,pw,fmt,obj)
but also takes an optional array of property names which are
to be excluded.host
- class exporting the propertiespw
- PrintWriter to which properties are writtenfmt
- Numeric formatting information. This is only used when the value to be
written is itself Scannable
, in which case
it is passed to that value's write
method.ref
- Reference object. This is only used when the value to be
written is itself Scannable
, in which case
it is passed to that value's write
method.exclude
- optional array of property names which are to be excluded.java.io.IOException
- if an I/O error occurred writing to the streampublic void setDefaultModes(HasProperties host)
public void setDefaultValues(HasProperties host)
public void setDefaultValuesAndModes(HasProperties host)
public boolean scanProp(HasProperties host, ReaderTokenizer rtok) throws java.io.IOException
<propertyName> = <value>i.e., the property name, followed by an
=
sign, followed by
the property's value.
If the first token read is not a word, or if it does not correspond to the
name of a known property on this list, then the token is pushed back and
this routine returns false. Otherwise, the remaining input is expected to
consist of an =
equal sign followed by whatever input is
required to specify the property, and an exception is thrown if this is
not the case.
host
- Object exporting the propertyrtok
- Tokenizer stream from which the property is readjava.io.IOException
- if an I/O error occurred or if the input does not conform to the required
format.public void scanNamedProp(HasProperties host, java.lang.String name, ReaderTokenizer rtok) throws java.io.IOException
java.io.IOException
public int size()
size
in interface PropertyInfoList
public boolean hasNoInheritableProperties()
hasNoInheritableProperties
in interface PropertyInfoList