Class ArrayConverter<T>
java.lang.Object
jodd.typeconverter.impl.ArrayConverter<T>
- All Implemented Interfaces:
TypeConverter<T[]>
- Direct Known Subclasses:
ClassArrayConverter, StringArrayConverter
Converts given object to an array. This converter is specific, as it
is not directly registered to a type; but created when needed.
Conversion rules:
nullvalue is returned asnull- source non-array value is checked for
Collections - if non-array element can't be resolved, it is converted to single element array
- source array is converted to target array, by converting each element
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionArrayConverter(TypeConverterManager typeConverterManager, Class<T> targetComponentType) -
Method Summary
Modifier and TypeMethodDescriptionT[]Converts object received as parameter into object of another class.protected T[]convertArrayToArray(Object value) Converts array value to array.protected T[]convertPrimitiveArrayToArray(Object value, Class primitiveComponentType) Converts primitive array to target array.protected String[]convertStringToArray(String value) Converts string to array, for theconvertValueToArray(Object)method.protected T[]Creates an array with single element.protected TconvertType(Object value) Converts type using type converter manager.protected T[]convertValueToArray(Object value) Converts non-array value to array.protected T[]createArray(int length) Creates new array of target component type.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TypeConverter
convert
-
Field Details
-
NUMBER_DELIMITERS
public static final char[] NUMBER_DELIMITERS -
typeConverterManager
-
targetComponentType
-
-
Constructor Details
-
ArrayConverter
-
-
Method Details
-
convert
Description copied from interface:TypeConverterConverts object received as parameter into object of another class. For example, anIntegerconverter tries to convert given objects into targetIntegerobject. Converters should try all reasonable ways of conversion into target object, depending on target type.- Specified by:
convertin interfaceTypeConverter<T>- Parameters:
value- object to convert from- Returns:
- resulting object converted to target type
-
convertType
-
createArray
Creates new array of target component type. Default implementation uses reflection to create an array of target type. Override it for better performances. -
convertToSingleElementArray
-
convertValueToArray
-
convertStringToArray
Converts string to array, for theconvertValueToArray(Object)method. By default, the string is converted into an array usingCsvUtil. -
convertArrayToArray
-
convertPrimitiveArrayToArray
-