|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.openpermis.editor.policy.beans.BeanUtilities
final class BeanUtilities
Utility functions around Java Beans.
Field Summary | |
---|---|
private static String |
ADD
Method name of 'addPropertyChangeListener' support method. |
private static int[] |
ARG_COUNT
An array of allowed number of arguments in a property change method. |
private static int |
ARG_NEW_VALUE
The new value argument position in a property change method. |
private static int |
ARG_OLD_VALUE
The old value argument position in a property change method. |
private static int |
ARG_PROPERTY
The property argument position in a property change method. |
private static int |
ARG_SOURCE
The source argument position in a property change method. |
private static String |
GET_PREFIX
Prefix of Java Beans getter methods. |
private static String |
IS_PREFIX
Alternative prefix of Java Beans boolean getter methods. |
private static String |
REMOVE
Method name of 'removePropertyChangeListener' support method. |
private static String |
SET_PREFIX
Prefix of Java Beans setter methods. |
Constructor Summary | |
---|---|
private |
BeanUtilities()
Objects of this class cannot be instantiated. |
Method Summary | ||
---|---|---|
static
|
addPropertyChangeListener(T bean,
PropertyChangeListener listener)
Registers the specified property change listener at the given bean. |
|
static Map<String,Method> |
getPropertyChangeMethods(Class<?> beanClass,
Class<?> targetClass)
Builds a map of methods with a PropertyChange annotation. |
|
static Method |
getter(Class<?> beanClass,
String property)
Finds the method for the getter of the specified property. |
|
(package private) static String |
getterName(String property,
boolean booleanValue)
Returns the method name of the getter for the specified property. |
|
static boolean |
isJavaBean(Class<?> cls)
Tests if the specified class provides Java Beans support. |
|
static boolean |
isJavaBean(Object object)
Tests if the specified object is a Java Bean. |
|
static Method |
method(Class<?> cls,
String methodName,
Class<?> parameterClass)
Returns the method with the specified name and parameter class in the given class. |
|
private static String |
methodName(String prefix,
String property)
Composes a method name given the specified prefix and property name. |
|
static
|
removePropertyChangeListener(T bean,
PropertyChangeListener listener)
Deregisters the specified property change listener from the given bean. |
|
static Method |
setter(Class<?> beanClass,
String property)
Finds the method for the setter of the specified property. |
|
(package private) static String |
setterName(String property)
Returns the method name of the setter for the specified property. |
|
(package private) static String |
signature(Object beanOrClass,
String methodName,
Class<?> parameterClass)
Returns the signature of the specified method. |
|
(package private) static void |
validate(Method method,
PropertyChange pc)
Validates the property change object and throws illegal state exceptions if it is not valid. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final String ADD
"addPropertyChangeListener"
private static final String REMOVE
"removePropertyChangeListener"
private static final String SET_PREFIX
"set"
private static final String GET_PREFIX
"get"
private static final String IS_PREFIX
"is"
private static final int[] ARG_COUNT
private static final int ARG_SOURCE
0
private static final int ARG_PROPERTY
1
private static final int ARG_OLD_VALUE
2
private static final int ARG_NEW_VALUE
3
Constructor Detail |
---|
private BeanUtilities()
Method Detail |
---|
private static final String methodName(String prefix, String property)
prefix
- the prefix to use.property
- the name of the property, must not be null
or empty.
static final String getterName(String property, boolean booleanValue)
property
- the name of the property, must not be null
or empty.booleanValue
- indicates if the property is a boolean value.
static final String setterName(String property)
property
- the name of the property, must not be null
or empty.
static String signature(Object beanOrClass, String methodName, Class<?> parameterClass)
Returns the name of the method including its parameter type if non-null
.
beanOrClass
- the bean or the bean class for which to create the signature.methodName
- the name of the method.parameterClass
- the parameter type or null
if the method has no parameters.
public static Method method(Class<?> cls, String methodName, Class<?> parameterClass)
cls
- the class for which to retrieve the method, must not be null
.methodName
- the name of the method, must not be null
or empty.parameterClass
- the type of the parameter, may be null
for methods without
any parameters.
null
if the method does not exist.public static Method getter(Class<?> beanClass, String property)
beanClass
- the Java bean class to search for the getter, must not be null
.property
- the name of the property, must not be null
or empty.
null
if there is no such getter.public static Method setter(Class<?> beanClass, String property)
beanClass
- the Java bean class to search for the setter, must not be null
.property
- the name of the property, must not be null
or empty.
null
if there is no such setter.public static boolean isJavaBean(Class<?> cls)
cls
- the class to test, may be null
.
true
if the class provides Java Beans support.public static boolean isJavaBean(Object object)
object
- the object to test, may be null
.
true
if the object is a Java Bean.static void validate(Method method, PropertyChange pc)
method
- the method to validate the object for, must not be null
(not checked).pc
- the property change object to validate, must not be null
(not checked).
IllegalStateException
- if the property change object is invalid.public static Map<String,Method> getPropertyChangeMethods(Class<?> beanClass, Class<?> targetClass)
PropertyChange
annotation.
beanClass
- the bean class for which to build the map, must not be null
.targetClass
- the class for which to build the map, must not be null
.
public static <T> T addPropertyChangeListener(T bean, PropertyChangeListener listener)
bean
- the bean to add the property change listener to, must not be null
.listener
- the listener to add, must not be null
.
IllegalArgumentException
- if the object passed in is not a Java Bean.
IllegalStateException
- if there is an error registering.public static <T> T removePropertyChangeListener(T bean, PropertyChangeListener listener)
bean
- the bean to remove the listener from, must not be null
.listener
- the listener to remove, must not be null
.
IllegalArgumentException
- if the object passed in is not a Java Bean.
IllegalStateException
- if there is an error deregistering.
|
![]() |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
PERMIS Role Based Access Control 0.3.0 (Build 14)
2009/05/08 09:06:48
Copyright (c) 2002-2007 Ergon Informatik AG