Package org.geoserver.wms.kvp

Source Code of org.geoserver.wms.kvp.ColorKvpParser

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

import org.geoserver.ows.KvpParser;
import org.vfny.geoserver.wms.WmsException;
import java.awt.Color;


/**
* Parses kvp of hte form <key>=<hex color value>.
*
* @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
*
*/
public class ColorKvpParser extends KvpParser {
    public ColorKvpParser(String key) {
        super(key, Color.class);
    }

    public Object parse(String value) throws Exception {
        try {
            return Color.decode(value);
        } catch (NumberFormatException nfe) {
            throw new WmsException("BGCOLOR " + value
                + " incorrectly specified (0xRRGGBB format expected)");
        }
    }
}
TOP

Related Classes of org.geoserver.wms.kvp.ColorKvpParser

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.