Top Description Inners Fields Constructors Methods
com.sun.javafx.fxml

public Class BeanAdapter

extends AbstractMap<String, Object>
Class Inheritance
Imports
java.lang.reflect.InvocationTargetException, .Method, .Modifier, .ParameterizedType, .Type, .TypeVariable, java.lang.reflect.*, java.math.BigDecimal, .BigInteger, java.util.*, javafx.beans.value.ObservableValue, com.sun.javafx.reflect.FieldUtil, .MethodUtil, .ReflectUtil

Exposes Java Bean properties of an object via the Map interface. A call to Map#get(Object) invokes the getter for the corresponding property, and a call to Map#put(Object, Object) invokes the property's setter. Appending a "Property" suffix to the key returns the corresponding property model.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class

Field Summary

Modifier and TypeField and Description
private final Object
public static final String
private static final HashMap<Class<?>, BeanAdapter.MethodCache>
public static final String
private final BeanAdapter.MethodCache
public static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public
BeanAdapter(Object
The Bean object to wrap.
bean
)

Creates a new Bean adapter.

Method Summary

Modifier and TypeMethod and Description
public static <T> T

Returns:

The coerced value.
coerce
(Object value, Class<? extends T> type)

Coerces a value to a given type.

public boolean

Returns:

true if the property exists; false, otherwise.
containsKey
(Object
The property name.
key
)

Overrides java.util.AbstractMap.containsKey.

Implements java.util.Map.containsKey.

Verifies the existence of a property.

public Set<Map.Entry<String, Object>>
entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map.

public boolean
equals(Object
object to be compared for equality with this map
object
)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Compares the specified object with this map for equality.

public Object

Returns:

The value returned by the method, or null if no such method exists.
get
(Object
The property name.
key
)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Invokes the getter method for the given property.

private Object
get(String key)

public static <T> T

Returns:

The value returned by the method, or null if no such method exists.
get
(Object
The object to which the property is attached.
target
,
Class<?>
The class that defines the property.
sourceType
,
String
The property name.
key
)

Invokes the static getter method for the given property.

public Object

Returns:

The Bean object, or null if no Bean has been set.
getBean
()

Returns the Bean object this adapter wraps.

private static BeanAdapter.MethodCache
getClassMethodCache(final Class<?> type)

public static Object
getConstantValue(Class<?>
The type that defines the constant.
type
,
String
The name of the constant.
name
)

Returns the value of a named constant.

public static Type
getGenericListItemType(Type listType)

Determines the type of a list item.

public static Type
getGenericMapValueType(Type mapType)

Determines the type of a map value.

public Type
getGenericType(String
The property name.
key
)

Returns the generic type of a property.

public static Type
getGenericType(Class<?>
The class that defines the property.
sourceType
,
String
The property name.
key
,
Class<?>
The type of the object to which the property applies.
targetType
)

Returns the generic type of a static property.

private Method
public static Class<?>
getListItemType(Type listType)

Determines the type of a list item.

public static Class<?>
getMapValueType(Type mapType)

Determines the type of a map value.

private static String
public <T> ObservableValue<T>

Returns:

The named property model, or null if no such property exists.
getPropertyModel
(String
The property name.
key
)

Returns the property model for the given property.

private Method
private static Method
getStaticGetterMethod(Class<?> sourceType, String key, Class<?> targetType)

private static Method
getStaticSetterMethod(Class<?> sourceType, String key, Class<?> valueType, Class<?> targetType)

public Class<?>
getType(String
The property name.
key
)

Returns the type of a property.

public static Class<?>
getType(Class<?>
The class that defines the property.
sourceType
,
String
The property name.
key
,
Class<?>
The type of the object to which the property applies.
targetType
)

Returns the type of a static property.

public int
hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Returns the hash code value for this map.

public static boolean

Returns:

true if the property exists; false, otherwise.
isDefined
(Class<?>
The class that defines the property.
sourceType
,
String
The property name.
key
,
Class<?>
The type of the object to which the property applies.
targetType
)

Tests the existence of a static property.

public boolean

Returns:

true if the property is read-only; false, otherwise.
isReadOnly
(String
The property name.
key
)

Tests the mutability of a property.

public Object

Returns:

Returns null, since returning the previous value would require an unnecessary call to the getter method.
put
(String
The property name.
key
,
Object
The new property value.
value
)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Invokes a setter method for the given property.

public static void
put(Object
The object to which the property is or will be attached.
target
,
Class<?>
The class that defines the property.
sourceType
,
String
The property name.
key
,
Object
The new property value.
value
)

