%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.util.JetspeedObjectID |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
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 | 0 | private String stringOID = null; |
37 | ||
38 | public JetspeedObjectID(String stringOID) |
|
39 | 0 | { |
40 | 0 | this.stringOID = stringOID; |
41 | 0 | if ( stringOID == null ) |
42 | { |
|
43 | // really cannot have a null here |
|
44 | 0 | throw new NullPointerException(); |
45 | } |
|
46 | 0 | } |
47 | ||
48 | public boolean equals(Object object) |
|
49 | { |
|
50 | 0 | if (object instanceof JetspeedObjectID) |
51 | { |
|
52 | 0 | return ((JetspeedObjectID)object).stringOID.equals(stringOID); |
53 | } |
|
54 | 0 | else if (object instanceof String) |
55 | { |
|
56 | 0 | return ((String)object).equals(stringOID); |
57 | } |
|
58 | 0 | return false; |
59 | } |
|
60 | ||
61 | public int hashCode() |
|
62 | { |
|
63 | 0 | return stringOID.hashCode(); |
64 | } |
|
65 | ||
66 | public String toString() |
|
67 | { |
|
68 | 0 | return (stringOID); |
69 | } |
|
70 | ||
71 | static public JetspeedObjectID createFromString(String idStr) |
|
72 | { |
|
73 | 0 | 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 | 0 | return createFromString(portletDefinition.getName() + ":" + portletDefinition.getId().toString() + ":" + instanceName); |
84 | } |
|
85 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |