Class StringTrimmedResultSet

  • All Implemented Interfaces:
    InvocationHandler

    public class StringTrimmedResultSet
    extends Object
    implements 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 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 Detail

      • StringTrimmedResultSet

        public StringTrimmedResultSet​(ResultSet resultSet)
        Constructs a new instance of StringTrimmedResultSet to wrap the specified ResultSet.
        Parameters:
        resultSet - ResultSet to wrap
    • Method Detail

      • wrap

        public static ResultSet wrap​(ResultSet resultSet)
        Wraps the ResultSet in an instance of this class. This is equivalent to:
         ProxyFactory.instance().createResultSet(new StringTrimmedResultSet(resultSet));
         
        Parameters:
        resultSet - The ResultSet to wrap.
        Returns:
        wrapped ResultSet