de.vc.jfo.rtf.listeners

## Class ReflectionDataSource

- java.lang.Object
- - de.vc.jfo.rtf.listeners.AbstractDataSource
  - - de.vc.jfo.rtf.listeners.ReflectionDataSource

- All Implemented Interfaces:
    FieldListener

      public class ReflectionDataSource
      extends AbstractDataSource

  Use this class to get business data (for fields) by reflection. This field listener has a target on which methods are invoked. The result of the method is passed to the field. Use the `register` to add relevant methods.

- - ### Field Summary

    - ### Fields inherited from interface de.vc.jfo.rtf.FieldListener

      `FIELD_FILLIN, FIELD_MERGEFIELD`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ReflectionDataSource()`
    `ReflectionDataSource(boolean autoRegister)`
    `ReflectionDataSource(java.lang.Object target)`
    `ReflectionDataSource(java.lang.Object target, boolean autoRegister)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `autoRegister()` Registers all get and is methods with any visibility (public, protected, package and private) of the invocation target.
    `void` | `autoRegister(boolean allVisibilities, boolean superMethods)` Registers all get and is methods of the invocation target.
    `protected java.lang.reflect.Method` | `findMatchingMethod(java.lang.String name, java.lang.reflect.Method[] methods, java.lang.Object[] params)`
    `protected java.lang.Object` | `getValue(java.lang.String keyword)`
    `boolean` | `hasValue(java.lang.String keyword)` Checks whether value (can also be an empty or null value) is assigned to a keyword.
    `protected boolean` | `insertResult(FieldContext ctx, java.lang.String keyword)`
    `boolean` | `isEmptyValue(java.lang.String keyword)` Checks whether an empty value is assigned to a keyword.
    `boolean` | `isIgnoreErrors()`
    `protected boolean` | `isInstance(java.lang.Class<?> clazz, java.lang.Object object)`
    `protected boolean` | `matches(java.lang.reflect.Method m, java.lang.Object[] params)`
    `boolean` | `register(java.lang.String keyword, java.lang.String method)` Registers a method that returns data for a field.
    `boolean` | `register(java.lang.String keyword, java.lang.String method, java.lang.Object... args)` Registers a method that returns data for a field.
    `void` | `setIgnoreErrors(boolean ignoreErrors)` Set whether exceptions during method invokation should be ignored or thrown.

    - ### Methods inherited from class de.vc.jfo.rtf.listeners.AbstractDataSource

      `fieldEncountered, handleUnpopulatedField, isCaseSensitiveKeywords, isEnableDateFormatting, isEnableNumberFormatting, isHighlightUnpopulatedFields, normalizeKey, setCaseSensitiveKeywords, setEnableDateFormatting, setEnableNumberFormatting, setHighlightUnpopulatedFields`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ReflectionDataSource

          public ReflectionDataSource()

    - #### ReflectionDataSource

          public ReflectionDataSource(boolean autoRegister)

    - #### ReflectionDataSource

          public ReflectionDataSource(java.lang.Object target)

    - #### ReflectionDataSource

          public ReflectionDataSource(java.lang.Object target,
                              boolean autoRegister)

  - ### Method Detail

    - #### autoRegister

          public void autoRegister()

      Registers all get and is methods with any visibility (public, protected, package and private) of the invocation target. The get and is prefixes are truncated and not part of the keyword.
      Example: If your object has a method "getAddress()", the keyword "Address" is registered. Note: Only methods without parameters are registered.

    - #### autoRegister

          public void autoRegister(boolean allVisibilities,
                          boolean superMethods)

      Registers all get and is methods of the invocation target. The get and is prefixes are truncated and not part of the keyword.
      Example: If your object has a method "getAddress()", the keyword "Address" is registered. Note: Only methods without parameters are registered.
      Parameters:
        `allVisibilities` - Register not only public methods?
        `superMethods` - Register methods of super classes and not just of concrete class.

    - #### register

          public boolean register(java.lang.String keyword,
                         java.lang.String method)

      Registers a method that returns data for a field. The method may have any visibility (public, private...).
      Parameters:
        `keyword` - Keyword in field.
        `method` - Name of method in target object.
      Returns:
        Returns true if method was found and registered.

    - #### register

          public boolean register(java.lang.String keyword,
                         java.lang.String method,
                         java.lang.Object... args)

      Registers a method that returns data for a field. The method may have any visibility (public, private...).
      Parameters:
        `keyword` - Keyword in field.
        `method` - Name of method in target object.
      Returns:
        Returns true if method was found and registered.

    - #### hasValue

          public boolean hasValue(java.lang.String keyword)

      Description copied from class: `AbstractDataSource`
      Checks whether value (can also be an empty or null value) is assigned to a keyword.
      Specified by:
        `hasValue` in class `AbstractDataSource`
      Parameters:
        `keyword` - Normalized keyword.
      Returns:
        `true` if there is a registered value for keyword.

    - #### isEmptyValue

          public boolean isEmptyValue(java.lang.String keyword)

      Description copied from class: `AbstractDataSource`
      Checks whether an empty value is assigned to a keyword.
      Specified by:
        `isEmptyValue` in class `AbstractDataSource`
      Parameters:
        `keyword` - Keyword
      Returns:
        `true` if value of `keyword` is empty.

    - #### isIgnoreErrors

          public boolean isIgnoreErrors()

    - #### setIgnoreErrors

          public void setIgnoreErrors(boolean ignoreErrors)

      Set whether exceptions during method invokation should be ignored or thrown.
      Parameters:
        `ignoreErrors` -

    - #### insertResult

          protected boolean insertResult(FieldContext ctx,
                             java.lang.String keyword)

      Specified by:
        `insertResult` in class `AbstractDataSource`

    - #### getValue

          protected java.lang.Object getValue(java.lang.String keyword)

    - #### findMatchingMethod

          protected java.lang.reflect.Method findMatchingMethod(java.lang.String name,
                                                    java.lang.reflect.Method[] methods,
                                                    java.lang.Object[] params)

    - #### matches

          protected boolean matches(java.lang.reflect.Method m,
                        java.lang.Object[] params)

    - #### isInstance

          protected boolean isInstance(java.lang.Class<?> clazz,
                           java.lang.Object object)

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.