com.kiwisoft.utils.format
Interface ObjectFormat

All Known Implementing Classes:
DefaultObjectFormat

public interface ObjectFormat

Interface class for displaying objects in UI text components like table cells, lists, labels and text fields.

Version:
$Revision: 1.2 $, $Date: 2004/09/30 18:09:26 $
Author:
Stefan Stiller

Field Summary
static java.lang.String DEFAULT
          Used for default formats.
 
Method Summary
 boolean canFormat(java.lang.Class aClass)
           
 boolean canParse(java.lang.Class aClass)
           
 java.lang.String format(java.lang.Object value)
          Returns the String representing the specified value.
 java.lang.String getGroup()
          The name of the group the format belongs to.
 int getHorizontalAlignment(java.lang.Object value)
          Returns the horizontal alignment of the formatted text.
 javax.swing.Icon getIcon(java.lang.Object value)
          Returns the icon for the specified value;
 java.lang.String getName()
          Returns the name of the format.
 java.lang.Object parse(java.lang.String value, java.lang.Class targetClass)
          Returns the Object created from the specified String.
 

Field Detail

DEFAULT

public static final java.lang.String DEFAULT
Used for default formats.

See Also:
getName()
Method Detail

getName

public java.lang.String getName()
Returns the name of the format. Return "Default" if the format should be the default format for the handled classes (works only if no default format has already been installed).

Returns:
The name of the format.

getGroup

public java.lang.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.

Returns:
The name of the format group. If null the format will appear in the root menu.

canFormat

public boolean canFormat(java.lang.Class aClass)
Returns:
true if the format can format objects of the specified class.
See Also:
format(Object)

canParse

public boolean canParse(java.lang.Class aClass)
Returns:
true if the format can create objects of the specified class from String objects.
See Also:
parse(String, Class)

getHorizontalAlignment

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

Parameters:
value - The unformated value.
Returns:
One of the following constants defined in SwingConstants: LEFT, CENTER, RIGHT, LEADING. TRAILING.

getIcon

public javax.swing.Icon getIcon(java.lang.Object value)
Returns the icon for the specified value;

Parameters:
value - The unformated value.
Returns:
The icon for the specified value (can be null).

format

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

Parameters:
value - The object which should be formated.
Returns:
The string representing the specified object.
See Also:
canFormat(Class)

parse

public java.lang.Object parse(java.lang.String value,
                              java.lang.Class targetClass)
Returns the Object created from the specified String. The method may throw an RuntimeException if the String is invalid.

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:
The Object created from the String.
See Also:
canParse(Class)