Class StringTrimmedResultSet
- java.lang.Object
-
- org.apache.commons.dbutils.wrappers.StringTrimmedResultSet
-
- All Implemented Interfaces:
java.lang.reflect.InvocationHandler
public class StringTrimmedResultSet extends java.lang.Object implements java.lang.reflect.InvocationHandler
Wraps aResultSet
to trim strings returned by thegetString()
andgetObject()
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 = new BasicRowProcessor().toBeanList(rs);
-
-
Field Summary
Fields Modifier and Type Field Description private static ProxyFactory
factory
The factory to create proxies with.private java.sql.ResultSet
rs
The wrapped result.
-
Constructor Summary
Constructors Constructor Description StringTrimmedResultSet(java.sql.ResultSet rs)
Constructs a new instance ofStringTrimmedResultSet
to wrap the specifiedResultSet
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args)
Intercept calls to thegetString()
andgetObject()
methods and trim any Strings before they're returned.static java.sql.ResultSet
wrap(java.sql.ResultSet rs)
Wraps theResultSet
in an instance of this class.
-
-
-
Field Detail
-
factory
private static final ProxyFactory factory
The factory to create proxies with.
-
rs
private final java.sql.ResultSet rs
The wrapped result.
-
-
Method Detail
-
wrap
public static java.sql.ResultSet wrap(java.sql.ResultSet rs)
Wraps theResultSet
in an instance of this class. This is equivalent to:ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs));
- Parameters:
rs
- TheResultSet
to wrap.- Returns:
- wrapped ResultSet
-
invoke
public java.lang.Object invoke(java.lang.Object proxy, java.lang.reflect.Method method, java.lang.Object[] args) throws java.lang.Throwable
Intercept calls to thegetString()
andgetObject()
methods and trim any Strings before they're returned.- Specified by:
invoke
in interfacejava.lang.reflect.InvocationHandler
- Parameters:
proxy
- Not used; all method calls go to the internal result setmethod
- The method to invoke on the result setargs
- The arguments to pass to the result set- Returns:
- string trimmed result
- Throws:
java.lang.Throwable
- error- See Also:
InvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
-
-