1/*- 2 * See the file LICENSE for redistribution information. 3 * 4 * Copyright (c) 2002-2009 Oracle. All rights reserved. 5 * 6 * $Id$ 7 */ 8 9package com.sleepycat.persist.impl; 10 11import java.lang.reflect.Array; 12import java.util.Map; 13 14import com.sleepycat.persist.model.EntityModel; 15 16/** 17 * Format for a non-persistent class that is only used for declared field 18 * types and arrays. Currently used only for Object and interface types. 19 * 20 * @author Mark Hayes 21 */ 22class NonPersistentFormat extends Format { 23 24 private static final long serialVersionUID = -7488355830875148784L; 25 26 NonPersistentFormat(Class type) { 27 super(type); 28 } 29 30 @Override 31 void initialize(Catalog catalog, EntityModel model, int initVersion) { 32 } 33 34 @Override 35 void collectRelatedFormats(Catalog catalog, 36 Map<String,Format> newFormats) { 37 } 38 39 @Override 40 Object newArray(int len) { 41 return Array.newInstance(getType(), len); 42 } 43 44 @Override 45 public Object newInstance(EntityInput input, boolean rawAccess) { 46 throw new UnsupportedOperationException 47 ("Cannot instantiate non-persistent class: " + getClassName()); 48 } 49 50 @Override 51 public Object readObject(Object o, EntityInput input, 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} 71