blob: e3b066a1f50dcc682bfbd2c2f46e2b53ac26d8d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
/*******************************************************************************
* Copyright (c) 2001, 2008 Oracle Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Oracle Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jst.jsf.common.runtime.internal.model.bean;
import java.io.IOException;
import java.io.NotSerializableException;
import java.io.Serializable;
/**
* A special object used in place of Object to ensure that when an interface
* requires a generic #{@link java.lang.Object}, it won't throw serialization
* exception when a containing object is serialized.
*
* @author cbateman
*
*/
public class SerializableObject implements Serializable
{
/**
*
*/
private static final long serialVersionUID = 9133733048469500692L;
private Object _maybeSerializable;
/**
* @param maybeSerializable
*/
public SerializableObject(Object maybeSerializable)
{
_maybeSerializable = maybeSerializable;
}
// /**
// * Provided to support serialization. Should not be used by sub-classes
// * or clients except in this regard.
// */
// protected SerializableObject()
// {
// _maybeSerializable = null;
// }
/**
* @return the actual value
*/
public final Object getMaybeSerializable() {
return _maybeSerializable;
}
private void writeObject(java.io.ObjectOutputStream out)
throws IOException
{
try
{
out.writeObject(_maybeSerializable);
}
catch (NotSerializableException nse)
{
// do nothing, the object isn't guaranteed to be serializable,
// but we don't want this be an error
out.writeObject(null);
}
}
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException
{
_maybeSerializable = in.readObject();
}
}
|