Class StringTrimmedResultSet
java.lang.Object
org.apache.commons.dbutils.wrappers.StringTrimmedResultSet
- All Implemented Interfaces:
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 = new BasicRowProcessor().toBeanList(rs);
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final ProxyFactory
The factory to create proxies with.private final ResultSet
The wrapped result. -
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new instance ofStringTrimmedResultSet
to wrap the specifiedResultSet
. -
Method Summary
-
Field Details
-
factory
The factory to create proxies with. -
rs
The wrapped result.
-
-
Constructor Details
-
StringTrimmedResultSet
Constructs a new instance ofStringTrimmedResultSet
to wrap the specifiedResultSet
.- Parameters:
rs
- ResultSet to wrap
-
-
Method Details
-
wrap
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
Intercept calls to thegetString()
andgetObject()
methods and trim any Strings before they're returned.- Specified by:
invoke
in 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:
-