@Override public T convert(S sourceValue) throws ConversionException { return (sourceValue != null ? realConverter.convert(sourceValue) : nullResult); }
@Override public T convert(S sourceValue) throws ConversionException { synchronized(realConverter) { return realConverter.convert(sourceValue); } }
@Override public T convert(Object source) throws ConversionException { Object tmp = source; for (Converter converter : components) { tmp = converter.convert(tmp); } return (T) tmp; }
@Override public T next() { S sourceValue = source.next(); return converter.convert(sourceValue); }
@Override public StringBuffer format(Object sourceValue, StringBuffer toAppendTo, FieldPosition pos) { toAppendTo.append((converter).convert(sourceValue)); return toAppendTo; }
public static <S, T> Object convertAll(S[] sourceValues, Converter<S, T> converter, Class componentType) { Object convertedValues = Array.newInstance(componentType, sourceValues.length); for (int i = 0; i < sourceValues.length; i++) Array.set(convertedValues, i, converter.convert(sourceValues[i])); return convertedValues; }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Object convertString(CellValue cellValue, String emptyMarker, Converter<?, ?> stringPreprocessor) { String content = cellValue.getStringValue(); if (content != null && (content.equals(emptyMarker) || content.equals("'"))) content = ""; return (stringPreprocessor != null ? ((Converter) stringPreprocessor).convert(content) : content); }
public static <T> ComparableWrapper<T>[] wrapAll(T[] realObjects, Converter<T, ?> comparableBuilder) { ComparableWrapper<T>[] result = new ComparableWrapper[realObjects.length]; for (int i = 0; i < realObjects.length; i++) { T realObject = realObjects[i]; Comparable comparable = (Comparable) comparableBuilder.convert(realObject); result[i] = new ComparableWrapper<T>(comparable, realObject); } return result; }
@Override public GregorianCalendar convert(String sourceValue) throws ConversionException { Date date = realConverter.convert(sourceValue); return TimeUtil.gregorianCalendar(date); }
@Override public boolean valid(String value) { if (value == null) return false; return realValidator.valid(substringExtractor.convert(value)); }
@Override @SuppressWarnings("unchecked") public Object convert(Object sourceValue) throws ConversionException { return (condition.evaluate(sourceValue) ? realConverter.convert(sourceValue) : sourceValue); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Object convertString(Cell cell, String emptyMarker, String nullMarker, Converter<?, ?> stringPreprocessor) { String content = cell.getRichStringCellValue().getString(); if (content != null) { if (content.equals(emptyMarker) || content.equals("'")) content = ""; if (content.equals(nullMarker)) content = null; } return (stringPreprocessor != null ? ((Converter) stringPreprocessor).convert(content) : content); }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static Object convertString(Cell cell, String emptyMarker, String nullMarker, Converter<?, ?> stringPreprocessor) { String content = cell.getRichStringCellValue().getString(); if (content != null) { if (content.equals(emptyMarker) || content.equals("'")) content = ""; if (content.equals(nullMarker)) content = null; } return (stringPreprocessor != null ? ((Converter) stringPreprocessor).convert(content) : content); }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); for (int i = 0; i < cells.length; i++) out.write(cells[i]); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { Object[] cellsOfCurrentRow = (Object[]) context.get("part"); for (int i = 0; i < cellsOfCurrentRow.length; i++) out.write(converters[i].convert(cellsOfCurrentRow[i])); out.write(SystemInfo.getLineSeparator()); } catch (ConversionException e) { throw new ScriptException(e); } } }
public static void mapAttributesToProperties(Element element, Object bean, boolean unescape, Converter<String, String> nameNormalizer) { for (Map.Entry<String, String> attribute : getAttributes(element).entrySet()) { String name = StringUtil.lastToken(attribute.getKey(), ':'); name = nameNormalizer.convert(name); String value = attribute.getValue(); if (unescape) value = StringUtil.unescape(value); Class<?> type = bean.getClass(); if (BeanUtil.hasProperty(type, name)) BeanUtil.setPropertyValue(bean, name, value, true, true); } }
@Override public DataContainer<T> next(DataContainer<T> container) { DataContainer<S> sourceWrapper = nextOfSource(); if (sourceWrapper == null) return null; return container.setData(converter.convert(sourceWrapper.getData())); }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); CSVUtil.writeRow(out, separator, cells); } catch (ConversionException e) { throw new ScriptException(e); } }
@Override public void execute(Context context, Writer out) throws IOException, ScriptException { try { String[] cells = converter.convert(context.get("part")); CSVUtil.writeRow(out, separator, cells); } catch (ConversionException e) { throw new ScriptException(e); } }
public DataContainer<T> next(DataContainer<T> container) { DataContainer<S> sourceValue = source.next(sourceContainer.get()); if (sourceValue == null) return null; return container.setData(converter.convert(sourceValue.getData())); }