net.sf.morph.reflect.reflectors
Class ContextReflector

java.lang.Object
  extended by net.sf.morph.reflect.reflectors.BaseReflector
      extended by net.sf.morph.reflect.reflectors.BaseBeanReflector
          extended by net.sf.morph.reflect.reflectors.ContextReflector
All Implemented Interfaces:
net.sf.composite.Component, BeanReflector, DecoratedReflector, InstantiatingReflector, Reflector, SizableReflector

public class ContextReflector
extends BaseBeanReflector
implements InstantiatingReflector

A reflector that can expose the properties of any Context.

Since:
Nov 28, 2004
Author:
Matt Sgarlata

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
ContextReflector()
           
 
Method Summary
protected  java.lang.Object getImpl(java.lang.Object bean, java.lang.String propertyName)
          Template method must be overridden.
protected  java.lang.String[] getPropertyNamesImpl(java.lang.Object bean)
          Template method must be overridden.
 java.lang.Class[] getReflectableClassesImpl()
          Implementation of Reflector.getReflectableClasses().
protected  java.lang.Class getTypeImpl(java.lang.Object bean, java.lang.String propertyName)
          Template method must be overridden.
protected  boolean isReadableImpl(java.lang.Object bean, java.lang.String propertyName)
          Returns true because all properties of a context are considered readable.
protected  boolean isWriteableImpl(java.lang.Object bean, java.lang.String propertyName)
          Returns true because all properties in a context are assumed to be writeable.
protected  java.lang.Object newInstanceImpl(java.lang.Class clazz, java.lang.Object parameters)
          Implementation of InstantiatingReflector.newInstance(Class, Object).
protected  void setImpl(java.lang.Object bean, java.lang.String propertyName, java.lang.Object value)
          Template method must be overridden.
 
Methods inherited from class net.sf.morph.reflect.reflectors.BaseReflector
add, addImpl, checkIndex, checkIsReflectable, createWrapperInvocationHandler, get, get, getContainedType, getContainedTypeImpl, getImpl, getIterator, getIteratorImpl, getPropertyNames, getReflectableCallCache, getReflectableClasses, getReflectorName, getSize, getSizeImpl, getType, getWrapper, getWrapperImpl, initialize, initializeImpl, isCachingIsReflectableCalls, isInitialized, isPerformingLogging, isReadable, isReflectable, isReflectable, isReflectableImpl, isReflectableImpl, isStrictlyTyped, isValidIndex, isWrappingRuntimeExceptions, isWriteable, newInstance, newInstanceImpl, set, set, setCachingIsReflectableCalls, setImpl, setInitialized, setReflectableCallCache, setReflectorName, toString
 
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.BeanReflector
get, getPropertyNames, getType, isReadable, isWriteable, set
 
Methods inherited from interface net.sf.morph.reflect.SizableReflector
getSize
 

Constructor Detail

ContextReflector

public ContextReflector()
Method Detail

getReflectableClassesImpl

public java.lang.Class[] getReflectableClassesImpl()
Description copied from class: BaseReflector
Implementation of Reflector.getReflectableClasses().

Specified by:
getReflectableClassesImpl in class BaseReflector

getPropertyNamesImpl

protected java.lang.String[] getPropertyNamesImpl(java.lang.Object bean)
                                           throws java.lang.Exception
Description copied from class: BaseBeanReflector
Template method must be overridden. Implementation of BeanReflector.getPropertyNames(Object). Implementation automatically provided for IndexedContainerReflectors. For other reflectors, throws an UnsupportedOperationException.

Specified by:
getPropertyNamesImpl in class BaseBeanReflector
Throws:
java.lang.Exception

getTypeImpl

protected java.lang.Class getTypeImpl(java.lang.Object bean,
                                      java.lang.String propertyName)
                               throws java.lang.Exception
Description copied from class: BaseBeanReflector
Template method must be overridden. Implementation of BeanReflector.getType(Object, String). Default implementation provided. For IndexedContainerReflectors, returns the type by calling ContainerReflector.getContainedType(Class). For other reflectors, checks the type of the property by calling BaseReflector.get(Object, String).

Specified by:
getTypeImpl in class BaseBeanReflector
Throws:
java.lang.Exception

isReadableImpl

protected boolean isReadableImpl(java.lang.Object bean,
                                 java.lang.String propertyName)
                          throws java.lang.Exception
Returns true because all properties of a context are considered readable. If the property isn't a defined property returned by getPropertyNames, null is returned when the BeanReflector.get(Object, String) method is called.

Overrides:
isReadableImpl in class BaseReflector
Throws:
java.lang.Exception

isWriteableImpl

protected boolean isWriteableImpl(java.lang.Object bean,
                                  java.lang.String propertyName)
                           throws java.lang.Exception
Returns true because all properties in a context are assumed to be writeable. If they're not (e.g. - on an Object has been exposed as a Context), an exception is thrown when the set method is called on the context.

Overrides:
isWriteableImpl in class BaseReflector
Throws:
java.lang.Exception

getImpl

protected java.lang.Object getImpl(java.lang.Object bean,
                                   java.lang.String propertyName)
                            throws java.lang.Exception
Description copied from class: BaseBeanReflector
Template method must be overridden. Implementation of BeanReflector.get(Object, String). Implementation automatically provided for IndexedContainerReflectors. For other reflectors, throws an UnsupportedOperationException.

Specified by:
getImpl in class BaseBeanReflector
Throws:
java.lang.Exception

setImpl

protected void setImpl(java.lang.Object bean,
                       java.lang.String propertyName,
                       java.lang.Object value)
                throws java.lang.Exception
Description copied from class: BaseBeanReflector
Template method must be overridden. Implementation of BeanReflector.set(Object, String, Object). Implementation automatically provided for MutableIndexedContainerReflectors. For other reflectors, throws an UnsupportedOperationException.

Specified by:
setImpl in class BaseBeanReflector
Throws:
java.lang.Exception

newInstanceImpl

protected java.lang.Object newInstanceImpl(java.lang.Class clazz,
                                           java.lang.Object parameters)
                                    throws java.lang.Exception
Description copied from class: BaseReflector
Implementation of InstantiatingReflector.newInstance(Class, Object). Default implementation returns a new instance of the given class by calling Class#newInstance()).

Overrides:
newInstanceImpl in class BaseReflector
Throws:
java.lang.Exception


Copyright © 2004-2008.