Invokes a static setter method for the given property.

private static String
Inherited from java.util.AbstractMap:
clearclonecontainsValueisEmptykeySetputAllremovesizetoStringvalues

Field Detail

beanback to summary
private final Object bean
GET_PREFIXback to summary
public static final String GET_PREFIX
globalMethodCacheback to summary
private static final HashMap<Class<?>, BeanAdapter.MethodCache> globalMethodCache
IS_PREFIXback to summary
public static final String IS_PREFIX
localCacheback to summary
private final BeanAdapter.MethodCache localCache
PROPERTY_SUFFIXback to summary
public static final String PROPERTY_SUFFIX
SET_PREFIXback to summary
public static final String SET_PREFIX
VALUE_OF_METHOD_NAMEback to summary
public static final String VALUE_OF_METHOD_NAME

Constructor Detail

BeanAdapterback to summary
public BeanAdapter(Object bean)

Creates a new Bean adapter.

Parameters
bean:Object

The Bean object to wrap.

Method Detail

coerceback to summary
public static <T> T coerce(Object value, Class<? extends T> type)

Coerces a value to a given type.

Returns:T

The coerced value.

Annotations
@SuppressWarnings:unchecked
containsKeyback to summary
public boolean containsKey(Object key)

Overrides java.util.AbstractMap.containsKey.

Implements java.util.Map.containsKey.

Verifies the existence of a property.

Parameters
key:Object

The property name.

Returns:boolean

true if the property exists; false, otherwise.

Annotations
@Override
entrySetback to summary
public Set<Map.Entry<String, Object>> entrySet()

Implements abstract java.util.AbstractMap.entrySet.

Implements java.util.Map.entrySet.

Doc from java.util.Map.entrySet.

