KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > util > strainer > ContextVariableFilter


1 /*
2 Copyright (c) 2003 eInnovation Inc. All rights reserved
3
4 This library is free software; you can redistribute it and/or modify it under the terms
5 of the GNU Lesser General Public License as published by the Free Software Foundation;
6 either version 2.1 of the License, or (at your option) any later version.
7
8 This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the GNU Lesser General Public License for more details.
11 */

12
13 package com.openedit.util.strainer;
14
15 import com.openedit.WebPageRequest;
16
17
18 /**
19  * This filter only passes users that have a certain permission.
20  *
21  * @author Eric Galluzzo
22  */

23 public class ContextVariableFilter implements Filter
24 {
25     protected String JavaDoc fieldEquals;
26     protected String JavaDoc fieldProperty;
27
28     /**
29      * Construct a filter that passes all users.
30      *
31      * @see #setPermission(String)
32      */

33     public ContextVariableFilter()
34     {
35         super();
36     }
37
38     /**
39      * Construct a filter that only passes users that have the given permission.
40      *
41      * @param inPermission The permission to check for
42      * @param inEQ DOCME
43      */

44     public ContextVariableFilter(String JavaDoc inPermission, String JavaDoc inEQ)
45     {
46         setProperty(inPermission);
47         setEquals(inEQ);
48     }
49
50     /**
51      * DOCUMENT ME!
52      *
53      * @param inString
54      */

55     public void setEquals(String JavaDoc inString)
56     {
57         fieldEquals = inString;
58     }
59
60     /**
61      * DOCUMENT ME!
62      *
63      * @return
64      */

65     public String JavaDoc getEquals()
66     {
67         return fieldEquals;
68     }
69
70     /**
71      * Sets the permission to check for.
72      *
73      * @param permission The permission to check for
74      */

75     public void setProperty(String JavaDoc permission)
76     {
77         fieldProperty = permission;
78     }
79
80     /**
81      * Returns the permission to check for.
82      *
83      * @return String
84      */

85     public String JavaDoc getProperty()
86     {
87         return fieldProperty;
88     }
89
90     /**
91      * @see com.openedit.util.strainer.Filter#passes(java.lang.Object)
92      */

93     public boolean passes(Object JavaDoc inObj) throws FilterException, ClassCastException JavaDoc
94     {
95         WebPageRequest req = (WebPageRequest) inObj;
96
97         String JavaDoc compare = (String JavaDoc) req.getPageValue(getProperty());
98
99         return (getProperty() == null) || getEquals().equalsIgnoreCase(compare);
100     }
101
102     public void accept( FilterVisitor inFilterVisitor ) throws FilterException
103     {
104         // TODO Auto-generated method stub
105

106     }
107
108     public Filter[] getFilters()
109     {
110         // TODO Auto-generated method stub
111
return null;
112     }
113 }
114
Popular Tags