KickJava   Java API By Example, From Geeks To Geeks.

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


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 PathFilter implements Filter
24 {
25     protected String JavaDoc fieldPath;
26
27     /**
28      * Construct a filter that passes all users.
29      *
30      * @see #setPermission(String)
31      */

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

42     public PathFilter(String JavaDoc inPermission)
43     {
44         setPath(inPermission);
45     }
46
47     /**
48      * Sets the permission to check for.
49      *
50      * @param permission The permission to check for
51      */

52     public void setPath(String JavaDoc permission)
53     {
54         fieldPath = permission;
55     }
56
57     /**
58      * Returns the permission to check for.
59      *
60      * @return String
61      */

62     public String JavaDoc getPath()
63     {
64         return fieldPath;
65     }
66
67     /**
68      * @see com.openedit.util.strainer.Filter#passes(java.lang.Object)
69      */

70     public boolean passes(Object JavaDoc inObj) throws FilterException, ClassCastException JavaDoc
71     {
72         WebPageRequest req = (WebPageRequest) inObj;
73
74         return (getPath() == null) || req.getPage().getPath().startsWith(getPath());
75     }
76
77     public void accept( FilterVisitor inFilterVisitor ) throws FilterException
78     {
79         // TODO Auto-generated method stub
80

81     }
82
83     public Filter[] getFilters()
84     {
85         // TODO Auto-generated method stub
86
return null;
87     }
88 }
89
Popular Tags