From dda33209b5baa5c2446b0374ccf63f138062e61f Mon Sep 17 00:00:00 2001 From: mdb Date: Fri, 8 Mar 2002 02:07:58 +0000 Subject: [PATCH] Add a parser for Color fields. git-svn-id: https://samskivert.googlecode.com/svn/trunk@641 6335cc39-0255-0410-8fd6-9bcaacd3b74c --- .../java/com/samskivert/util/ValueMarshaller.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/projects/samskivert/src/java/com/samskivert/util/ValueMarshaller.java b/projects/samskivert/src/java/com/samskivert/util/ValueMarshaller.java index ad6a4735..21487dab 100644 --- a/projects/samskivert/src/java/com/samskivert/util/ValueMarshaller.java +++ b/projects/samskivert/src/java/com/samskivert/util/ValueMarshaller.java @@ -1,8 +1,9 @@ // -// $Id: ValueMarshaller.java,v 1.2 2001/12/11 01:38:08 mdb Exp $ +// $Id: ValueMarshaller.java,v 1.3 2002/03/08 02:07:58 mdb Exp $ package com.samskivert.util; +import java.awt.Color; import java.util.HashMap; /** @@ -87,5 +88,16 @@ public class ValueMarshaller return StringUtil.parseStringArray(source); } }); + + // and Color objects + _parsers.put(Color.class, new Parser() { + public Object parse (String source) throws Exception { + if (source.length() == 0 || source.charAt(0) != '#') { + return new Color(Integer.parseInt(source, 16)); + } else { + return new Color(Integer.parseInt(source.substring(1), 16)); + } + } + }); } }