01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * 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:
18: package javax.sql.rowset.serial;
19:
20: import java.io.Serializable;
21: import java.lang.reflect.Field;
22: import java.util.Vector;
23:
24: import org.apache.harmony.sql.internal.nls.Messages;
25:
26: public class SerialJavaObject implements Serializable, Cloneable {
27:
28: private static final long serialVersionUID = -1465795139032831023L;
29:
30: /**
31: * obj and chain are defined in serialized form.
32: */
33: private Object obj;
34:
35: @SuppressWarnings({"unchecked","unused"})
36: // Required by serialized form
37: private Vector chain;
38:
39: private transient Field[] fields;
40:
41: public SerialJavaObject(Object obj) throws SerialException {
42: if (null == obj) {
43: throw new NullPointerException();
44: }
45: if (!(obj instanceof Serializable)) {
46: throw new SerialException(Messages.getString("sql.41"));
47: }
48: this .obj = obj;
49: }
50:
51: public Field[] getFields() throws SerialException {
52: if (fields == null) {
53: fields = obj.getClass().getFields();
54: }
55: return fields;
56: }
57:
58: public Object getObject() throws SerialException {
59: return obj;
60: }
61: }
|