KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > ejb > authorization > AdminEntityPK


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13  
14
15 package org.ejbca.core.ejb.authorization;
16
17 /**
18  * The current pk in AdminEntityData and AccessRulesData is a mix of integer pk and
19  * constraints and actually works fine.
20  * It's used like a primitive int primary key in the db, but embeds logic for
21  * enforcing constraints, which would otherwise have to be programatically added to the beans.
22  * If needed it can easily be replaced with an int pk and programatic logic to handle
23  * constraints. From the database view the pk is just an int.
24  *
25  * @version $Id: AdminEntityPK.java,v 1.1 2006/01/17 20:30:04 anatom Exp $
26  */

27 public final class AdminEntityPK implements java.io.Serializable JavaDoc {
28
29     public int primKey;
30
31     public AdminEntityPK(String JavaDoc admingroupname, int caid, int matchwith, int matchtype, String JavaDoc matchvalue) {
32         this.primKey =
33         ((admingroupname==null?0:admingroupname.hashCode())
34         ^
35         (caid)
36         ^
37         (matchwith)
38         ^
39         (matchvalue==null?0:matchvalue.hashCode())
40         ^
41         (matchtype));
42     }
43
44     public AdminEntityPK() {
45     }
46
47     public int getPrimKey()
48     {
49         return primKey;
50     }
51
52     public void setPrimKey(int primKey)
53     {
54         this.primKey = primKey;
55     }
56
57     /**
58      * @see java.lang.Object#equals(java.lang.Object)
59      */

60     public boolean equals(java.lang.Object JavaDoc otherOb) {
61         if (!(otherOb instanceof org.ejbca.core.ejb.authorization.AdminEntityPK)) {
62             return false;
63         }
64         org.ejbca.core.ejb.authorization.AdminEntityPK other = (org.ejbca.core.ejb.authorization.AdminEntityPK) otherOb;
65         return (this.primKey == other.primKey);
66     }
67
68     /**
69      * @see java.lang.Object#hashCode()
70      */

71     public int hashCode() {
72         return this.primKey;
73     }
74
75     /** @return String representation of this pk in the form of [.field1.field2.field3]. */
76     public String JavaDoc toString()
77     {
78         StringBuffer JavaDoc toStringValue = new StringBuffer JavaDoc("[.");
79         toStringValue.append(this.primKey).append('.');
80         toStringValue.append(']');
81         return toStringValue.toString();
82     }
83     
84 }
85
Popular Tags