01: /* Copyright (c) 2001 - 2007 TOPP - www.openplans.org. All rights reserved.
02: * This code is licensed under the GPL 2.0 license, availible at the root
03: * application directory.
04: */
05: package org.geoserver.wms.kvp;
06:
07: import org.geoserver.ows.KvpParser;
08: import org.vfny.geoserver.wms.WmsException;
09: import java.awt.Color;
10:
11: /**
12: * Parses kvp of hte form <key>=<hex color value>.
13: *
14: * @author Justin Deoliveira, The Open Planning Project, jdeolive@openplans.org
15: *
16: */
17: public class ColorKvpParser extends KvpParser {
18: public ColorKvpParser(String key) {
19: super (key, Color.class);
20: }
21:
22: public Object parse(String value) throws Exception {
23: try {
24: return Color.decode(value);
25: } catch (NumberFormatException nfe) {
26: throw new WmsException(
27: "BGCOLOR "
28: + value
29: + " incorrectly specified (0xRRGGBB format expected)");
30: }
31: }
32: }
|