You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by jw...@apache.org on 2007/11/06 01:39:06 UTC
svn commit: r592207 -
/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
Author: jwaldman
Date: Mon Nov 5 16:39:06 2007
New Revision: 592207
URL: http://svn.apache.org/viewvc?rev=592207&view=rev
Log:
TRINIDAD-774 support for static colors in a tag
Changed TagUtils.java to add a getColor(String) method that can be called from a Tag class (via the TrinidadComponentTagGenerator in the plugins).
Modified:
myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
Modified: myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java?rev=592207&r1=592206&r2=592207&view=diff
==============================================================================
--- myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java (original)
+++ myfaces/trinidad/trunk/trinidad/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java Mon Nov 5 16:39:06 2007
@@ -228,6 +228,34 @@
}
/**
+ * Takes in a string that is a sequence of hex color codes, converts it to a
+ * java.awt.Color object and returns it.
+ * @throws ParseException In case of any parse errors upon such conversion.
+ */
+ public static Color getColor(String value) throws ParseException
+ {
+ if (value == null)
+ return null;
+
+ String colorCode = value.toString();
+
+ // If we do not have correct starter, stop here
+ if (!colorCode.startsWith("#"))
+ {
+ throw new ParseException(_LOG.getMessage(
+ "COLOR_CODE_DOES_NOT_START_WITH_POUNDSIGN",
+ new Object[]{colorCode, value}), 0);
+ }
+
+ // Allow NumberFormatException (RTE) to propogate as is, or transform to JspException ?.
+ int rgb = Integer.parseInt(colorCode.substring(1), 16);
+
+ // CSSUtils used to cache and re-use color. Revisit if found required.
+ return new Color(rgb);
+
+ }
+
+ /**
* Takes a string that is a composite of tokens, extracts tokens delimited
* by any whitespace character sequence combination and returns a String
* array of such tokens.