Package net.sourceforge.stripes.validation

Examples of net.sourceforge.stripes.validation.TypeConverterFactory


        // Dig up the type converter.  This gets a bit tricky because we need to handle
        // the following cases:
        // 1. We need to simply find a converter for the declared type of a simple property
        // 2. We need to find a converter for the element type in a list/array/map
        // 3. We have a domain model object that implements List/Map and has a converter itself!
        TypeConverterFactory factory = this.configuration.getTypeConverterFactory();
        TypeConverter<?> converter = null;
        Locale locale = bean.getContext().getRequest().getLocale();

        converter = factory.getTypeConverter(declaredType, locale);
        if (validationInfo != null && validationInfo.converter() != null) {
            // If a specific converter was requested and it's the same type as one we'd use
            // for the declared type, set the return type appropriately
            if (converter != null && validationInfo.converter().isAssignableFrom(converter.getClass())) {
                returnType = declaredType;
            }
            // Otherwise assume that it's a converter for the scalar type inside a collection
            else {
                returnType = scalarType;
            }
            converter = factory.getInstance(validationInfo.converter(), locale);
        }
        // Else, if we got a converter for the declared type (e.g. Foo implementes List<Bar>)
        // then convert for the declared type
        else if (converter != null) {
            returnType = declaredType;
        }
        // Else look for a converter for the scalar type (Bar in List<Bar>)
        else {
            converter  = factory.getTypeConverter(scalarType, locale);
            returnType = scalarType;
        }

        log.debug("Converting ", values.length, " value(s) using ", (converter != null ?
            "converter " + converter.getClass().getName()
View Full Code Here


        // Dig up the type converter.  This gets a bit tricky because we need to handle
        // the following cases:
        // 1. We need to simply find a converter for the declared type of a simple property
        // 2. We need to find a converter for the element type in a list/array/map
        // 3. We have a domain model object that implements List/Map and has a converter itself!
        TypeConverterFactory factory = this.configuration.getTypeConverterFactory();
        TypeConverter<?> converter = null;
        Locale locale = bean.getContext().getRequest().getLocale();

        converter = factory.getTypeConverter(declaredType, locale);
        if (validationInfo != null && validationInfo.converter() != null) {
            // If a specific converter was requested and it's the same type as one we'd use
            // for the declared type, set the return type appropriately
            if (converter != null && validationInfo.converter().isAssignableFrom(converter.getClass())) {
                returnType = declaredType;
            }
            // Otherwise assume that it's a converter for the scalar type inside a collection
            else {
                returnType = scalarType;
            }
            converter = factory.getInstance(validationInfo.converter(), locale);
        }
        // Else, if we got a converter for the declared type (e.g. Foo implements List<Bar>)
        // then convert for the declared type
        else if (converter != null) {
            returnType = declaredType;
        }
        // Else look for a converter for the scalar type (Bar in List<Bar>)
        else {
            converter  = factory.getTypeConverter(scalarType, locale);
            returnType = scalarType;
        }

        log.debug("Converting ", values.length, " value(s) using ", (converter != null ?
            "converter " + converter.getClass().getName()
View Full Code Here

        // Dig up the type converter.  This gets a bit tricky because we need to handle
        // the following cases:
        // 1. We need to simply find a converter for the declared type of a simple property
        // 2. We need to find a converter for the element type in a list/array/map
        // 3. We have a domain model object that implements List/Map and has a converter itself!
        TypeConverterFactory factory = this.configuration.getTypeConverterFactory();
        TypeConverter<?> converter = null;
        Locale locale = bean.getContext().getRequest().getLocale();

        converter = factory.getTypeConverter(declaredType, locale);
        if (validationInfo != null && validationInfo.converter() != null) {
            // If a specific converter was requested and it's the same type as one we'd use
            // for the declared type, set the return type appropriately
            if (converter != null && validationInfo.converter().isAssignableFrom(converter.getClass())) {
                returnType = declaredType;
            }
            // Otherwise assume that it's a converter for the scalar type inside a collection
            else {
                returnType = scalarType;
            }
            converter = factory.getInstance(validationInfo.converter(), locale);
        }
        // Else, if we got a converter for the declared type (e.g. Foo implements List<Bar>)
        // then convert for the declared type
        else if (converter != null) {
            returnType = declaredType;
        }
        // Else look for a converter for the scalar type (Bar in List<Bar>)
        else {
            converter  = factory.getTypeConverter(scalarType, locale);
            returnType = scalarType;
        }

        log.debug("Converting ", values.length, " value(s) using ", (converter != null ?
            "converter " + converter.getClass().getName()
View Full Code Here

TOP

Related Classes of net.sourceforge.stripes.validation.TypeConverterFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.