1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.jetspeed.util;
18
19 import java.io.Serializable;
20
21 import org.apache.pluto.om.common.ObjectID;
22 import org.apache.pluto.om.portlet.PortletDefinition;
23
24 /***
25 *
26 * JetspeedObjectID
27 ** Wraps around the internal Object IDs. By holding both
28 ** the string and the integer version of an Object ID this class
29 ** helps speed up the internal processing.
30 *
31 * @version $Id: JetspeedObjectID.java 516448 2007-03-09 16:25:47Z ate $
32 *
33 */
34 public class JetspeedObjectID implements ObjectID, Serializable
35 {
36 private String stringOID = null;
37
38 public JetspeedObjectID(String stringOID)
39 {
40 this.stringOID = stringOID;
41 if ( stringOID == null )
42 {
43
44 throw new NullPointerException();
45 }
46 }
47
48 public boolean equals(Object object)
49 {
50 if (object instanceof JetspeedObjectID)
51 {
52 return ((JetspeedObjectID)object).stringOID.equals(stringOID);
53 }
54 else if (object instanceof String)
55 {
56 return ((String)object).equals(stringOID);
57 }
58 return false;
59 }
60
61 public int hashCode()
62 {
63 return stringOID.hashCode();
64 }
65
66 public String toString()
67 {
68 return (stringOID);
69 }
70
71 static public JetspeedObjectID createFromString(String idStr)
72 {
73 return new JetspeedObjectID(idStr);
74 }
75
76 /***
77 * @param portletDefinition
78 * @param instanceName
79 * @return
80 */
81 public static JetspeedObjectID createPortletEntityId(PortletDefinition portletDefinition, String instanceName)
82 {
83 return createFromString(portletDefinition.getName() + ":" + portletDefinition.getId().toString() + ":" + instanceName);
84 }
85 }