public static Color toColor(Object value) throws ConversionException {
        if (value instanceof Color) {
            return (Color)value;
        } else if (value instanceof String &&
                   !StringUtils.isBlank((String)value)) {
            String color = ((String)value).trim();

            int[] components = new int[3];

            // check the size of the string
            int minlength = components.length * 2;
            if (color.length() < minlength) {
                throw new ConversionException("The value " + value +
                                              " can't be converted to a Color");
            }

            // remove the leading #
            if (color.startsWith("#")) {
                color = color.substring(1);
            }

            try {
                // parse the components
                for (int i = 0; i < components.length; i++) {
                    components[i] =
                            Integer.parseInt(color.substring(2 * i, 2 * i + 2),
                                             HEX_RADIX);
                }

                // parse the transparency
                int alpha;
                if (color.length() >= minlength + 2) {
                    alpha =
                            Integer.parseInt(color.substring(minlength, minlength +
                                                             2), HEX_RADIX);
                } else {
                    alpha = Color.black.getAlpha();
                }

                return new Color(components[0], components[1], components[2],
                                 alpha);
            } catch (Exception e) {
                throw new ConversionException("The value " + value +
                                              " can't be converted to a Color",
                                              e);
            }
        } else {
            throw new ConversionException("The value " + value +
                                          " can't be converted to a Color");
        }
    }