org.spicefactory.lib.reflect.convert
Class ArrayConverter
java.lang.Object
org.spicefactory.lib.reflect.convert.AbstractSequenceConverter<Object>
org.spicefactory.lib.reflect.convert.ArrayConverter
- All Implemented Interfaces:
- Converter<Object>
public class ArrayConverter
- extends AbstractSequenceConverter<Object>
Converter implementation that creates Arrays of the required target type from any sequence (Collection
or Array). This might include conversion of elements of that sequence to the required type.
- Author:
- Jens Halm
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ArrayConverter
public ArrayConverter(ReflectionFactory factory)
createInstance
protected Object createInstance(TypeContext typeContext,
int size,
Object originalValue)
- Description copied from class:
AbstractSequenceConverter
- Create a new instance for the required target type. The given TypeContext instance
gives additional hints on the exact required type of the sequence (i.e. a Set or List or an Array
of Numbers).
- Specified by:
createInstance in class AbstractSequenceConverter<Object>
- Parameters:
typeContext - the context from which the required type of the new instance be obtainedsize - the size of the Array/Collection to createoriginalValue - the original value (Array or Collection - mainly for logging purposes)
- Returns:
- the new instance
getElementType
protected Type getElementType(TypeContext typeContext)
- Description copied from class:
AbstractSequenceConverter
- Return the generic element type of the sequence (Array or Collection).
- Specified by:
getElementType in class AbstractSequenceConverter<Object>
- Parameters:
typeContext - the context from which the element type can be obtained
- Returns:
- the generic element type of the sequence (Array or Collection)
addElement
protected void addElement(Object array,
Object element,
int index)
- Description copied from class:
AbstractSequenceConverter
- Adds the given element to the sequence (Array or Collection) at the specified index.
- Specified by:
addElement in class AbstractSequenceConverter<Object>
- Parameters:
array - the sequence (Array or Collection) the item should be added toelement - the new element to be addedindex - the index at which the element should be added