01: /**
02: * Copyright 2005 Sun Microsystems, Inc. All
03: * rights reserved. Use of this product is subject
04: * to license terms. Federal Acquisitions:
05: * Commercial Software -- Government Users
06: * Subject to Standard License Terms and
07: * Conditions.
08: *
09: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
10: * are trademarks or registered trademarks of Sun Microsystems,
11: * Inc. in the United States and other countries.
12: */package com.sun.portal.community.mc.impl.jdo.pc;
13:
14: import java.io.Serializable;
15: import java.util.StringTokenizer;
16:
17: /**
18: * Application identifier class for JDO PC community user class
19: */
20: public class CommunityRoleId extends BaseId implements Serializable {
21: public CommunityId community;
22: public int roleId;
23:
24: public CommunityRoleId() {
25: }
26:
27: protected String getSeparator() {
28: return "##";
29: }
30:
31: public CommunityRoleId(String id) {
32: StringTokenizer token = new StringTokenizer(id, getSeparator());
33: //className
34: token.nextToken();
35:
36: community = new CommunityId(token.nextToken());
37: this .roleId = new Integer(token.nextToken()).intValue();
38: }
39:
40: public boolean equals(Object obj) {
41: if (obj == this ) {
42: return true;
43: }
44: if (!(obj instanceof CommunityRoleId)) {
45: return false;
46: }
47: CommunityRoleId other = (CommunityRoleId) obj;
48:
49: return community.equals(other.community)
50: && roleId == other.roleId;
51: }
52:
53: public int hashCode() {
54: return community.hashCode() ^ roleId;
55: }
56:
57: public String toString() {
58: // for debugging only
59: return this.getClass().getName() + getSeparator() + community
60: + getSeparator() + roleId;
61: }
62: }
|