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 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);
Constructor and Description |
---|
StringTrimmedResultSet(ResultSet rs)
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 rs)
Wraps the
ResultSet in an instance of this class. |
public StringTrimmedResultSet(ResultSet rs)
StringTrimmedResultSet
to wrap the specified ResultSet
.rs
- ResultSet to wrappublic static ResultSet wrap(ResultSet rs)
ResultSet
in an instance of this class. This is
equivalent to:
ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(rs));
rs
- 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 InvocationHandler
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 setThrowable
- errorInvocationHandler.invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
Copyright © 2002–2017 The Apache Software Foundation. All rights reserved.