1 8 9 package com.sleepycat.persist.impl; 10 11 import java.util.IdentityHashMap ; 12 import java.util.List ; 13 import java.util.Map ; 14 import java.util.NoSuchElementException ; 15 16 import com.sleepycat.persist.raw.RawObject; 17 18 27 class ReadOnlyCatalog implements Catalog { 28 29 private List <Format> formatList; 30 private Map <String ,Format> formatMap; 31 32 ReadOnlyCatalog(List <Format> formatList, Map <String ,Format> formatMap) { 33 this.formatList = formatList; 34 this.formatMap = formatMap; 35 } 36 37 public Format getFormat(int formatId) { 38 try { 39 Format format = formatList.get(formatId); 40 if (format == null) { 41 throw new IllegalStateException 42 ("Format does not exist: " + formatId); 43 } 44 return format; 45 } catch (NoSuchElementException e) { 46 throw new IllegalStateException 47 ("Format does not exist: " + formatId); 48 } 49 } 50 51 public Format getFormat(Class cls) { 52 Format format = formatMap.get(cls.getName()); 53 if (format == null) { 54 throw new IllegalArgumentException 55 ("Class is not persistent: " + cls.getName()); 56 } 57 return format; 58 } 59 60 public Format getFormat(String className) { 61 return formatMap.get(className); 62 } 63 64 public Format createFormat(String clsName, Map <String ,Format> newFormats) { 65 throw new IllegalStateException (); 66 } 67 68 public Format createFormat(Class type, Map <String ,Format> newFormats) { 69 throw new IllegalStateException (); 70 } 71 72 public boolean isRawAccess() { 73 return false; 74 } 75 76 public Object convertRawObject(RawObject o, IdentityHashMap converted) { 77 throw new IllegalStateException (); 78 } 79 } 80 | Popular Tags |