KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > dbunit > dataset > filter > ExcludeTableFilter


1 /*
2  *
3  * The DbUnit Database Testing Framework
4  * Copyright (C)2002-2004, DbUnit.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19  *
20  */

21 package org.dbunit.dataset.filter;
22
23 import org.dbunit.dataset.DataSetException;
24
25
26 /**
27  * This filter hides specified tables from the filtered dataset. This
28  * implementation do not modify the original table order from the filtered
29  * dataset and support duplicate table names.
30  *
31  * @author Manuel Laflamme
32  * @since Mar 7, 2003
33  * @version $Revision: 1.7 $
34  */

35 public class ExcludeTableFilter extends AbstractTableFilter implements ITableFilter
36 {
37     private final PatternMatcher _patternMatcher = new PatternMatcher();
38
39     /**
40      * Create a new empty ExcludeTableFilter. Use {@link #excludeTable} to hide
41      * some tables.
42      */

43     public ExcludeTableFilter()
44     {
45     }
46
47     /**
48      * Create a new ExcludeTableFilter which prevent access to specified tables.
49      */

50     public ExcludeTableFilter(String JavaDoc[] tableNames)
51     {
52         for (int i = 0; i < tableNames.length; i++)
53         {
54             String JavaDoc tableName = tableNames[i];
55             excludeTable(tableName);
56         }
57     }
58
59     /**
60      * Add a new refused table pattern name.
61      * The following wildcard characters are supported:
62      * '*' matches zero or more characters,
63      * '?' matches one character.
64      */

65     public void excludeTable(String JavaDoc patternName)
66     {
67         _patternMatcher.addPattern(patternName);
68     }
69
70     public boolean isEmpty()
71     {
72         return _patternMatcher.isEmpty();
73     }
74
75     ////////////////////////////////////////////////////////////////////////////
76
// ITableFilter interface
77

78     public boolean isValidName(String JavaDoc tableName) throws DataSetException
79     {
80         return !_patternMatcher.accept(tableName);
81     }
82 }
83
Popular Tags