01: /**
02: * $Id: CommunityUserId.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 JDO PC community user class
20: */
21: public class CommunityUserId extends BaseId implements Serializable {
22: public CommunityId community;
23: public int roleId;
24: public String userName;
25:
26: public CommunityUserId() {
27: }
28:
29: protected String getSeparator() {
30: return "##";
31: }
32:
33: public CommunityUserId(String id) {
34: StringTokenizer token = new StringTokenizer(id, getSeparator());
35: //className
36: token.nextToken();
37:
38: community = new CommunityId(token.nextToken());
39: this .roleId = new Integer(token.nextToken()).intValue();
40: this .userName = token.nextToken();
41: }
42:
43: public boolean equals(Object obj) {
44: if (obj == this ) {
45: return true;
46: }
47: if (!(obj instanceof CommunityUserId)) {
48: return false;
49: }
50: CommunityUserId other = (CommunityUserId) obj;
51:
52: return community.equals(other.community)
53: && roleId == other.roleId
54: && userName.equals(other.userName);
55: }
56:
57: public int hashCode() {
58: return community.hashCode() ^ roleId ^ userName.hashCode();
59: }
60:
61: public String toString() {
62: // for debugging only
63: return this.getClass().getName() + getSeparator() + community
64: + getSeparator() + roleId + getSeparator() + userName;
65: }
66:
67: }
|