01: /**********************************************************************************
02: * $URL: https://source.sakaiproject.org/svn/metaobj/tags/sakai_2-4-1/metaobj-api/api/src/java/org/sakaiproject/metaobj/shared/mgt/ReferenceHolder.java $
03: * $Id: ReferenceHolder.java 8052 2006-04-20 18:16:21Z ggolden@umich.edu $
04: ***********************************************************************************
05: *
06: * Copyright (c) 2005, 2006 The Sakai Foundation.
07: *
08: * Licensed under the Educational Community License, Version 1.0 (the "License");
09: * you may not use this file except in compliance with the License.
10: * You may obtain a copy of the License at
11: *
12: * http://www.opensource.org/licenses/ecl1.php
13: *
14: * Unless required by applicable law or agreed to in writing, software
15: * distributed under the License is distributed on an "AS IS" BASIS,
16: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17: * See the License for the specific language governing permissions and
18: * limitations under the License.
19: *
20: **********************************************************************************/package org.sakaiproject.metaobj.shared.mgt;
21:
22: import java.io.IOException;
23: import java.io.Serializable;
24:
25: import org.sakaiproject.entity.api.Reference;
26: import org.sakaiproject.entity.cover.EntityManager;
27:
28: /**
29: * Created by IntelliJ IDEA.
30: * User: John Ellis
31: * Date: Nov 15, 2005
32: * Time: 3:13:42 PM
33: * To change this template use File | Settings | File Templates.
34: */
35: public class ReferenceHolder implements Serializable {
36:
37: private transient Reference base;
38:
39: public ReferenceHolder() {
40: }
41:
42: public ReferenceHolder(Reference base) {
43: this .base = base;
44: }
45:
46: public Reference getBase() {
47: return base;
48: }
49:
50: public void setBase(Reference base) {
51: this .base = base;
52: }
53:
54: private void writeObject(java.io.ObjectOutputStream out)
55: throws IOException {
56: out.writeObject(base.getReference());
57: }
58:
59: private void readObject(java.io.ObjectInputStream in)
60: throws IOException, ClassNotFoundException {
61: String ref = (String) in.readObject();
62: setBase(EntityManager.newReference(ref));
63: }
64:
65: public boolean equals(Object o) {
66: if (this == o) {
67: return true;
68: }
69: if (!(o instanceof ReferenceHolder)) {
70: return false;
71: }
72:
73: final ReferenceHolder referenceHolder = (ReferenceHolder) o;
74:
75: if (base != null ? !base.getReference().equals(
76: referenceHolder.base.getReference())
77: : referenceHolder.base != null) {
78: return false;
79: }
80:
81: return true;
82: }
83:
84: public int hashCode() {
85: return (base != null ? base.hashCode() : 0);
86: }
87:
88: }
|