com.ricebridge.data.sc
Class DefaultStringConverter

java.lang.Object
  extended bycom.ricebridge.data.sc.StringConverterSupport
      extended bycom.ricebridge.data.sc.DefaultStringConverter
All Implemented Interfaces:
StringConverter
Direct Known Subclasses:
LoadBeansTest.DateConverter, PerformanceTest.DateStringConverter, SaveBeansTest.DateConverter

public abstract class DefaultStringConverter
extends StringConverterSupport

Convenience class for implementing the StringConverter interface quickly and easily.

The StringConverter interface requires that you handle the default parameter option to the makeObject and makeString methods. This means you have to check for errors and create a DataException reporting the error, or return the default value. All this hard is done for you by the DefaultStringConverter class.

All you have to do is implement the makeObjectImpl(String) and makeStringImpl(Object) methods, and you don't have to worry about handling the default option at all.

The Source Code of this Java class is available under a BSD-style license.


Constructor Summary
DefaultStringConverter()
           
 
Method Summary
protected  Object makeDefaultObjectImpl()
          Return an empty string.
protected  String makeDefaultStringImpl()
          Return an empty string.
protected abstract  Object makeObjectImpl(String pValue)
          Implement this method to create an object based on a textual representation.
protected  Object makeObjectImpl(String pValue, boolean pUseDefault)
          Calls the simpler makeObjectImpl(String) method, and handles the default value automatically.
protected abstract  String makeStringImpl(Object pValue)
          Implement this method to produce a textual representation of an object.
protected  String makeStringImpl(Object pValue, boolean pUseDefault)
          Calls the simpler makeStringImpl(Object) method, and handles the default value automatically.
 
Methods inherited from class com.ricebridge.data.sc.StringConverterSupport
makeDefaultObject, makeDefaultString, makeObject, makeString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultStringConverter

public DefaultStringConverter()
Method Detail

makeObjectImpl

protected Object makeObjectImpl(String pValue,
                                boolean pUseDefault)
                         throws Exception
Calls the simpler makeObjectImpl(String) method, and handles the default value automatically.

Specified by:
makeObjectImpl in class StringConverterSupport
Throws:
Exception
See Also:
StringConverterSupport.makeObject(java.lang.String, boolean), StringConverter.makeObject(java.lang.String, boolean)

makeDefaultObjectImpl

protected Object makeDefaultObjectImpl()
Return an empty string.

Override this method if you need a different default object.

Specified by:
makeDefaultObjectImpl in class StringConverterSupport
See Also:
StringConverterSupport.makeDefaultObject(), StringConverter.makeDefaultObject()

makeStringImpl

protected String makeStringImpl(Object pValue,
                                boolean pUseDefault)
                         throws Exception
Calls the simpler makeStringImpl(Object) method, and handles the default value automatically.

Specified by:
makeStringImpl in class StringConverterSupport
Throws:
Exception
See Also:
StringConverterSupport.makeString(java.lang.Object, boolean), StringConverter.makeString(java.lang.Object, boolean)

makeDefaultStringImpl

protected String makeDefaultStringImpl()
Return an empty string.

Override this method if you need a different default text.

Specified by:
makeDefaultStringImpl in class StringConverterSupport
See Also:
StringConverterSupport.makeDefaultString(), StringConverter.makeDefaultString()

makeObjectImpl

protected abstract Object makeObjectImpl(String pValue)
                                  throws Exception
Implement this method to create an object based on a textual representation.

If an error occurs, just throw an Exception.

Parameters:
pValue - textual representation
Throws:
Exception

makeStringImpl

protected abstract String makeStringImpl(Object pValue)
                                  throws Exception
Implement this method to produce a textual representation of an object.

If an error occurs, just throw an Exception.

Parameters:
pValue - object
Throws:
Exception


Copyright © 2004-2005 Ricebridge