KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > openedit > users > Permission


1 /*
2 Copyright (c) 2004 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.users;
14
15 /**
16  * This object represents a permission that can be assigned to a group.
17  *
18  * @author Dennis Brown
19  */

20 public class Permission
21 {
22     protected String JavaDoc fieldName;
23     protected String JavaDoc fieldDisplayName;
24
25     public Permission()
26     {
27     }
28
29     public Permission( String JavaDoc inName )
30     {
31         fieldName = inName;
32     }
33
34     public Permission( String JavaDoc inName, String JavaDoc inDisplayName )
35     {
36         fieldName = inName;
37         fieldDisplayName = inDisplayName;
38     }
39
40     public String JavaDoc getName()
41     {
42         return fieldName;
43     }
44
45     public String JavaDoc getDisplayName()
46     {
47         return fieldDisplayName;
48     }
49
50     public void setName( String JavaDoc inName )
51     {
52         fieldName = inName;
53     }
54
55     public void setDisplayName( String JavaDoc inDisplayName )
56     {
57         fieldDisplayName = inDisplayName;
58     }
59
60     /**
61      * Two <code>Permission</code>s are equal if their names are equal.
62      */

63     public boolean equals( Object JavaDoc o )
64     {
65         if ( o instanceof Permission )
66         {
67             Permission p = (Permission) o;
68             if ( fieldName != null )
69             {
70                 return fieldName.equals( p.fieldName );
71             }
72             else
73             {
74                 return ( p.fieldName == null );
75             }
76         }
77         else
78         {
79             return false;
80         }
81     }
82
83     public int hashCode()
84     {
85         return ( fieldName != null ) ?
86                 fieldName.hashCode() :
87                 0;
88     }
89
90     public String JavaDoc toString()
91     {
92         return fieldName;
93     }
94 }
95
Popular Tags