org.xwiki.properties.internal.converter
Class ColorConverter

java.lang.Object
  extended by org.xwiki.properties.converter.AbstractConverter
      extended by org.xwiki.properties.internal.converter.ColorConverter
All Implemented Interfaces:
Converter

@Component
@Named(value="java.awt.Color")
@Singleton
public class ColorConverter
extends AbstractConverter

Bean Utils converter that converts a value into an Color object.

Since:
2.0M2
Version:
$Id$

Constructor Summary
ColorConverter()
           
 
Method Summary
protected  java.lang.String convertToString(java.lang.Object value)
          Convert the input object into a String.
protected  java.awt.Color convertToType(java.lang.reflect.Type type, java.lang.Object value)
          Convert the input object into an output object of the specified type.
 java.awt.Color parse(java.lang.String value)
          Convert a String in Color.
protected  java.awt.Color parseHtml(java.lang.String value)
          Parsers a String in the form "#xxxxxx" into an SWT RGB class.
protected  java.awt.Color parseRGB(java.lang.String value)
          Parsers a String in the form "x, y, z" into an SWT RGB class.
 
Methods inherited from class org.xwiki.properties.converter.AbstractConverter
convert, convertToType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorConverter

public ColorConverter()
Method Detail

convertToType

protected java.awt.Color convertToType(java.lang.reflect.Type type,
                                       java.lang.Object value)
Convert the input object into an output object of the specified type.

Typical implementations will provide a minimum of String --> type conversion.

Overrides:
convertToType in class AbstractConverter
Parameters:
type - Data type to which this value should be converted.
value - The input value to be converted.
Returns:
The converted value.
See Also:
AbstractConverter.convertToType(java.lang.reflect.Type, Object)

convertToString

protected java.lang.String convertToString(java.lang.Object value)
Convert the input object into a String.

N.B.This implementation simply uses the value's toString() method and should be overriden if a more sophisticated mechanism for conversion to a String is required.

Overrides:
convertToString in class AbstractConverter
Parameters:
value - The input value to be converted.
Returns:
the converted String value.
See Also:
org.apache.commons.beanutils.converters.AbstractConverter#convertToString(java.lang.Object)

parseRGB

protected java.awt.Color parseRGB(java.lang.String value)
Parsers a String in the form "x, y, z" into an SWT RGB class.

Parameters:
value - the color as String
Returns:
RGB

parseHtml

protected java.awt.Color parseHtml(java.lang.String value)
Parsers a String in the form "#xxxxxx" into an SWT RGB class.

Parameters:
value - the color as String
Returns:
RGB

parse

public java.awt.Color parse(java.lang.String value)
Convert a String in Color.

Parameters:
value - the String to parse
Returns:
the Color


Copyright © 2004-2011 XWiki. All Rights Reserved.