KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > web > security > impl > ResourceImpl


1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  */

16 package web.security.impl;
17
18 import java.io.Serializable JavaDoc;
19
20 import web.security.Resource;
21
22
23 /**
24  * 受控资源的实现类
25  * @author liudong
26  */

27 public class ResourceImpl implements Resource, Serializable JavaDoc {
28     
29     protected String JavaDoc name;
30     protected String JavaDoc desc;
31     
32     public ResourceImpl(){
33         this(null,null);
34     }
35     
36     public ResourceImpl(String JavaDoc name,String JavaDoc desc){
37         this.name = name;
38         this.desc = desc;
39     }
40
41     public boolean equals(Resource res) {
42         boolean be = false;
43         if(name!=null && res!=null)
44             be = name.equals(res.getName());
45         return be;
46     }
47     /* (non-Javadoc)
48      * @see com.clickcom.web.security.Resource#getName()
49      */

50     public String JavaDoc getName() {
51         return name;
52     }
53
54     /* (non-Javadoc)
55      * @see com.clickcom.web.security.Resource#getDesc()
56      */

57     public String JavaDoc getDesc() {
58         return desc;
59     }
60
61     public void setDesc(String JavaDoc desc) {
62         this.desc = desc;
63     }
64     public void setName(String JavaDoc name) {
65         this.name = name;
66     }
67     public String JavaDoc toString() {
68         return "RES["+getClass().getName()+"]:("+name+','+desc+')';
69     }
70     
71     public static void main(String JavaDoc[] args){
72         ResourceImpl r1 = new ResourceImpl("log",null);
73         ResourceImpl r2 = new ResourceImpl("log",null);
74         System.out.println(r1.equals(r2));
75     }
76 }
77
Popular Tags