org.appng.api.support

## Class RequestSupportImpl

- java.lang.Object
- - org.appng.api.support.RequestSupportImpl

- All Implemented Interfaces:
    RequestSupport, org.springframework.beans.factory.InitializingBean, org.springframework.core.convert.ConversionService

      public class RequestSupportImpl
      extends Object
      implements RequestSupport

  Default `RequestSupport` implementation
  Author:
    Matthias Müller

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Application` | `application`
    `protected org.springframework.core.convert.ConversionService` | `conversionService`
    `protected static String` | `CURRENT`
    `protected Environment` | `environment`
    `protected ExpressionEvaluator` | `expressionEvaluator`
    `protected FieldConversionFactory` | `fieldConverter`
    `protected List<FieldType>` | `FILE_TYPES`
    `protected List<FieldType>` | `LIST_TYPES`
    `protected org.springframework.context.MessageSource` | `messageSource`
    `protected Site` | `site`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestSupportImpl()`
    `RequestSupportImpl(org.springframework.core.convert.ConversionService conversionService, Environment environment, org.springframework.context.MessageSource messageSource)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `addErrorMessage(FieldProcessor fp, MessageParam messageParam)` Adds an error to the `FieldProcessor` using `FieldProcessor.addErrorMessage(String)`.
    `void` | `addErrorMessage(FieldProcessor fp, MessageParam messageParam, String fieldBinding)` Adds an error to a `FieldDef` using `FieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)`.
    `void` | `afterPropertiesSet()`
    `boolean` | `canConvert(Class<?> sourceType, Class<?> targetType)`
    `boolean` | `canConvert(org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)`
    `<T> T` | `convert(Object source, Class<T> target)`
    `<T> T` | `convert(Object source, Class<T> target, T defaultValue)`
    `Object` | `convert(Object source, org.springframework.core.convert.TypeDescriptor sourceType, org.springframework.core.convert.TypeDescriptor targetType)`
    `void` | `fillBindObject(Object instance, FieldProcessor fp, RequestContainer container, ClassLoader classLoader)` Fills the given `bindobject` with the (converted) values provided by a `RequestContainer`.
    `Object` | `getBindObject(FieldProcessor fp, RequestContainer container, ClassLoader classLoader)` Creates, fills and returns a new bindobject.
    `<T> T` | `getDefaultIfNull(T source, T defaultValue)`
    `String` | `getMessage(String key, Object... args)` Retrieves a message from the underlying `MessageSource`, using the `Locale` provided by `Environment.getLocale()`.
    `void` | `handleException(FieldProcessor fp, Exception e)` Handles an `Exception`.
    `boolean` | `isFile(FieldType type)`
    `boolean` | `isListType(FieldType type)`
    `<T> void` | `setPropertyValue(T source, T target, String property)` Copies the property from `source` to `target`.
    `<T> void` | `setPropertyValues(T source, T target, MetaData metaData)` Copies the fields defined by the given `MetaData` from `source` to `target`.

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

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

    - ### Methods inherited from interface org.appng.api.RequestSupport

      `getEnvironment, getFieldConverter, getMessageSource`

- - ### Field Detail

    - #### CURRENT

          protected static final String CURRENT

      See Also:
        Constant Field Values

    - #### LIST_TYPES

          protected final List<FieldType> LIST_TYPES

    - #### FILE_TYPES

          protected final List<FieldType> FILE_TYPES

    - #### conversionService

          protected org.springframework.core.convert.ConversionService conversionService

    - #### messageSource

          protected org.springframework.context.MessageSource messageSource

    - #### environment

          protected Environment environment

    - #### expressionEvaluator

          protected ExpressionEvaluator expressionEvaluator

    - #### fieldConverter

          protected FieldConversionFactory fieldConverter

    - #### application

          protected Application application

    - #### site

          protected Site site

  - ### Constructor Detail

    - #### RequestSupportImpl

          public RequestSupportImpl()

    - #### RequestSupportImpl

          public RequestSupportImpl(org.springframework.core.convert.ConversionService conversionService,
                                    Environment environment,
                                    org.springframework.context.MessageSource messageSource)

  - ### Method Detail

    - #### fillBindObject

          public final void fillBindObject(Object instance,
                                           FieldProcessor fp,
                                           RequestContainer container,
                                           ClassLoader classLoader)
                                    throws BusinessException

      Description copied from interface: `RequestSupport`
      Fills the given `bindobject` with the (converted) values provided by a `RequestContainer`. The type of the `bindobject` must match `fp.getMetaData().getBindClass()`. The `MetaData`'s `FieldDef`initions are responsible for which fields are getting filled.
      Specified by:
        `fillBindObject` in interface `RequestSupport`
      Parameters:
        `instance` - the bindobject to fill
        `fp` - the current `FieldProcessor`
        `container` - the `RequestContainer` used to retrieve the values for filling the bindobject
        `classLoader` - the `ClassLoader` used to load the bindclass
      Throws:
        `BusinessException` -
        - if the type of the `bindobject` is not assignable from the type returned by `fp.getMetaData().getBindClass()`
        - if the type returned by `fp.getMetaData().getBindClass()` can not be instanciated

    - #### getBindObject

          public final Object getBindObject(FieldProcessor fp,
                                            RequestContainer container,
                                            ClassLoader classLoader)
                                     throws BusinessException

      Description copied from interface: `RequestSupport`
      Creates, fills and returns a new bindobject. The type of the returned object is obtained from `fp.getMetaData().getBindClass()`. The `MetaData`'s `FieldDef`initions are responsible for which fields are getting filled.
      Specified by:
        `getBindObject` in interface `RequestSupport`
      Parameters:
        `fp` - the current `FieldProcessor`
        `container` - the `RequestContainer` used to retrieve the values for filling the bindobject
        `classLoader` - the `ClassLoader` used to load the bindclass
      Returns:
        a new bindobject
      Throws:
        `BusinessException` - if the bindclass could not be loaded, instantiated or initialized, or if an error occurred during filling the bindobject
      See Also:
        `RequestSupport.fillBindObject(Object, FieldProcessor, RequestContainer, ClassLoader)`

    - #### convert

          public <T> T convert(Object source,
                               Class<T> target,
                               T defaultValue)

    - #### getDefaultIfNull

          public <T> T getDefaultIfNull(T source,
                                        T defaultValue)

    - #### getMessage

          public String getMessage(String key,
                                   Object... args)

      Description copied from interface: `RequestSupport`
      Retrieves a message from the underlying `MessageSource`, using the `Locale` provided by `Environment.getLocale()`.
      Specified by:
        `getMessage` in interface `RequestSupport`
      Parameters:
        `key` - the message key
        `args` - the message arguments

    - #### addErrorMessage

          public void addErrorMessage(FieldProcessor fp,
                                      MessageParam messageParam)

      Description copied from interface: `RequestSupport`
      Adds an error to the `FieldProcessor` using `FieldProcessor.addErrorMessage(String)`. `MessageParam.getMessageKey()` is used for the message key, `MessageParam.getMessageArgs()` for the message arguments.
      Specified by:
        `addErrorMessage` in interface `RequestSupport`
      Parameters:
        `fp` - a `FieldProcessor`
        `messageParam` - a `MessageParam`
      See Also:
        `MessageParam`

    - #### addErrorMessage

          public void addErrorMessage(FieldProcessor fp,
                                      MessageParam messageParam,
                                      String fieldBinding)

      Description copied from interface: `RequestSupport`
      Adds an error to a `FieldDef` using `FieldProcessor.addErrorMessage(org.appng.xml.platform.FieldDef, String)`. `MessageParam.getMessageKey()` is used for the message key, `MessageParam.getMessageArgs()` for the message arguments.
      Specified by:
        `addErrorMessage` in interface `RequestSupport`
      Parameters:
        `fp` - a `FieldProcessor`
        `messageParam` - a `MessageParam`
        `fieldBinding` - the binding of the `FieldDef` to add the error to
      See Also:
        `MessageParam`

    - #### handleException

          public void handleException(FieldProcessor fp,
                                      Exception e)
                               throws BusinessException

      Description copied from interface: `RequestSupport`
      Handles an `Exception`. If the given Exception is a `BusinessException`, the very same `BusinessException` is being re-thrown. Otherwise, the `Exception` is being wrapped into a new `BusinessException` which is then being thrown.
      If the given `Exception` is a `MessageParam`, `RequestSupport.addErrorMessage(FieldProcessor, MessageParam)` is being called.
      Specified by:
        `handleException` in interface `RequestSupport`
      Parameters:
        `fp` - a `FieldProcessor`
        `e` - an `Exception`
      Throws:
        `BusinessException`
      See Also:
        `MessageParam`, `RequestSupport.addErrorMessage(FieldProcessor, MessageParam)`

    - #### setPropertyValues

          public <T> void setPropertyValues(T source,
                                            T target,
                                            MetaData metaData)

      Description copied from interface: `RequestSupport`
      Copies the fields defined by the given `MetaData` from `source` to `target`.
      Specified by:
        `setPropertyValues` in interface `RequestSupport`
      Parameters:
        `source` - the source object to read the fields from
        `target` - the target object to write the fields to
        `metaData` - the `MetaData`

    - #### setPropertyValue

          public <T> void setPropertyValue(T source,
                                           T target,
                                           String property)

      Description copied from interface: `RequestSupport`
      Copies the property from `source` to `target`.
      Specified by:
        `setPropertyValue` in interface `RequestSupport`
      Parameters:
        `source` - the source object to read the property from
        `target` - the target object to write the property to
        `property` - the name of the property to set

    - #### canConvert

          public boolean canConvert(Class<?> sourceType,
                                    Class<?> targetType)

      Specified by:
        `canConvert` in interface `org.springframework.core.convert.ConversionService`

    - #### canConvert

          public boolean canConvert(org.springframework.core.convert.TypeDescriptor sourceType,
                                    org.springframework.core.convert.TypeDescriptor targetType)

      Specified by:
        `canConvert` in interface `org.springframework.core.convert.ConversionService`

    - #### convert

          public Object convert(Object source,
                                org.springframework.core.convert.TypeDescriptor sourceType,
                                org.springframework.core.convert.TypeDescriptor targetType)

      Specified by:
        `convert` in interface `org.springframework.core.convert.ConversionService`

    - #### convert

          public <T> T convert(Object source,
                               Class<T> target)

      Specified by:
        `convert` in interface `org.springframework.core.convert.ConversionService`

    - #### isFile

          public final boolean isFile(FieldType type)

    - #### isListType

          public final boolean isListType(FieldType type)

    - #### afterPropertiesSet

          public void afterPropertiesSet()

      Specified by:
        `afterPropertiesSet` in interface `org.springframework.beans.factory.InitializingBean`

Copyright © 2011–2023 aiticon GmbH. All rights reserved.