org.apache.velocity.tools.generic.introspection
Class PublicFieldUberspect

java.lang.Object
  extended by org.apache.velocity.util.introspection.UberspectImpl
      extended by org.apache.velocity.tools.generic.introspection.PublicFieldUberspect
All Implemented Interfaces:
org.apache.velocity.util.introspection.Uberspect, org.apache.velocity.util.introspection.UberspectLoggable

public class PublicFieldUberspect
extends org.apache.velocity.util.introspection.UberspectImpl

Uberspect implementation that exposes public fields. Also exposes the explicit "length" field of arrays.

To use, tell Velocity to use this class for introspection by adding the following to your velocity.properties:
runtime.introspector.uberspect = org.apache.velocity.tools.generic.introspection.PublicFieldUberspect

Version:
$Id: $
Author:
Shinobu Kawai

Nested Class Summary
protected  class PublicFieldUberspect.ArrayLengthGetter
          Implementation of VelPropertyGet that gets length from arrays.
protected  class PublicFieldUberspect.PublicFieldGetter
          Implementation of VelPropertyGet that gets from public fields.
protected  class PublicFieldUberspect.PublicFieldSetter
          Implementation of VelPropertySet that sets to public fields.
 
Nested classes/interfaces inherited from class org.apache.velocity.util.introspection.UberspectImpl
org.apache.velocity.util.introspection.UberspectImpl.VelGetterImpl, org.apache.velocity.util.introspection.UberspectImpl.VelMethodImpl, org.apache.velocity.util.introspection.UberspectImpl.VelSetterImpl
 
Constructor Summary
PublicFieldUberspect()
          Default constructor.
 
Method Summary
 org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(java.lang.Object obj, java.lang.String identifier, org.apache.velocity.util.introspection.Info i)
          Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie).
 org.apache.velocity.util.introspection.VelPropertySet getPropertySet(java.lang.Object obj, java.lang.String identifier, java.lang.Object arg, org.apache.velocity.util.introspection.Info i)
          Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir").
 
Methods inherited from class org.apache.velocity.util.introspection.UberspectImpl
getIterator, getMethod, init, setRuntimeLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PublicFieldUberspect

public PublicFieldUberspect()
Default constructor.

Method Detail

getPropertyGet

public org.apache.velocity.util.introspection.VelPropertyGet getPropertyGet(java.lang.Object obj,
                                                                            java.lang.String identifier,
                                                                            org.apache.velocity.util.introspection.Info i)
                                                                     throws java.lang.Exception
Property getter - returns VelPropertyGet appropos for #set($foo = $bar.woogie).
Returns a special VelPropertyGet for the length property of arrays. Otherwise tries the regular routine. If a getter was not found, returns a VelPropertyGet that gets from public fields.

Specified by:
getPropertyGet in interface org.apache.velocity.util.introspection.Uberspect
Overrides:
getPropertyGet in class org.apache.velocity.util.introspection.UberspectImpl
Parameters:
obj - the object
identifier - the name of the property
i - a bunch of information.
Returns:
a valid VelPropertyGet, if it was found.
Throws:
java.lang.Exception - failed to create a valid VelPropertyGet.

getPropertySet

public org.apache.velocity.util.introspection.VelPropertySet getPropertySet(java.lang.Object obj,
                                                                            java.lang.String identifier,
                                                                            java.lang.Object arg,
                                                                            org.apache.velocity.util.introspection.Info i)
                                                                     throws java.lang.Exception
Property setter - returns VelPropertySet appropos for #set($foo.bar = "geir").
First tries the regular routine. If a setter was not found, returns a VelPropertySet that sets to public fields.

Specified by:
getPropertySet in interface org.apache.velocity.util.introspection.Uberspect
Overrides:
getPropertySet in class org.apache.velocity.util.introspection.UberspectImpl
Parameters:
obj - the object
identifier - the name of the property
arg - the value to set to the property
i - a bunch of information.
Returns:
a valid VelPropertySet, if it was found.
Throws:
java.lang.Exception - failed to create a valid VelPropertySet.


Copyright © 2002-2005 org.ieee.shinobu. All Rights Reserved.