4740 |
05 Feb 09 |
nicklas |
1 |
/** |
4740 |
05 Feb 09 |
nicklas |
$Id$ |
4740 |
05 Feb 09 |
nicklas |
3 |
|
4740 |
05 Feb 09 |
nicklas |
Copyright (C) 2008 Nicklas Nordborg |
4740 |
05 Feb 09 |
nicklas |
5 |
|
4740 |
05 Feb 09 |
nicklas |
This file is part of BASE - BioArray Software Environment. |
4740 |
05 Feb 09 |
nicklas |
Available at http://base.thep.lu.se/ |
4740 |
05 Feb 09 |
nicklas |
8 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is free software; you can redistribute it and/or |
4740 |
05 Feb 09 |
nicklas |
modify it under the terms of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
as published by the Free Software Foundation; either version 3 |
4740 |
05 Feb 09 |
nicklas |
of the License, or (at your option) any later version. |
4740 |
05 Feb 09 |
nicklas |
13 |
|
4740 |
05 Feb 09 |
nicklas |
BASE is distributed in the hope that it will be useful, |
4740 |
05 Feb 09 |
nicklas |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
4740 |
05 Feb 09 |
nicklas |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
4740 |
05 Feb 09 |
nicklas |
GNU General Public License for more details. |
4740 |
05 Feb 09 |
nicklas |
18 |
|
4740 |
05 Feb 09 |
nicklas |
You should have received a copy of the GNU General Public License |
4740 |
05 Feb 09 |
nicklas |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
4740 |
05 Feb 09 |
nicklas |
21 |
*/ |
4740 |
05 Feb 09 |
nicklas |
22 |
package net.sf.basedb.util.overview.filter; |
4740 |
05 Feb 09 |
nicklas |
23 |
|
4740 |
05 Feb 09 |
nicklas |
24 |
import net.sf.basedb.core.BasicItem; |
4740 |
05 Feb 09 |
nicklas |
25 |
import net.sf.basedb.core.Item; |
4740 |
05 Feb 09 |
nicklas |
26 |
import net.sf.basedb.util.filter.Filter; |
4740 |
05 Feb 09 |
nicklas |
27 |
import net.sf.basedb.util.overview.Node; |
4740 |
05 Feb 09 |
nicklas |
28 |
|
4740 |
05 Feb 09 |
nicklas |
29 |
/** |
4740 |
05 Feb 09 |
nicklas |
A filter implementation that matches against the item |
4740 |
05 Feb 09 |
nicklas |
that is attached to nodes. It will evaluate to true |
4740 |
05 Feb 09 |
nicklas |
for all nodes that has the same item as the reference |
4740 |
05 Feb 09 |
nicklas |
item. |
4740 |
05 Feb 09 |
nicklas |
34 |
|
4740 |
05 Feb 09 |
nicklas |
@author Nicklas |
4740 |
05 Feb 09 |
nicklas |
@version 2.10 |
4740 |
05 Feb 09 |
nicklas |
@base.modified $Date$ |
4740 |
05 Feb 09 |
nicklas |
38 |
*/ |
4740 |
05 Feb 09 |
nicklas |
39 |
public class BasicItemFilter |
4740 |
05 Feb 09 |
nicklas |
40 |
implements Filter<Node> |
4740 |
05 Feb 09 |
nicklas |
41 |
{ |
4740 |
05 Feb 09 |
nicklas |
42 |
private final Item itemType; |
4740 |
05 Feb 09 |
nicklas |
43 |
private final BasicItem item; |
4740 |
05 Feb 09 |
nicklas |
44 |
|
4740 |
05 Feb 09 |
nicklas |
45 |
/** |
4740 |
05 Feb 09 |
nicklas |
Create a filter that finds nodes that has the given |
4740 |
05 Feb 09 |
nicklas |
item attached to it. |
4740 |
05 Feb 09 |
nicklas |
@param item The item to look for |
4740 |
05 Feb 09 |
nicklas |
49 |
*/ |
4740 |
05 Feb 09 |
nicklas |
50 |
public BasicItemFilter(BasicItem item) |
4740 |
05 Feb 09 |
nicklas |
51 |
{ |
4740 |
05 Feb 09 |
nicklas |
52 |
this.item = item; |
4740 |
05 Feb 09 |
nicklas |
53 |
this.itemType = item.getType(); |
4740 |
05 Feb 09 |
nicklas |
54 |
} |
4740 |
05 Feb 09 |
nicklas |
55 |
|
4740 |
05 Feb 09 |
nicklas |
56 |
/* |
4740 |
05 Feb 09 |
nicklas |
From the Filter interface |
4740 |
05 Feb 09 |
nicklas |
58 |
------------------------- |
4740 |
05 Feb 09 |
nicklas |
59 |
*/ |
4740 |
05 Feb 09 |
nicklas |
60 |
@Override |
4740 |
05 Feb 09 |
nicklas |
61 |
public boolean evaluate(Node node) |
4740 |
05 Feb 09 |
nicklas |
62 |
{ |
4740 |
05 Feb 09 |
nicklas |
63 |
return itemType == node.getItemType() && item.equals(node.getItem()); |
4740 |
05 Feb 09 |
nicklas |
64 |
} |
4740 |
05 Feb 09 |
nicklas |
65 |
// ----------------------------- |
4740 |
05 Feb 09 |
nicklas |
66 |
} |