01: /*-
02: * See the file LICENSE for redistribution information.
03: *
04: * Copyright (c) 2002,2008 Oracle. All rights reserved.
05: *
06: * $Id: NonPersistentFormat.java,v 1.11.2.3 2008/01/07 15:14:19 cwl Exp $
07: */
08:
09: package com.sleepycat.persist.impl;
10:
11: import java.lang.reflect.Array;
12: import java.util.Map;
13:
14: /**
15: * Format for a non-persistent class that is only used for declared field
16: * types and arrays. Currently used only for Object and interface types.
17: *
18: * @author Mark Hayes
19: */
20: class NonPersistentFormat extends Format {
21:
22: private static final long serialVersionUID = -7488355830875148784L;
23:
24: NonPersistentFormat(Class type) {
25: super (type);
26: }
27:
28: @Override
29: void initialize(Catalog catalog, int initVersion) {
30: }
31:
32: @Override
33: void collectRelatedFormats(Catalog catalog,
34: Map<String, Format> newFormats) {
35: }
36:
37: @Override
38: Object newArray(int len) {
39: return Array.newInstance(getType(), len);
40: }
41:
42: @Override
43: public Object newInstance(EntityInput input, boolean rawAccess) {
44: throw new UnsupportedOperationException(
45: "Cannot instantiate non-persistent class: "
46: + getClassName());
47: }
48:
49: @Override
50: public Object readObject(Object o, EntityInput input,
51: boolean rawAccess) {
52: throw new UnsupportedOperationException();
53: }
54:
55: @Override
56: void writeObject(Object o, EntityOutput output, boolean rawAccess) {
57: throw new UnsupportedOperationException();
58: }
59:
60: @Override
61: void skipContents(RecordInput input) {
62: throw new UnsupportedOperationException();
63: }
64:
65: @Override
66: boolean evolve(Format newFormat, Evolver evolver) {
67: evolver.useOldFormat(this , newFormat);
68: return true;
69: }
70: }
|