net.sf.mmm.util.value.impl
Class AbstractConverterToArray<ARRAY>

java.lang.Object
  extended by net.sf.mmm.util.component.base.AbstractComponent
      extended by net.sf.mmm.util.component.base.AbstractLoggableComponent
          extended by net.sf.mmm.util.value.base.AbstractValueConverter<SOURCE,TARGET>
              extended by net.sf.mmm.util.value.base.AbstractRecursiveValueConverter<Object,CONTAINER>
                  extended by net.sf.mmm.util.value.impl.AbstractValueConverterToContainer<ARRAY>
                      extended by net.sf.mmm.util.value.impl.AbstractConverterToArray<ARRAY>
Type Parameters:
ARRAY - is the generic type of the array as target-type.
All Implemented Interfaces:
SimpleValueConverter<Object,ARRAY>, ValueConverter<Object,ARRAY>
Direct Known Subclasses:
ValueConverterToArrayOfBoolean, ValueConverterToArrayOfByte, ValueConverterToArrayOfDouble, ValueConverterToArrayOfFloat, ValueConverterToArrayOfInt, ValueConverterToArrayOfLong, ValueConverterToArrayOfObject, ValueConverterToArrayOfShort

public abstract class AbstractConverterToArray<ARRAY>
extends AbstractValueConverterToContainer<ARRAY>

This is an implementation of the ValueConverter interface that converts an Object to an array.
Java has a string type-system and arrays of primitive types (int[], etc.) can therefore NOT be casted to Object[]. However Object is NOT specific enough so we need to supply multiple ValueConverter

Since:
1.1.0
Author:
Joerg Hohwiller (hohwille at users.sourceforge.net)

Field Summary
 
Fields inherited from class net.sf.mmm.util.value.impl.AbstractValueConverterToContainer
ELEMENT_ESCAPE_END, ELEMENT_ESCAPE_START, ELEMENT_SEPARATOR
 
Constructor Summary
AbstractConverterToArray()
          The constructor.
 
Method Summary
protected  void convertContainerEntry(Object element, int index, ARRAY container, Object valueSource, GenericType<? extends ARRAY> targetType, Object value)
          This method converts a single entry of a container.
protected  ARRAY createContainer(GenericType<? extends ARRAY> targetType, int length)
          This method creates the according container for the given containerType.
protected  void doInitialize()
          This method performs the actual initialization.
 
Methods inherited from class net.sf.mmm.util.value.impl.AbstractValueConverterToContainer
convert, convertFromArray, convertFromCollection, convertFromString, getCollectionReflectionUtil, getSourceType, setCollectionReflectionUtil
 
Methods inherited from class net.sf.mmm.util.value.base.AbstractRecursiveValueConverter
getComposedValueConverter, setComposedValueConverter
 
Methods inherited from class net.sf.mmm.util.value.base.AbstractValueConverter
convert, getReflectionUtil, setReflectionUtil
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractLoggableComponent
getLogger, setLogger
 
Methods inherited from class net.sf.mmm.util.component.base.AbstractComponent
doInitialized, getInitializationState, initialize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.mmm.util.value.api.ValueConverter
getTargetType
 

Constructor Detail

AbstractConverterToArray

public AbstractConverterToArray()
The constructor.

Method Detail

doInitialize

protected void doInitialize()
This method performs the actual initialization. It is called when AbstractComponent.initialize() is invoked for the first time.
ATTENTION:
When you override this method from a sub-class you need to do a super.AbstractComponent.doInitialize().

Overrides:
doInitialize in class AbstractValueConverterToContainer<ARRAY>

convertContainerEntry

protected void convertContainerEntry(Object element,
                                     int index,
                                     ARRAY container,
                                     Object valueSource,
                                     GenericType<? extends ARRAY> targetType,
                                     Object value)
Description copied from class: AbstractValueConverterToContainer
This method converts a single entry of a container.

Specified by:
convertContainerEntry in class AbstractValueConverterToContainer<ARRAY>
Parameters:
element - is the single entry (element) of the container to convert.
index - is the index of the given element in the order of occurrence.
container - is the current container where to add the given element as entry.
valueSource - describes the source of the value or null if NOT available.
targetType - is the target-type to convert to.
value - is the original value to convert.

createContainer

protected ARRAY createContainer(GenericType<? extends ARRAY> targetType,
                                int length)
This method creates the according container for the given containerType.

Specified by:
createContainer in class AbstractValueConverterToContainer<ARRAY>
Parameters:
targetType - is the GenericType of the container.
length - is the length (or capacity) of the container to create.
Returns:
the container instance.


Copyright © 2001-2010 mmm-Team. All Rights Reserved.