Example usage for org.springframework.beans SimpleTypeConverter SimpleTypeConverter

List of usage examples for org.springframework.beans SimpleTypeConverter SimpleTypeConverter

Introduction

In this page you can find the example usage for org.springframework.beans SimpleTypeConverter SimpleTypeConverter.

Prototype

public SimpleTypeConverter() 

Source Link

Usage

From source file:com.alibaba.citrus.service.requestcontext.support.ValueListSupportTests.java

@Before
public void init() {
    values = new ValueListSupport(new SimpleTypeConverter(), true);
}

From source file:org.jdal.swing.report.DefaultReportParameterEditor.java

public Object getValue() throws Exception {
    String strValue = ((JTextField) editor).getText();
    SimpleTypeConverter stc = new SimpleTypeConverter();
    return stc.convertIfNecessary(strValue, clazz);
}

From source file:cat.albirar.framework.dynabean.impl.DefaultDynaBeanFactory.java

/**
 * Default constructor./*from   w  w  w  .java 2s  . com*/
 */
public DefaultDynaBeanFactory() {
    propRegistry = new SimpleTypeConverter();
    descriptors = Collections.synchronizedMap(new TreeMap<String, DynaBeanDescriptor<?>>());
}

From source file:com.alibaba.citrus.service.form.impl.FormImpl.java

/**
 * converter/* ww w . j  a v  a2  s . c om*/
 */
public TypeConverter getTypeConverter() {
    if (typeConverter == null) {
        typeConverter = new SimpleTypeConverter();
        getFormConfig().getPropertyEditorRegistrar().registerCustomEditors(typeConverter);
    }

    return typeConverter;
}

From source file:org.jdal.ui.bind.DirectFieldAccessor.java

/**
 * Create a new DirectFieldAccessor for the given target object.
 * @param target the target object to access
 *//*from   w ww .  ja v a 2  s.  c  om*/
public DirectFieldAccessor(final Object target) {
    Assert.notNull(target, "Target object must not be null");
    this.target = target;
    ReflectionUtils.doWithFields(this.target.getClass(), new ReflectionUtils.FieldCallback() {
        public void doWith(Field field) {
            // jlm - FIX SPR-8398: avoid to overwrite shadowed fileds
            if (!fieldMap.containsKey(field.getName())) {
                fieldMap.put(field.getName(), field);
            }
        }
    });
    this.typeConverterDelegate = new SimpleTypeConverter();
    registerDefaultEditors();
    setExtractOldValueForEditor(true);
}

From source file:org.synyx.hades.extensions.beans.DomainClassPropertyEditor.java

/**
 * Returns the actual typed id. Looks up an available customly registered
 * {@link PropertyEditor} from the {@link PropertyEditorRegistry} before
 * falling back on a {@link SimpleTypeConverter} to translate the
 * {@link String} id into the type one.//from w  ww.ja  v a  2s .  c o  m
 * 
 * @param idAsString
 * @return
 */
@SuppressWarnings("unchecked")
private T getId(String idAsString) {

    Class<T> idClass = (Class<T>) ClassUtils.getIdClass(dao.getClass());

    PropertyEditor idEditor = registry.findCustomEditor(idClass, null);

    if (idEditor != null) {
        idEditor.setAsText(idAsString);
        return (T) idEditor.getValue();
    }

    return new SimpleTypeConverter().convertIfNecessary(idAsString, idClass);
}

From source file:com.consol.citrus.admin.converter.endpoint.AbstractEndpointConverter.java

/**
 *
 * @param setter//from   ww w.  ja  v  a 2  s.  c  o  m
 * @param value
 * @return
 */
private Object getMethodArgument(Method setter, String value) {
    Class<?> type = setter.getParameterTypes()[0];
    if (type.isInstance(value)) {
        return type.cast(value);
    }

    try {
        return new SimpleTypeConverter().convertIfNecessary(value, type);
    } catch (ConversionNotSupportedException e) {
        if (String.class.equals(type)) {
            return value.toString();
        }

        throw new ApplicationRuntimeException("Unable to convert method argument type", e);
    }
}

From source file:com.conversantmedia.mapreduce.tool.AnnotatedToolContext.java

@Override
protected void populateExtendedContext(CommandLine line) throws ParseException {
    // Populate the underlying annotated context object
    // with the values from the parsed command line arguments.
    SimpleTypeConverter converter = new SimpleTypeConverter();

    for (Entry<String, Field> e : this.fieldsMap.entrySet()) {
        String optName = e.getKey();
        Field field = e.getValue();
        String defaultValue = defaultValuesMap.get(optName);
        field.setAccessible(true);/*from  ww w.  j  a v a  2 s .  c o  m*/
        try {
            if (line.hasOption(optName)) {
                Object value = line.getOptionValue(optName);
                if (value == null) {
                    value = Boolean.TRUE;
                }
                value = converter.convertIfNecessary(value, field.getType());
                field.set(this.bean, value);
            } else if (StringUtils.isNotBlank(defaultValue)) {
                Object value = converter.convertIfNecessary(defaultValue, field.getType());
                field.set(this.bean, value);
            }
        } catch (IllegalArgumentException | IllegalAccessException e1) {
            throw new ParseException(e1.getMessage());
        }
    }
}

From source file:com.alibaba.citrus.service.requestcontext.session.valueencoder.AbstractSessionValueEncoder.java

protected final TypeConverter getTypeConverter() {
    SimpleTypeConverter typeConverter = new SimpleTypeConverter();
    propertyEditorRegistrars.registerCustomEditors(typeConverter);
    return typeConverter;
}