public class StringTrimmedResultSet extends Object implements InvocationHandler
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 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 and Description |
|---|
StringTrimmedResultSet(ResultSet resultSet)
Constructs a new instance of
StringTrimmedResultSet
to wrap the specified ResultSet. |
| Modifier and Type | Method and Description |
|---|---|
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 resultSet)
Wraps the
ResultSet in an instance of this class. |
public StringTrimmedResultSet(ResultSet resultSet)
StringTrimmedResultSet
to wrap the specified ResultSet.resultSet - ResultSet to wrappublic static ResultSet wrap(ResultSet resultSet)
ResultSet in an instance of this class. This is
equivalent to:
ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(resultSet));
resultSet - The ResultSet to wrap.public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
getString() and
getObject() methods and trim any Strings before they're
returned.invoke in interface InvocationHandlerproxy - 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 setThrowable - errorInvocationHandler.invoke(Object, java.lang.reflect.Method, Object[])Copyright © 2002–2023 The Apache Software Foundation. All rights reserved.