Class StringTrimmedResultSet
- java.lang.Object
-
- org.apache.commons.dbutils.wrappers.StringTrimmedResultSet
-
- All Implemented Interfaces:
InvocationHandler
public class StringTrimmedResultSet extends Object implements InvocationHandler
Wraps aResultSetto 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 resultSet = // somehow get a ResultSet; // Substitute wrapped ResultSet with additional behavior for real ResultSet resultSet = StringTrimmedResultSet.wrap(resultSet); // Pass wrapped ResultSet to processor List list = new BasicRowProcessor().toBeanList(resultSet);
-
-
Constructor Summary
Constructors Constructor Description StringTrimmedResultSet(ResultSet resultSet)Constructs a new instance ofStringTrimmedResultSetto wrap the specifiedResultSet.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Objectinvoke(Object proxy, Method method, Object[] args)Intercept calls to thegetString()andgetObject()methods and trim any Strings before they're returned.static ResultSetwrap(ResultSet resultSet)Wraps theResultSetin an instance of this class.
-
-
-
Constructor Detail
-
StringTrimmedResultSet
public StringTrimmedResultSet(ResultSet resultSet)
Constructs a new instance ofStringTrimmedResultSetto wrap the specifiedResultSet.- Parameters:
resultSet- ResultSet to wrap
-
-
Method Detail
-
wrap
public static ResultSet wrap(ResultSet resultSet)
Wraps theResultSetin an instance of this class. This is equivalent to:ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(resultSet));
- Parameters:
resultSet- TheResultSetto wrap.- Returns:
- wrapped ResultSet
-
invoke
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
Intercept calls to thegetString()andgetObject()methods and trim any Strings before they're returned.- Specified by:
invokein interfaceInvocationHandler- 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:
Throwable- error- See Also:
InvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])
-
-