1 // $Id:NamespaceFilter.java 62 2008-04-20 12:28:56Z me $
2 /*
3 * xsAnalyzer - XML schema analyzing tool. Copyright (C) 2008 Michael Engelhardt
4 *
5 * This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public
6 * License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later
7 * version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
10 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License along with this program; if not, write to the Free
13 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
14 */
15 /**
16 *
17 */
18 package de.mindcrimeilab.xsanalyzer.model;
19
20 import java.util.LinkedList;
21 import java.util.List;
22
23 import org.apache.xerces.xs.XSObject;
24
25 import de.mindcrimeilab.util.Filter;
26
27 /**
28 * @author Michael Engelhardt<me@mindcrime-ilab.de>
29 * @author $Author:me $
30 * @version $Revision:62 $
31 *
32 */
33 public class NamespaceFilter implements Filter<XSObject> {
34
35 private final List<String> filteredNamespaces;
36
37 public NamespaceFilter() {
38 filteredNamespaces = new LinkedList<String>();
39 }
40
41 public boolean addNamespace(String namespace) {
42 return filteredNamespaces.add(namespace);
43 }
44
45 public boolean removeNamespace(String namespace) {
46 return filteredNamespaces.remove(namespace);
47 }
48
49 @Override
50 public boolean isFiltered(XSObject object) {
51 final String namespaceItem = object.getNamespace();
52 final boolean result = filteredNamespaces.contains(namespaceItem);
53 return result;
54 }
55
56 }