org.dbunit.database
Class PrimaryKeyFilter

java.lang.Object
  extended by org.dbunit.dataset.filter.AbstractTableFilter
      extended by org.dbunit.database.PrimaryKeyFilter
All Implemented Interfaces:
ITableFilter

public class PrimaryKeyFilter
extends AbstractTableFilter

Filter a table given a map of the allowed rows based on primary key values.
It uses a depth-first algorithm (although not recursive - it might be refactored in the future) to define which rows are allowed, as well which rows are necessary (and hence allowed) because of dependencies with the allowed rows.
NOTE: multi-column primary keys are not supported at the moment. TODO: test cases

Since:
Sep 9, 2005
Version:
$Revision: 499 $
Author:
Felipe Leme

Field Summary
protected  org.apache.commons.logging.Log logger
           
 
Constructor Summary
PrimaryKeyFilter(IDatabaseConnection connection, java.util.Map allowedPKs, boolean reverseDependency)
          Default constructor, it takes as input a map with desired rows in a final dataset; the filter will ensure that the rows necessary by these initial rows are also allowed (and so on...).
 
Method Summary
 void edgeAdded(ForeignKeyRelationshipEdge edge)
           
 boolean isValidName(java.lang.String tableName)
          Returns true if specified table is allowed by this filter.
 ITableIterator iterator(IDataSet dataSet, boolean reversed)
          Returns iterator of tables allowed by this filter from the specified dataset.
 void nodeAdded(java.lang.Object node)
           
 
Methods inherited from class org.dbunit.dataset.filter.AbstractTableFilter
accept, getTableNames
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final org.apache.commons.logging.Log logger
Constructor Detail

PrimaryKeyFilter

public PrimaryKeyFilter(IDatabaseConnection connection,
                        java.util.Map allowedPKs,
                        boolean reverseDependency)
Default constructor, it takes as input a map with desired rows in a final dataset; the filter will ensure that the rows necessary by these initial rows are also allowed (and so on...).

Parameters:
connection - database connection
allowedPKs - map of allowed rows, based on the primary keys (key is the name of a table; value is a Set with allowed primary keys for that table)
reverseDependency - flag indicating if the rows that depend on a row should also be allowed by the filter
Method Detail

nodeAdded

public void nodeAdded(java.lang.Object node)

edgeAdded

public void edgeAdded(ForeignKeyRelationshipEdge edge)

isValidName

public boolean isValidName(java.lang.String tableName)
                    throws DataSetException
Description copied from class: AbstractTableFilter
Returns true if specified table is allowed by this filter. This legacy method, now replaced by accept, still exist for compatibily with older environment

Specified by:
isValidName in class AbstractTableFilter
Throws:
DataSetException
See Also:
AbstractTableFilter

iterator

public ITableIterator iterator(IDataSet dataSet,
                               boolean reversed)
                        throws DataSetException
Description copied from interface: ITableFilter
Returns iterator of tables allowed by this filter from the specified dataset.

Specified by:
iterator in interface ITableFilter
Overrides:
iterator in class AbstractTableFilter
Parameters:
dataSet - the filtered dataset
Throws:
DataSetException


Copyright © 2002-2006. All Rights Reserved.