view flys-artifacts/src/main/java/de/intevation/flys/artifacts/datacage/templating/TypeConverter.java @ 4740:fb135e1dfa35

Added 'type' attribute to <dc:variable/> element. If an optional 'type' attribute is given the result of the XPATH expression is interpreted as this type. Valid values are 'number', 'bool', 'node' and 'nodeset'. All other defaults to 'string' which also is the default if nor type is given.
author Sascha L. Teichmann <teichmann@intevation.de>
date Wed, 02 Jan 2013 15:31:53 +0100
parents b81626b10cb7
children
line wrap: on
line source
package de.intevation.flys.artifacts.datacage.templating;

public class TypeConverter
{
    private TypeConverter() {
    }

    public static Object convert(Object object, String type) {

        if (type == null) {
            return object;
        }

        if ("Integer".equals(type)) {
            return Integer.valueOf(object.toString());
        }

        if ("Double".equals(type)) {
            return Double.valueOf(object.toString());
        }

        if ("String".equals(type)) {
            return object.toString();
        }

        // TODO: Add more types

        return object;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org