Add a parser for Color fields.

git-svn-id: https://samskivert.googlecode.com/svn/trunk@641 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
mdb
2002-03-08 02:07:58 +00:00
parent 4f65f77e81
commit dda33209b5
@@ -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));
}
}
});
}
}