KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > core > filter > AppliedFilterCondition


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.core.filter;
21
22 /**
23  * This class represents a filter condition applied to a property.
24  */

25 public final class AppliedFilterCondition {
26
27     private SuggestionProperty prop;
28     private FilterCondition cond;
29
30     public AppliedFilterCondition(SuggestionProperty property, FilterCondition condition) {
31         this.prop = property;
32         this.cond = condition;
33     }
34
35     public Object JavaDoc clone() {
36         return new AppliedFilterCondition(prop, (FilterCondition)cond.clone());
37     }
38
39     public SuggestionProperty getProperty() { return prop;}
40     public FilterCondition getCondition() { return cond;}
41     
42     /**
43      * Tests if the condition is true on the property of task.
44      * @param task the object to filter
45      * @return true, if value of the property of <code>task</code>
46      * defined by getProperty() passed the condition getCondition()
47      */

48     public boolean isTrue(Object JavaDoc task) {
49         return cond.isTrue(prop.getValue(task));
50     }
51     
52     public String JavaDoc toString() {
53         return cond.toString() + " applied to " + prop.toString();
54     }
55     
56     /**
57      * Checks whether afc is of the same type.
58      * This method will be used to replace a condition created with
59      * Filter.getConditionsFor(Node.Property) with one contained in a filter.
60      * This method should return true also if this and fc have different
61      * constants for comparing with property values.
62      *
63      * @param fc another condition
64      * @return true fc is of the same type as this
65      */

66     public boolean sameType(AppliedFilterCondition afc) {
67         return getCondition().sameType(afc.getCondition()) && getProperty().equals(afc.getProperty());
68     }
69     
70 }
71
Popular Tags