|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.millstone.base.data.util.MethodProperty
Proxy class for creating Properties from pairs of getter and setter methods of a Bean property. An instance of this class can be thought as having been attached to a field of an object. Accessing the object through the Property interface directly manipulates the underlying field.
It's assumed that the return value returned by the getter method is assignable to the type of the property, and the setter method parameter is assignable to that value.
A valid getter method must always be available, but instance of this
class can be constructed with a null
setter method in which
case the resulting MethodProperty is read-only.
Nested Class Summary | |
class |
MethodProperty.MethodException
Exception object that signals that there were
problems calling or finding the specified getter or setter methods
of the property. |
Nested classes inherited from class org.millstone.base.data.Property |
Property.ConversionException, Property.Editor, Property.ReadOnlyException, Property.ReadOnlyStatusChangeEvent, Property.ReadOnlyStatusChangeListener, Property.ReadOnlyStatusChangeNotifier, Property.ValueChangeEvent, Property.ValueChangeListener, Property.ValueChangeNotifier, Property.Viewer |
Constructor Summary | |
MethodProperty(java.lang.Class type,
java.lang.Object instance,
java.lang.reflect.Method getMethod,
java.lang.reflect.Method setMethod)
Creates a new instance of MethodProperty with the getter and setter methods. |
|
MethodProperty(java.lang.Class type,
java.lang.Object instance,
java.lang.reflect.Method getMethod,
java.lang.reflect.Method setMethod,
java.lang.Object[] getArgs,
java.lang.Object[] setArgs,
int setArgumentIndex)
Creates a new instance of MethodProperty from the getter and setter methods, and argument lists. |
|
MethodProperty(java.lang.Class type,
java.lang.Object instance,
java.lang.String getMethodName,
java.lang.String setMethodName)
Creates a new instance of MethodProperty from named getter and setter methods. |
|
MethodProperty(java.lang.Class type,
java.lang.Object instance,
java.lang.String getMethodName,
java.lang.String setMethodName,
java.lang.Object[] getArgs,
java.lang.Object[] setArgs,
int setArgumentIndex)
Creates a new instance of MethodProperty from named getter and setter methods and argument lists. |
|
MethodProperty(java.lang.Object instance,
java.lang.String beanPropertyName)
Creates a new instance of MethodProperty from a named bean property. |
Method Summary | |
void |
addListener(Property.ReadOnlyStatusChangeListener listener)
Registers a new read-only status change listener for this Property. |
java.lang.Class |
getType()
Returns the type of the Property. |
java.lang.Object |
getValue()
Gets the value stored in the Property. |
boolean |
isReadOnly()
Tests if the object is in read-only mode. |
void |
removeListener(Property.ReadOnlyStatusChangeListener listener)
Remove a previously registered read-only status change listener. |
void |
setArguments(java.lang.Object[] getArgs,
java.lang.Object[] setArgs,
int setArgumentIndex)
Sets the setter method and getter method argument lists. |
void |
setReadOnly(boolean newStatus)
Sets the Property's read-only mode to the specified status. |
void |
setValue(java.lang.Object newValue)
Set the value of the property. |
java.lang.String |
toString()
Returns the value of the MethodProperty in human readable textual format. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public MethodProperty(java.lang.Object instance, java.lang.String beanPropertyName)
Creates a new instance of MethodProperty from a named bean property. This constructor takes an object and the name of a bean property and initializes itself with the accessor methods for the property. The getter method of a MethodProperty instantiated with this constructor will be called with no arguments, and the setter method with only the new value as the sole argument.
If the setter method is unavailable, the resulting MethodProperty will be read-only, otherwise it will be read-write.
Method names are constucted from the bean property by adding get/is/are/set prefix and capitalising the first character in the name of the given bean property
instance
- object that includes the propertybeanPropertyName
- name of the property to bind topublic MethodProperty(java.lang.Class type, java.lang.Object instance, java.lang.String getMethodName, java.lang.String setMethodName)
Creates a new instance of MethodProperty from named getter and setter methods. The getter method of a MethodProperty instantiated with this constructor will be called with no arguments, and the setter method with only the new value as the sole argument.
If the setter method is null
, the resulting
MethodProperty will be read-only, otherwise it will be
read-write.
type
- type of the propertyinstance
- object that includes the propertygetMethodName
- name of the getter methodsetMethodName
- name of the setter methodpublic MethodProperty(java.lang.Class type, java.lang.Object instance, java.lang.reflect.Method getMethod, java.lang.reflect.Method setMethod)
Creates a new instance of MethodProperty with the getter and setter methods. The getter method of a MethodProperty instantiated with this constructor will be called with no arguments, and the setter method with only the new value as the sole argument.
If the setter method is null
, the resulting
MethodProperty will be read-only, otherwise it will be
read-write.
type
- type of the propertyinstance
- object that includes the propertygetMethod
- the getter methodsetMethod
- the setter methodpublic MethodProperty(java.lang.Class type, java.lang.Object instance, java.lang.String getMethodName, java.lang.String setMethodName, java.lang.Object[] getArgs, java.lang.Object[] setArgs, int setArgumentIndex)
Creates a new instance of MethodProperty from named getter and
setter methods and argument lists. The getter method of a
MethodProperty instantiated with this constructor will be called with
getArgs
as arguments. setArgs
will be used
as the arguments for the setter method, though the argument indexed
by setArgumentIndex
will be replaced with the argument
passed to the setValue(Object newValue)
method.
For example, if the setArgs
contains A
,
B
and C
, and setArgumentIndex =
1
, the call methodProperty.setValue(X)
would
result in the setter method to be called with the parameter set of
{A, X, C}
type
- type of the propertyinstance
- object that includes the propertygetMethodName
- the name of the getter methodsetMethodName
- the name of the setter methodgetArgs
- fixed argument list to be passed to the getter methodsetArgs
- fixed argument list to be passed to the setter methodsetArgumentIndex
- the index of the argument in
setArgs
to be replaced with newValue
when
setValue(Object newValue)
is calledpublic MethodProperty(java.lang.Class type, java.lang.Object instance, java.lang.reflect.Method getMethod, java.lang.reflect.Method setMethod, java.lang.Object[] getArgs, java.lang.Object[] setArgs, int setArgumentIndex)
Creates a new instance of MethodProperty from the getter and
setter methods, and argument lists. This constructor behaves exctly
like MethodProperty(Class type, Object instance, String
getMethodName, String setMethodName, Object [] getArgs, Object []
setArgs, int setArgumentIndex)
except that instead of names of
the getter and setter methods this constructor is given the actual
methods themselves.
type
- type of the propertyinstance
- object that includes the propertygetMethod
- the getter methodsetMethod
- the setter methodgetArgs
- fixed argument list to be passed to the getter methodsetArgs
- fixed argument list to be passed to the setter methodsetArgumentIndex
- the index of the argument in
setArgs
to be replaced with newValue
when
setValue(Object newValue)
is calledMethod Detail |
public final java.lang.Class getType()
getValue
and setValue
must be compatible with this type: one
must be able to safely cast the value returned from
getValue
to the given type and pass any variable
assignable to this type as an argument to setValue
.
getType
in interface Property
public boolean isReadOnly()
setValue
will throw ReadOnlyException
s
and will not modify the value of the Property.
isReadOnly
in interface Property
true
if the object is in read-only mode,
false
if it's notpublic java.lang.Object getValue()
getValue
in interface Property
public java.lang.String toString()
setValue
method if the Property is not in read-only
mode.
toString
in interface Property
toString
in class java.lang.Object
public void setArguments(java.lang.Object[] getArgs, java.lang.Object[] setArgs, int setArgumentIndex)
Sets the setter method and getter method argument lists.
getArgs
- fixed argument list to be passed to the getter methodsetArgs
- fixed argument list to be passed to the setter methodsetArgumentIndex
- the index of the argument in
setArgs
to be replaced with newValue
when
setValue(Object newValue)
is calledpublic void setValue(java.lang.Object newValue) throws Property.ReadOnlyException, Property.ConversionException
String
s if either String
is directly
assignable to property type, or the type class contains a string
constructor.
setValue
in interface Property
newValue
- New value of the property.
Property.ReadOnlyException
- if the object is in
read-only mode
Property.ConversionException
- if
newValue
can't be converted into the Property's native
type directly or through String
Property.ConversionException
- if newValue
can't
be converted into the Property's native type directly or through
String
Property.ReadOnlyException
- if the object is in read-only
modepublic void setReadOnly(boolean newStatus)
setReadOnly
in interface Property
newStatus
- new read-only status of the Propertypublic void addListener(Property.ReadOnlyStatusChangeListener listener)
listener
- the new Listener to be registeredpublic void removeListener(Property.ReadOnlyStatusChangeListener listener)
listener
- listener to be removed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |