01: /**
02: * $Id: CommunityId.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 class
20: */
21: public class CommunityId extends BaseId implements Serializable {
22: public long communityId;
23:
24: public CommunityId() {
25: }
26:
27: protected String getSeparator() {
28: return "%%";
29: }
30:
31: public CommunityId(String id) {
32: StringTokenizer token = new StringTokenizer(id, getSeparator());
33: // class name
34: token.nextToken();
35: this .communityId = Long.valueOf(token.nextToken()).longValue();
36: }
37:
38: public boolean equals(Object obj) {
39: if (obj == this ) {
40: return true;
41: }
42: if (!(obj instanceof CommunityId)) {
43: return false;
44: }
45: CommunityId other = (CommunityId) obj;
46:
47: return communityId == other.communityId;
48: }
49:
50: public int hashCode() {
51: return (int) communityId;
52: }
53:
54: public String toString() {
55: return this.getClass().getName() + getSeparator() + communityId;
56: }
57: }
|