Class InMemoryMetadataResultSet

java.lang.Object
org.dbunit.database.InMemoryMetadataResultSet
All Implemented Interfaces:
InvocationHandler

public final class InMemoryMetadataResultSet extends Object implements InvocationHandler
An in-memory ResultSet, backed by rows copied out of one or more source result sets ahead of time. It supports only the handful of ResultSet/ResultSetMetaData methods dbunit itself calls against an IMetadataHandler result - next(), getString(int/String), getInt(int/String), getMetaData()/ getColumnCount(), close(), plus equals()/hashCode()/ toString() for safe use as a log argument or map key - since implementing the rest of ResultSet's ~150 methods would serve no caller. Any other method throws UnsupportedOperationException.

A single instance answers both ResultSet calls and, since getMetaData() returns the proxy itself, the ResultSetMetaData calls made against its result.

Since:
3.5.0
  • Method Details

    • merge

      public static ResultSet merge(List<ResultSet> sources) throws SQLException
      Copies every row of each given result set, closing each as it is consumed, and returns a single merged ResultSet positioned before the first row.
      Parameters:
      sources - The result sets to merge, in the order their rows should appear.
      Returns:
      The merged result set.
      Throws:
      SQLException - if a source result set cannot be read.
    • filter

      public static ResultSet filter(ResultSet source, InMemoryMetadataResultSet.RowFilter filter) throws SQLException
      Copies the rows of the given result set that match the given filter, closing it as it is consumed, and returns a filtered ResultSet positioned before the first row.
      Parameters:
      source - The result set to filter.
      filter - The filter a row must match to be kept.
      Returns:
      The filtered result set.
      Throws:
      SQLException - if the source result set cannot be read.
    • invoke

      public Object invoke(Object proxy, Method method, Object[] args)
      Answers exactly the methods documented on this class; any other method throws UnsupportedOperationException.
      Specified by:
      invoke in interface InvocationHandler