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