01: /*
02: * This program is free software; you can redistribute it and/or modify
03: * it under the terms of the GNU General Public License as published by
04: * the Free Software Foundation; either version 2 of the License, or
05: * (at your option) any later version.
06: *
07: * This program is distributed in the hope that it will be useful,
08: * but WITHOUT ANY WARRANTY; without even the implied warranty of
09: * 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;
19:
20: import web.security.Resource;
21:
22: /**
23: * 受控资源的实现类
24: * @author liudong
25: */
26: public class ResourceImpl implements Resource, Serializable {
27:
28: protected String name;
29: protected String desc;
30:
31: public ResourceImpl() {
32: this (null, null);
33: }
34:
35: public ResourceImpl(String name, String desc) {
36: this .name = name;
37: this .desc = desc;
38: }
39:
40: public boolean equals(Resource res) {
41: boolean be = false;
42: if (name != null && res != null)
43: be = name.equals(res.getName());
44: return be;
45: }
46:
47: /* (non-Javadoc)
48: * @see com.clickcom.web.security.Resource#getName()
49: */
50: public String getName() {
51: return name;
52: }
53:
54: /* (non-Javadoc)
55: * @see com.clickcom.web.security.Resource#getDesc()
56: */
57: public String getDesc() {
58: return desc;
59: }
60:
61: public void setDesc(String desc) {
62: this .desc = desc;
63: }
64:
65: public void setName(String name) {
66: this .name = name;
67: }
68:
69: public String toString() {
70: return "RES[" + getClass().getName() + "]:(" + name + ','
71: + desc + ')';
72: }
73:
74: public static void main(String[] args) {
75: ResourceImpl r1 = new ResourceImpl("log", null);
76: ResourceImpl r2 = new ResourceImpl("log", null);
77: System.out.println(r1.equals(r2));
78: }
79: }
|