diff options
Diffstat (limited to 'gnu/javax/swing/text/html/css/CSSColor.java')
-rw-r--r-- | gnu/javax/swing/text/html/css/CSSColor.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/gnu/javax/swing/text/html/css/CSSColor.java b/gnu/javax/swing/text/html/css/CSSColor.java index 381bcd5ed..57230f12a 100644 --- a/gnu/javax/swing/text/html/css/CSSColor.java +++ b/gnu/javax/swing/text/html/css/CSSColor.java @@ -40,6 +40,8 @@ package gnu.javax.swing.text.html.css; import java.awt.Color; import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; /** * Converts CSS color values into AWT Color values. @@ -131,4 +133,31 @@ public class CSSColor { return value; } + + /** + * Returns <code>true</code> if the specified value is a valid color value, + * <code>false</code> otherwise. + * + * @param val the value to check + * + * @return <code>true</code> if the specified value is a valid color value, + * <code>false</code> otherwise + */ + public static boolean isValidColor(String val) + { + boolean ret = false; + if (val.charAt(0) == '#') + ret = true; + else + { + Set colors = COLOR_MAP.keySet(); + for (Iterator i = colors.iterator(); i.hasNext() && ret == false;) + { + String color = (String) i.next(); + if (color.equalsIgnoreCase(val)) + ret = true; + } + } + return ret; + } } |