org.apache.commons.dbutils.wrappers
Class StringTrimmedResultSet

java.lang.Object
  extended byorg.apache.commons.dbutils.wrappers.StringTrimmedResultSet
All Implemented Interfaces:
InvocationHandler

public class StringTrimmedResultSet
extends Object
implements InvocationHandler

Wraps a ResultSet to trim strings returned by the getString() and getObject() methods.

Usage Example: This example shows how to decorate ResultSets so processing continues as normal but all Strings are trimmed before being returned from the ResultSet.

 ResultSet rs = // somehow get a ResultSet;
 
 // Substitute wrapped ResultSet with additional behavior for real ResultSet
 rs = StringTrimmedResultSet.wrap(rs);
 
 // Pass wrapped ResultSet to processor
 List list = BasicRowProcessor.instance().toBeanList(rs);
 

Version:
$Id: StringTrimmedResultSet.java,v 1.1 2003/11/02 19:15:23 dgraham Exp $
Author:
Steven Caswell, David Graham

Field Summary
private static ProxyFactory factory
          The factory to create proxies with.
private  ResultSet rs
          The wrapped result.
 
Constructor Summary
StringTrimmedResultSet(ResultSet rs)
          Constructs a new instance of StringTrimmedResultSet to wrap the specified ResultSet.
 
Method Summary
 Object invoke(Object proxy, Method method, Object[] args)
          Intercept calls to the getString() and getObject() methods and trim any Strings before they're returned.
static ResultSet wrap(ResultSet rs)
          Wraps the ResultSet in an instance of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

factory

private static final ProxyFactory factory
The factory to create proxies with.


rs

private final ResultSet rs
The wrapped result.

Constructor Detail

StringTrimmedResultSet

public StringTrimmedResultSet(ResultSet rs)
Constructs a new instance of StringTrimmedResultSet to wrap the specified ResultSet.

Method Detail

wrap

public static ResultSet wrap(ResultSet rs)
Wraps the ResultSet in an instance of this class. This is equivalent to:
 ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs));
 

Parameters:
rs - The ResultSet to wrap.

invoke

public Object invoke(Object proxy,
                     Method method,
                     Object[] args)
              throws Throwable
Intercept calls to the getString() and getObject() methods and trim any Strings before they're returned.

Specified by:
invoke in interface InvocationHandler
Throws:
Throwable
See Also:
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])