Returns a Set view of the mappings contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. If the map is modified while an iteration over the set is in progress (except through the iterator's own remove operation, or through the setValue operation on a map entry returned by the iterator) the results of the iteration are undefined. The set supports element removal, which removes the corresponding mapping from the map, via the Iterator.remove, Set.remove, removeAll, retainAll and clear operations. It does not support the add or addAll operations.

Returns:Set<Map.Entry<String, Object>>

a set view of the mappings contained in this map

Annotations
@Override
equalsback to summary
public boolean equals(Object object)

Overrides java.util.AbstractMap.equals.

Implements java.util.Map.equals.

Doc from java.util.AbstractMap.equals.

Compares the specified object with this map for equality. Returns true if the given object is also a map and the two maps represent the same mappings. More formally, two maps m1 and m2 represent the same mappings if m1.entrySet().equals(m2.entrySet()). This ensures that the equals method works properly across different implementations of the Map interface.

Parameters
object:Object

object to be compared for equality with this map

Returns:boolean

true if the specified object is equal to this map

Annotations
@Override
getback to summary
public Object get(Object key)

Overrides java.util.AbstractMap.get.

Implements java.util.Map.get.

Invokes the getter method for the given property.

Parameters
key:Object

The property name.

Returns:Object

The value returned by the method, or null if no such method exists.

Annotations
@Override
getback to summary
private Object get(String key)
getback to summary
public static <T> T get(Object target, Class<?> sourceType, String key)

Invokes the static getter method for the given property.

Parameters
target:Object

The object to which the property is attached.

sourceType:Class<?>

The class that defines the property.

key:String

The property name.

Returns:T

The value returned by the method, or null if no such method exists.

Annotations
@SuppressWarnings:unchecked
getBeanback to summary
public Object getBean()

Returns the Bean object this adapter wraps.

Returns:Object

The Bean object, or null if no Bean has been set.

getClassMethodCacheback to summary
private static BeanAdapter.MethodCache getClassMethodCache(final Class<?> type)
getConstantValueback to summary
public static Object getConstantValue(Class<?> type, String name)

Returns the value of a named constant.

Parameters
type:Class<?>

The type that defines the constant.

name:String

The name of the constant.

getGenericListItemTypeback to summary
public static Type getGenericListItemType(Type listType)

Determines the type of a list item.

getGenericMapValueTypeback to summary
public static Type getGenericMapValueType(Type mapType)

Determines the type of a map value.

getGenericTypeback to summary
public Type getGenericType(String key)

Returns the generic type of a property.

Parameters
key:String

The property name.

getGenericTypeback to summary
public static Type getGenericType(Class<?> sourceType, String key, Class<?> targetType)

Returns the generic type of a static property.

Parameters
sourceType:Class<?>

The class that defines the property.

key:String

The property name.

targetType:Class<?>

The type of the object to which the property applies.

getGetterMethodback to summary
private Method getGetterMethod(String key)
getListItemTypeback to summary
public static Class<?> getListItemType(Type listType)

Determines the type of a list item.

getMapValueTypeback to summary
public static Class<?> getMapValueType(Type mapType)

Determines the type of a map value.

getMethodNameback to summary
private static String getMethodName(String prefix, String key)
getPropertyModelback to summary
public <T> ObservableValue<T> getPropertyModel(String key)

Returns the property model for the given property.

Parameters
key:String

The property name.

Returns:ObservableValue<T>

The named property model, or null if no such property exists.

Annotations
@SuppressWarnings:unchecked
getSetterMethodback to summary
private Method getSetterMethod(String key)
getStaticGetterMethodback to summary
private static Method getStaticGetterMethod(Class<?> sourceType, String key, Class<?> targetType)
getStaticSetterMethodback to summary
private static Method getStaticSetterMethod(Class<?> sourceType, String key, Class<?> valueType, Class<?> targetType)
getTypeback to summary
public Class<?> getType(String key)

Returns the type of a property.

Parameters
key:String

The property name.

getTypeback to summary
public static Class<?> getType(Class<?> sourceType, String key, Class<?> targetType)

Returns the type of a static property.

Parameters
sourceType:Class<?>

The class that defines the property.

key:String

The property name.

targetType:Class<?>

The type of the object to which the property applies.

hashCodeback to summary
public int hashCode()

Overrides java.util.AbstractMap.hashCode.

Implements java.util.Map.hashCode.

Doc from java.util.AbstractMap.hashCode.

Returns the hash code value for this map. The hash code of a map is defined to be the sum of the hash codes of each entry in the map's entrySet() view. This ensures that m1.equals(m2) implies that m1.hashCode()==m2.hashCode() for any two maps m1 and m2, as required by the general contract of Object#hashCode.

Returns:int

the hash code value for this map

Annotations
@Override
isDefinedback to summary
public static boolean isDefined(Class<?> sourceType, String key, Class<?> targetType)

Tests the existence of a static property.

Parameters
sourceType:Class<?>

The class that defines the property.

key:String

The property name.

targetType:Class<?>

The type of the object to which the property applies.

Returns:boolean

true if the property exists; false, otherwise.

isReadOnlyback to summary
public boolean isReadOnly(String key)

Tests the mutability of a property.

Parameters
key:String

The property name.

Returns:boolean

true if the property is read-only; false, otherwise.

putback to summary
public Object put(String key, Object value)

Overrides java.util.AbstractMap.put.

Implements java.util.Map.put.

Invokes a setter method for the given property. The coerce(Object, Class) method is used as needed to attempt to convert a given value to the property type, as defined by the return value of the getter method.

Parameters
key:String

The property name.

value:Object

The new property value.

Returns:Object

Returns null, since returning the previous value would require an unnecessary call to the getter method.

Annotations
@Override
Exceptions
PropertyNotFoundException:
If the given property does not exist or is read-only.
putback to summary
public static void put(Object target, Class<?> sourceType, String key, Object value)

Invokes a static setter method for the given property. If the value is null or there is no explicit setter for a given type, the coerce(Object, Class) method is used to attempt to convert the value to the actual property type (defined by the return value of the getter method).

Parameters
target:Object

The object to which the property is or will be attached.

sourceType:Class<?>

The class that defines the property.

key:String

The property name.

value:Object

The new property value.

Exceptions
PropertyNotFoundException:
If the given static property does not exist or is read-only.
toAllCapsback to summary
private static String toAllCaps(String value)
com.sun.javafx.fxml back to summary

private Class BeanAdapter.MethodCache

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Map<String, List<Method>>
private final BeanAdapter.MethodCache

Constructor Summary

AccessConstructor and Description
private
MethodCache(Map<String, List<Method>> methods, BeanAdapter.MethodCache nextClassCache)

Method Summary

Modifier and TypeMethod and Description
private Method
getMethod(String name, Class<?>... parameterTypes)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

methodsback to summary
private final Map<String, List<Method>> methods
nextClassCacheback to summary
private final BeanAdapter.MethodCache nextClassCache

Constructor Detail

MethodCacheback to summary
private MethodCache(Map<String, List<Method>> methods, BeanAdapter.MethodCache nextClassCache)

Method Detail

getMethodback to summary
private Method getMethod(String name, Class<?>... parameterTypes)