private static String encode(Object value) {
        if (value instanceof String) {
            return (String)value;
        }
        if (value instanceof Boolean ||
            value instanceof Integer ||
            value instanceof Long ||
            value instanceof Float ||
            value instanceof Double)
        {
            return value.toString();
        }
        if (value instanceof Date) {
            try {
                return dateFormatter.format((Date)value);
            }
            catch (Exception ex) {
                Log.debug("An exception occurred while trying format value {} as a date.", value, ex);
            }
        }
        if (value instanceof Color) {
            Color color = (Color)value;
            return color.getRed() +","+ color.getGreen() +","+ color.getBlue();
        }
        if (value instanceof Class) {
            return ((Class)value).getName();
        }
        return null;
    }
Encodes a bean property value as a String. If the object type is not
supported, null will be returned.

@param value an Object to encode in a String representation.
@return the encoded bean.
xmppserver/src/main/java/org/jivesoftware/util/BeanUtils.java