1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002,2008 Oracle. All rights reserved. 5 * 6 * $Id: NonPersistentFormat.java,v 1.1 2008/02/07 17:12:27 mark Exp $ 7 */ 8 9package com.sleepycat.persist.impl; 10 11import java.lang.reflect.Array; 12import 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 */ 20class 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: " + getClassName()); 46 } 47 48 @Override 49 public Object readObject(Object o, EntityInput input, boolean rawAccess) { 50 throw new UnsupportedOperationException(); 51 } 52 53 @Override 54 void writeObject(Object o, EntityOutput output, boolean rawAccess) { 55 throw new UnsupportedOperationException(); 56 } 57 58 @Override 59 void skipContents(RecordInput input) { 60 throw new UnsupportedOperationException(); 61 } 62 63 @Override 64 boolean evolve(Format newFormat, Evolver evolver) { 65 evolver.useOldFormat(this, newFormat); 66 return true; 67 } 68} 69