Package org.geoserver.wps.transmute

Source Code of org.geoserver.wps.transmute.DoubleTransmuter

/* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
* This code is licensed under the GPL 2.0 license, available at the root
* application directory.
*/

package org.geoserver.wps.transmute;

import org.geoserver.wps.WPSException;

/**
* LiteralTransmuter for double precission floating point values
*
* @author Lucas Reed, Refractions Research Inc
*/
public class DoubleTransmuter implements LiteralTransmuter {
    /**
     * @see LiteralTransmuter#decode(String)
     */
    public Double decode(String encoded) {
        Double decoded;

        try {
            decoded = Double.valueOf(encoded);
        } catch(NumberFormatException e) {
            throw new WPSException("InvalidParameterType", "Could not convert paramter to object.");
        }

        return decoded;
    }

    /**
     * @see Transmuter#getType()
     */
    public Class<?> getType() {
        return Double.class;
    }

    /**
     * @see LiteralTransmuter#encode(Object)
     */
    public String encode(Object value) {
        return ((Double)value).toString();
    }

    /**
     * @see LiteralTransmuter#getEncodedType()
     */
    public String getEncodedType() {
        return "xs:double";
    }
}
TOP

Related Classes of org.geoserver.wps.transmute.DoubleTransmuter

TOP
Copyright © 2018 www.massapi.com. 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.