01: package abbot.script.parsers;
02:
03: import java.awt.Color;
04:
05: /** Convert a {@link String} into a {@link Color}. */
06: public class ColorParser implements Parser {
07: public ColorParser() {
08: }
09:
10: public Object parse(String input) throws IllegalArgumentException {
11: // NOTE: may want to provide additional parsing, e.g.
12: // #00CC00
13: // R:G:B
14: // Color.toString (although this is not guaranteed to be consistent)
15: // or some other format
16: Color c = Color.getColor(input);
17: if (c != null)
18: return c;
19: throw new IllegalArgumentException("Can't convert '" + input
20: + "' to java.awt.Color");
21: }
22: }
|