org.progeeks.meta.format
Class FormatRegistry

java.lang.Object
  extended by org.progeeks.meta.TypeRegistry
      extended by org.progeeks.meta.format.FormatRegistry

public class FormatRegistry
extends TypeRegistry

Matches types for PropertyFormats. This is essentially a thin wrapper around a TypeRegistry containing property format objects. This class can provide advanced behavior in some cases by automatically resolving formatters for multi-value types and such.

Version:
$Revision: 1.6 $
Author:
Paul Speed

Constructor Summary
FormatRegistry()
           
 
Method Summary
 java.lang.String format(MetaObject value)
          Convenience method for formatting a MetaObject value.
 java.lang.String format(java.lang.Object value, PropertyType type)
          Convenience method for formatting a value.
 PropertyFormat getFormat(PropertyType type)
          Returns a PropertyFormat object for the specified PropertyType.
protected  PropertyFormat getListFormat(ListPropertyType type)
          Searches for an appropriate formatter for the list type, but will create a default list format if one is not found.
 boolean hasFormat(PropertyType type)
          Returns true if the specified type has a registered format or registered default format.
 boolean hasSpecificFormat(PropertyType type)
          Returns true if the specified type has a specifically registered format.
 void registerDefaultFormat(java.lang.Class type, PropertyFormat format)
          Registers a PropertyFormat object that will handle all PropertyTypes of the specified base class when no more specific PropertyFormat object is found.
 void registerFormat(PropertyType type, PropertyFormat format)
          Registers a specific PropertyFormat object for the specified type.
 
Methods inherited from class org.progeeks.meta.TypeRegistry
get, get, get, get, getDefault, getDirectMatch, getValueForObject, put, putDefault
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FormatRegistry

public FormatRegistry()
Method Detail

registerFormat

public void registerFormat(PropertyType type,
                           PropertyFormat format)
Registers a specific PropertyFormat object for the specified type.


registerDefaultFormat

public void registerDefaultFormat(java.lang.Class type,
                                  PropertyFormat format)
Registers a PropertyFormat object that will handle all PropertyTypes of the specified base class when no more specific PropertyFormat object is found.


hasFormat

public boolean hasFormat(PropertyType type)
Returns true if the specified type has a registered format or registered default format. getFormat() always returns a PropertyFormat object even if one has not been registered. This method allows a caller to determine if it is a custom format or not.


hasSpecificFormat

public boolean hasSpecificFormat(PropertyType type)
Returns true if the specified type has a specifically registered format. This will return false for types that resolve to a default registered format for the type's base class. getFormat() always returns a PropertyFormat object even if one has not been registered. This method allows a caller to determine if it is a custom format or not.


getFormat

public PropertyFormat getFormat(PropertyType type)
Returns a PropertyFormat object for the specified PropertyType. This method always returns a valid PropertyFormat object regardless of the type provided. In the case where not specific formatter is found and no default formatter is found, a DefaultPropertyFormat instance is returned that will use toString() and introspection to implement the PropertyFormat functionality.


getListFormat

protected PropertyFormat getListFormat(ListPropertyType type)
Searches for an appropriate formatter for the list type, but will create a default list format if one is not found. The default list formmatter will wrap a PropertyFormat object returned by a getPropertyFormat() call for the ListPropertyTypes internal value type.


format

public java.lang.String format(java.lang.Object value,
                               PropertyType type)
Convenience method for formatting a value.


format

public java.lang.String format(MetaObject value)
Convenience method for formatting a MetaObject value.



Copyright © 2002-2003 Paul Speed. All Rights Reserved.