/** * Register a new ArrayConverter with the specified element delegate converter * that returns a default array of the specified size in the event of conversion errors. * * @param componentType The component type of the array * @param componentConverter The converter to delegate to for the array elements * @param throwException Whether a conversion exception should be thrown or a default * value used in the event of a conversion error * @param defaultArraySize The size of the default array */ private void registerArrayConverter(final Class<?> componentType, final Converter componentConverter, final boolean throwException, final int defaultArraySize) { final Class<?> arrayType = Array.newInstance(componentType, 0).getClass(); Converter arrayConverter = null; if (throwException) { arrayConverter = new ArrayConverter(arrayType, componentConverter); } else { arrayConverter = new ArrayConverter(arrayType, componentConverter, defaultArraySize); } register(arrayType, arrayConverter); }
size = Array.getLength(value); } else { final Collection<?> collection = convertToCollection(type, value); size = collection.size(); iterator = collection.iterator(); return (String)getDefault(String.class);
/** * Provide a String representation of this array converter. * * @return A String representation of this array converter */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(); buffer.append(toString(getClass())); buffer.append("[UseDefault="); buffer.append(isUseDefault()); buffer.append(", "); buffer.append(elementConverter.toString()); buffer.append(']'); return buffer.toString(); }
throw new ConversionException(toString(getClass()) + " cannot handle conversion to '" + toString(type) + "' (not an array)."); size = Array.getLength(value); } else { final Collection<?> collection = convertToCollection(type, value); size = collection.size(); iterator = collection.iterator();
if (log().isDebugEnabled()) { log().debug("Parsing elements, delimiter=[" + delimiter + "], value=[" + value + "]"); } else { throw new ConversionException("Encountered token of type " + ttype + " parsing elements to '" + toString(type) + "."); list = Collections.emptyList(); if (log().isDebugEnabled()) { log().debug(list.size() + " elements parsed"); + toString(type) + "': " + e.getMessage(), e);
/** * Construct an <b>array</b> <code>Converter</code> with the specified * <b>component</b> <code>Converter</code> that returns a default * array of the specified size (or <code>null</code>) if an error occurs. * * @param defaultType The default array type this * <code>Converter</code> handles * @param elementConverter Converter used to convert * individual array elements. * @param defaultSize Specifies the size of the default array value or if less * than zero indicates that a <code>null</code> default value should be used. */ public ArrayConverter(final Class<?> defaultType, final Converter elementConverter, final int defaultSize) { this(defaultType, elementConverter); this.defaultSize = defaultSize; Object defaultValue = null; if (defaultSize >= 0) { defaultValue = Array.newInstance(defaultType.getComponentType(), defaultSize); } setDefaultValue(defaultValue); }
return parseElements(type, value.toString());
final Class<?> arrayType = helper.getArrayTypeOfElementType(); final ArrayConverter converter = new ArrayConverter(arrayType, elementConverter); configure(converter, elementType); final Object[] array = (Object[]) converter.convert(arrayType, value); convertedValue = Arrays.asList(array);
ArrayConverter arrayConverter = new ArrayConverter(String[].class, new StringConverter()); arrayConverter.setDelimiter(','); convertUtilsBean.register(arrayConverter, String[].class); AWSCredentialsProviderPropertyValueDecoder oldCredentialsDecoder = new AWSCredentialsProviderPropertyValueDecoder();
throw new ConversionException(toString(getClass()) + " cannot handle conversion to '" + toString(type) + "' (not an array)."); size = Array.getLength(value); } else { final Collection<?> collection = convertToCollection(type, value); size = collection.size(); iterator = collection.iterator();
if (log().isDebugEnabled()) { log().debug("Parsing elements, delimiter=[" + delimiter + "], value=[" + value + "]"); } else { throw new ConversionException("Encountered token of type " + ttype + " parsing elements to '" + toString(type) + "."); list = Collections.emptyList(); if (log().isDebugEnabled()) { log().debug(list.size() + " elements parsed"); + toString(type) + "': " + e.getMessage(), e);
/** * Construct an <b>array</b> <code>Converter</code> with the specified * <b>component</b> <code>Converter</code> that returns a default * array of the specified size (or <code>null</code>) if an error occurs. * * @param defaultType The default array type this * <code>Converter</code> handles * @param elementConverter Converter used to convert * individual array elements. * @param defaultSize Specifies the size of the default array value or if less * than zero indicates that a <code>null</code> default value should be used. */ public ArrayConverter(final Class<?> defaultType, final Converter elementConverter, final int defaultSize) { this(defaultType, elementConverter); this.defaultSize = defaultSize; Object defaultValue = null; if (defaultSize >= 0) { defaultValue = Array.newInstance(defaultType.getComponentType(), defaultSize); } setDefaultValue(defaultValue); }
return parseElements(type, value.toString());
/** * Provide a String representation of this array converter. * * @return A String representation of this array converter */ @Override public String toString() { final StringBuilder buffer = new StringBuilder(); buffer.append(toString(getClass())); buffer.append("[UseDefault="); buffer.append(isUseDefault()); buffer.append(", "); buffer.append(elementConverter.toString()); buffer.append(']'); return buffer.toString(); }
size = Array.getLength(value); } else { final Collection<?> collection = convertToCollection(type, value); size = collection.size(); iterator = collection.iterator(); return (String)getDefault(String.class);
throw new ConversionException(toString(getClass()) + " cannot handle conversion to '" + toString(type) + "' (not an array)."); size = Array.getLength(value); } else { Collection collection = convertToCollection(type, value); size = collection.size(); iterator = collection.iterator();
if (log().isDebugEnabled()) { log().debug("Parsing elements, delimiter=[" + delimiter + "], value=[" + value + "]"); } else { throw new ConversionException("Encountered token of type " + ttype + " parsing elements to '" + toString(type) + "."); list = Collections.EMPTY_LIST; if (log().isDebugEnabled()) { log().debug(list.size() + " elements parsed"); + toString(type) + "': " + e.getMessage(), e);
/** * Register a new ArrayConverter with the specified element delegate converter * that returns a default array of the specified size in the event of conversion errors. * * @param componentType The component type of the array * @param componentConverter The converter to delegate to for the array elements * @param throwException Whether a conversion exception should be thrown or a default * value used in the event of a conversion error * @param defaultArraySize The size of the default array */ private void registerArrayConverter(final Class<?> componentType, final Converter componentConverter, final boolean throwException, final int defaultArraySize) { final Class<?> arrayType = Array.newInstance(componentType, 0).getClass(); Converter arrayConverter = null; if (throwException) { arrayConverter = new ArrayConverter(arrayType, componentConverter); } else { arrayConverter = new ArrayConverter(arrayType, componentConverter, defaultArraySize); } register(arrayType, arrayConverter); }
/** * Construct an <b>array</b> <code>Converter</code> with the specified * <b>component</b> <code>Converter</code> that returns a default * array of the specified size (or <code>null</code>) if an error occurs. * * @param defaultType The default array type this * <code>Converter</code> handles * @param elementConverter Converter used to convert * individual array elements. * @param defaultSize Specifies the size of the default array value or if less * than zero indicates that a <code>null</code> default value should be used. */ public ArrayConverter(Class defaultType, Converter elementConverter, int defaultSize) { this(defaultType, elementConverter); this.defaultSize = defaultSize; Object defaultValue = null; if (defaultSize >= 0) { defaultValue = Array.newInstance(defaultType.getComponentType(), defaultSize); } setDefaultValue(defaultValue); }
return parseElements(type, value.toString());