com.kiwisoft.utils.format
Class DefaultObjectFormat

java.lang.Object
  extended bycom.kiwisoft.utils.format.DefaultObjectFormat
All Implemented Interfaces:
ObjectFormat, TextFormat

public class DefaultObjectFormat
extends Object
implements TextFormat

Default implementation of ObjectFormat interface. Uses Object.toString() to format the objects. This class can format all objects.

Version:
$Revision: 1.3 $, $Date: 2006/03/18 15:54:03 $
Author:
Stefan Stiller
See Also:
ObjectFormat

Field Summary
 
Fields inherited from interface com.kiwisoft.utils.format.ObjectFormat
DEFAULT
 
Constructor Summary
DefaultObjectFormat(String name)
           
 
Method Summary
 boolean canFormat(Class aClass)
          Returns if this class can format object of the specified class.
 boolean canParse(Class aClass)
          Returns if the format can create objects of the specified class from String objects.
 String format(Object value)
          Returns the String representing the specified value.
 String getGroup()
          The name of the group the format belongs to.
 int getHorizontalAlignment(Object value)
          Returns the horizontal alignment of the formatted text.
 Icon getIcon(Object value)
          Returns the icon for the specified value;
 String getName()
          Returns the name of this format.
 Object parse(String value, Class targetClass)
          Returns the Object created from the specified String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultObjectFormat

public DefaultObjectFormat(String name)
Parameters:
name - The name of the format.
Method Detail

getName

public String getName()
Returns the name of this format.

Specified by:
getName in interface ObjectFormat
Returns:
The name of the format.

getGroup

public String getGroup()
The name of the group the format belongs to. The group defines the sub menu under which the format will appear in the context menu.

Specified by:
getGroup in interface ObjectFormat
Returns:
null.

canFormat

public boolean canFormat(Class aClass)
Returns if this class can format object of the specified class.

Specified by:
canFormat in interface ObjectFormat
Parameters:
aClass - The class of the objects which should be formated.
Returns:
Always true.
See Also:
format(Object)

canParse

public boolean canParse(Class aClass)
Returns if the format can create objects of the specified class from String objects.

Specified by:
canParse in interface ObjectFormat
Parameters:
aClass - The class of the objects which should be created.
Returns:
Always false.
See Also:
parse(String, Class)

format

public String format(Object value)
Returns the String representing the specified value.

Specified by:
format in interface TextFormat
Parameters:
value - The object which should be formated.
Returns:
null if value is null otherwise the value of value.toString().
See Also:
ObjectFormat.canFormat(Class)

parse

public Object parse(String value,
                    Class targetClass)
Returns the Object created from the specified String.

Specified by:
parse in interface TextFormat
Parameters:
value - The String which should be parsed.
targetClass - The Class the return value should have. Can be ignored if the format handles only one class.
Returns:
This method always throws an UnsupportedOperationException.
See Also:
ObjectFormat.canParse(Class)

getIcon

public Icon getIcon(Object value)
Returns the icon for the specified value;

Specified by:
getIcon in interface TextFormat
Parameters:
value - The unformated value.
Returns:
Always null.

getHorizontalAlignment

public int getHorizontalAlignment(Object value)
Returns the horizontal alignment of the formatted text.

Specified by:
getHorizontalAlignment in interface TextFormat
Parameters:
value - The unformated value.
Returns:
Always SwingConstants.LEADING