01: package com.sun.portal.community.mc.impl.jdo.pc;
02:
03: import java.util.HashSet;
04: import java.util.Set;
05: import java.io.UnsupportedEncodingException;
06:
07: /**
08: * JDO PC class to store community DPs.
09: */
10: public class CommunityDp {
11: private Community community;
12: private String communityName;
13: private int roleId;
14: private byte[] dp;
15: private long lastModified;
16:
17: public CommunityDp() {
18: }
19:
20: public CommunityDp(String communityName, int roleId, byte[] dp) {
21: this .communityName = communityName;
22: this .roleId = roleId;
23: this .dp = dp;
24:
25: lastModified = System.currentTimeMillis();
26: }
27:
28: public String getCommunityName() {
29: return communityName;
30: }
31:
32: public int getRoleId() {
33: return roleId;
34: }
35:
36: public byte[] getDp() {
37: return dp;
38: }
39:
40: public long getLastModified() {
41: return lastModified;
42: }
43:
44: public boolean equals(Object obj) {
45: if (obj == this ) {
46: return true;
47: }
48: if (!(obj instanceof CommunityDp)) {
49: return false;
50: }
51: CommunityDp other = (CommunityDp) obj;
52:
53: return getCommunityName().equals(other.getCommunityName())
54: && (getRoleId() == other.getRoleId());
55: }
56:
57: public int hashCode() {
58: return getCommunityName().hashCode() ^ getRoleId();
59: }
60:
61: /**
62: * For debugging purposes only.
63: */
64: public String toString() {
65: String dpString;
66: try {
67: dpString = new String(getDp(), "UTF-8");
68: } catch (UnsupportedEncodingException uee) {
69: throw new Error("UTF-8 encoding not supported");
70: }
71:
72: return "{ communityName=" + getCommunityName() + ", roleId="
73: + getRoleId() + ", lastModified=" + lastModified
74: + ", dp=" + dpString + " }";
75: }
76: }
|