org.apache.cocoon.forms.datatype.convertor
Class BeanConvertor

java.lang.Object
  extended byorg.apache.cocoon.forms.datatype.convertor.BeanConvertor
All Implemented Interfaces:
Convertor

public class BeanConvertor
extends Object
implements Convertor

Converts String representation of beans to bean instances and vice versa.

Sometimes the toString() method doesn't give a good representation of a Java Bean suited for selection list IDs. For this an optional <fd:id-path>jx-path</fd:id-path> attribute can be specified to have this convertor to use a different string representation.

Version:
$Id: BeanConvertor.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Nested Class Summary
 
Nested classes inherited from class org.apache.cocoon.forms.datatype.convertor.Convertor
Convertor.FormatCache
 
Constructor Summary
BeanConvertor(String className, String idPath)
          Construct a new BeanConvertor for a class
 
Method Summary
 ConversionResult convertFromString(String value, Locale locale, Convertor.FormatCache formatCache)
          Converts string representation into the object of convertor's type.
 String convertToString(Object value, Locale locale, Convertor.FormatCache formatCache)
           
 void generateSaxFragment(ContentHandler contentHandler, Locale locale)
          We do not enerate any SAX events
 Class getTypeClass()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanConvertor

public BeanConvertor(String className,
                     String idPath)
Construct a new BeanConvertor for a class

Parameters:
className - The package-qualified name of the class implementing the typesafe enum pattern.
idPath - Path to the identity field of the bean
Throws:
CascadingRuntimeException - If the class cannot be found
Method Detail

getTypeClass

public Class getTypeClass()
Specified by:
getTypeClass in interface Convertor
See Also:
Convertor.getTypeClass()

convertFromString

public ConversionResult convertFromString(String value,
                                          Locale locale,
                                          Convertor.FormatCache formatCache)
Description copied from interface: Convertor
Converts string representation into the object of convertor's type.

Specified by:
convertFromString in interface Convertor
Parameters:
formatCache - can be null if not needed
See Also:
Convertor.convertFromString(java.lang.String, java.util.Locale, org.apache.cocoon.forms.datatype.convertor.Convertor.FormatCache)

convertToString

public String convertToString(Object value,
                              Locale locale,
                              Convertor.FormatCache formatCache)
Specified by:
convertToString in interface Convertor
See Also:
Convertor.convertToString(java.lang.Object, java.util.Locale, org.apache.cocoon.forms.datatype.convertor.Convertor.FormatCache)

generateSaxFragment

public void generateSaxFragment(ContentHandler contentHandler,
                                Locale locale)
                         throws SAXException
We do not enerate any SAX events

Specified by:
generateSaxFragment in interface Convertor
Parameters:
contentHandler - The contentHandler
locale - The locale
Throws:
SAXException - Just in case of failure that could never happen


Copyright 1999-2008 The Apache Software Foundation. All Rights Reserved.