|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.morph.reflect.reflectors.BaseReflector net.sf.morph.reflect.reflectors.BaseBeanReflector net.sf.morph.reflect.reflectors.ObjectReflector
public class ObjectReflector
A Reflector that exposes the properties of any Object as they are defined by the JavaBeans specification. Also exposes any Object as a container.
When an object is exposed as a container, the getContainer
method returns an iterator that just iterates over the one reflected object.
The getType
method returns the type as specified by the
property's setter method, if one is available. If no mutator is available, the
getType
method returns the type as specified by the property's
getter method.
Field Summary |
---|
Fields inherited from class net.sf.morph.reflect.reflectors.BaseReflector |
---|
log |
Fields inherited from interface net.sf.morph.reflect.BeanReflector |
---|
IMPLICIT_PROPERTY_CLASS, IMPLICIT_PROPERTY_PROPERTY_NAMES, IMPLICIT_PROPERTY_THIS |
Fields inherited from interface net.sf.morph.reflect.SizableReflector |
---|
IMPLICIT_PROPERTY_SIZE |
Constructor Summary | |
---|---|
ObjectReflector()
|
Method Summary | |
---|---|
protected java.lang.Class |
getContainedTypeImpl(java.lang.Class clazz)
Implementation of ContainerReflector.getContainedType(Class) . |
protected java.lang.Object |
getImpl(java.lang.Object bean,
java.lang.String propertyName)
Retrieves the value of the property propertyName in bean
bean . |
protected java.util.Iterator |
getIteratorImpl(java.lang.Object container)
Implementation of ContainerReflector.getIterator(Object) . |
protected java.lang.String[] |
getPropertyNamesImpl(java.lang.Object bean)
Template method must be overridden. |
java.lang.Class[] |
getReflectableClassesImpl()
Implementation of Reflector.getReflectableClasses() . |
protected ReflectionInfo |
getReflectionInfo(java.lang.Class clazz)
Get the ReflectionInfo for the given Class. |
protected java.lang.Class |
getTypeImpl(java.lang.Object bean,
java.lang.String propertyName)
Returns the type of the property based on the parameter type for the property's setter method. |
boolean |
isAllowNullPrimitiveAssignment()
Indicates whether primitive assignments to null are
allowed. |
protected boolean |
isPrimitiveSetter(java.lang.Object bean,
java.lang.String propertyName)
Learn whether the mutator/setter method for the given property is primitive. |
protected boolean |
isReadableImpl(java.lang.Object bean,
java.lang.String propertyName)
Implementation of BeanReflector.isReadable(Object, String) . |
boolean |
isStrictlyTyped()
Returns true . |
protected boolean |
isWriteableImpl(java.lang.Object bean,
java.lang.String propertyName)
Implementation of BeanReflector.isWriteable(Object, String) . |
protected java.lang.Object |
newInstanceImpl(java.lang.Class clazz,
java.lang.Object parameters)
Implementation of InstantiatingReflector.newInstance(Class, Object) . |
void |
setAllowNullPrimitiveAssignment(boolean allowNullPrimitiveAssignment)
Sets whether primitive assignments to null are allowed. |
protected void |
setImpl(java.lang.Object bean,
java.lang.String propertyName,
java.lang.Object value)
Template method must be overridden. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface net.sf.morph.reflect.InstantiatingReflector |
---|
newInstance |
Methods inherited from interface net.sf.morph.reflect.Reflector |
---|
getReflectableClasses, getWrapper |
Methods inherited from interface net.sf.morph.reflect.ContainerReflector |
---|
getContainedType, getIterator |
Methods inherited from interface net.sf.morph.reflect.Reflector |
---|
getReflectableClasses, getWrapper |
Methods inherited from interface net.sf.morph.reflect.BeanReflector |
---|
get, getPropertyNames, getType, isReadable, isWriteable, set |
Methods inherited from interface net.sf.morph.reflect.SizableReflector |
---|
getSize |
Constructor Detail |
---|
public ObjectReflector()
Method Detail |
---|
public java.lang.Class[] getReflectableClassesImpl()
Reflector.getReflectableClasses()
.
getReflectableClassesImpl
in class BaseReflector
protected java.lang.String[] getPropertyNamesImpl(java.lang.Object bean) throws java.lang.Exception
BeanReflector.getPropertyNames(Object)
.
Implementation automatically provided for
IndexedContainerReflectors. For other reflectors, throws an
UnsupportedOperationException.
getPropertyNamesImpl
in class BaseBeanReflector
java.lang.Exception
protected java.lang.Class getTypeImpl(java.lang.Object bean, java.lang.String propertyName) throws java.lang.Exception
getTypeImpl
in class BaseBeanReflector
java.lang.Exception
protected boolean isReadableImpl(java.lang.Object bean, java.lang.String propertyName) throws java.lang.Exception
BeanReflector.isReadable(Object, String)
.
Default implementation assumes that all properties of the bean specified
by BeanReflector.getPropertyNames(Object)
are readable.
isReadableImpl
in class BaseReflector
java.lang.Exception
protected boolean isWriteableImpl(java.lang.Object bean, java.lang.String propertyName) throws java.lang.Exception
BeanReflector.isWriteable(Object, String)
.
Default implementation assumes that all readable properties are also
writeable. One exception to this is when this reflector is an
IndexedContainerReflector but not a MutableIndexedContainerReflector, in
which case no properties are considered writeable.
isWriteableImpl
in class BaseReflector
java.lang.Exception
protected java.lang.Object getImpl(java.lang.Object bean, java.lang.String propertyName) throws java.lang.Exception
propertyName
in bean
bean
. If the property is an indexed property that is only
accessible via an indexed getter method of the form get(int)
,
this implementation is O(n). Otherwise, this implementation is O(1).
getImpl
in class BaseBeanReflector
java.lang.Exception
protected void setImpl(java.lang.Object bean, java.lang.String propertyName, java.lang.Object value) throws java.lang.Exception
BeanReflector.set(Object, String, Object)
.
Implementation automatically provided for
MutableIndexedContainerReflectors. For other reflectors, throws an
UnsupportedOperationException.
setImpl
in class BaseBeanReflector
java.lang.Exception
protected java.lang.Object newInstanceImpl(java.lang.Class clazz, java.lang.Object parameters) throws java.lang.Exception
InstantiatingReflector.newInstance(Class, Object)
.
Default implementation returns a new instance of the given class by
calling Class#newInstance())
.
newInstanceImpl
in class BaseReflector
java.lang.Exception
protected java.lang.Class getContainedTypeImpl(java.lang.Class clazz) throws java.lang.Exception
ContainerReflector.getContainedType(Class)
.
getContainedTypeImpl
in class BaseReflector
java.lang.Exception
protected java.util.Iterator getIteratorImpl(java.lang.Object container) throws java.lang.Exception
ContainerReflector.getIterator(Object)
.
getIteratorImpl
in class BaseReflector
java.lang.Exception
protected boolean isPrimitiveSetter(java.lang.Object bean, java.lang.String propertyName) throws java.lang.Exception
bean
- propertyName
-
java.lang.Exception
protected ReflectionInfo getReflectionInfo(java.lang.Class clazz)
clazz
-
public boolean isStrictlyTyped()
true
.
isStrictlyTyped
in class BaseReflector
true
public boolean isAllowNullPrimitiveAssignment()
null
are
allowed. If they are allowed, primitive assignments to null
will be ignored. If they are not allowed, a ReflectionException will be
thrown.
null
are allowedpublic void setAllowNullPrimitiveAssignment(boolean allowNullPrimitiveAssignment)
null
are allowed. If
they are allowed, primitive assignments to null
will be
ignored. If they are not allowed, a ReflectionException will be thrown.
allowNullPrimitiveAssignment
- whether primitive assignments to null
are
allowed
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |