1 10 11 package com.triactive.jdo.model; 12 13 import com.triactive.jdo.sco.SCOProcessor; 14 import java.util.HashMap ; 15 import java.util.HashSet ; 16 17 18 public final class Types 19 { 20 private static final HashSet defaultFetchGroupTypes = new HashSet (); 21 private static final HashSet defaultPersistentTypes = new HashSet (); 22 23 static 24 { 25 defaultFetchGroupTypes.add(boolean.class); 26 defaultFetchGroupTypes.add(byte.class); 27 defaultFetchGroupTypes.add(char.class); 28 defaultFetchGroupTypes.add(short.class); 29 defaultFetchGroupTypes.add(int.class); 30 defaultFetchGroupTypes.add(long.class); 31 defaultFetchGroupTypes.add(float.class); 32 defaultFetchGroupTypes.add(double.class); 33 defaultFetchGroupTypes.add(Boolean .class); 34 defaultFetchGroupTypes.add(Byte .class); 35 defaultFetchGroupTypes.add(Character .class); 36 defaultFetchGroupTypes.add(Short .class); 37 defaultFetchGroupTypes.add(Integer .class); 38 defaultFetchGroupTypes.add(Long .class); 39 defaultFetchGroupTypes.add(Float .class); 40 defaultFetchGroupTypes.add(Double .class); 41 defaultFetchGroupTypes.add(Number .class); 42 defaultFetchGroupTypes.add(String .class); 43 defaultFetchGroupTypes.add(java.math.BigDecimal .class); 44 defaultFetchGroupTypes.add(java.math.BigInteger .class); 45 defaultFetchGroupTypes.add(java.util.Date .class); 46 defaultFetchGroupTypes.add(java.util.Locale .class); 47 48 defaultPersistentTypes.add(java.util.ArrayList .class); 49 defaultPersistentTypes.add(java.util.Collection .class); 50 defaultPersistentTypes.add(java.util.HashMap .class); 51 defaultPersistentTypes.add(java.util.HashSet .class); 52 defaultPersistentTypes.add(java.util.Hashtable .class); 53 defaultPersistentTypes.add(java.util.LinkedList .class); 54 defaultPersistentTypes.add(java.util.List .class); 55 defaultPersistentTypes.add(java.util.Map .class); 56 defaultPersistentTypes.add(java.util.Set .class); 57 defaultPersistentTypes.add(java.util.TreeMap .class); 58 defaultPersistentTypes.add(java.util.TreeSet .class); 59 defaultPersistentTypes.add(java.util.Vector .class); 60 } 61 62 public static boolean isDefaultFetchGroupType(Class c) 63 { 64 return defaultFetchGroupTypes.contains(c); 65 } 66 67 public static boolean isDefaultEmbeddedType(Class c) 68 { 69 if (c == null) 70 return false; 71 72 if (isDefaultFetchGroupType(c)) 73 return true; 74 75 if (isDefaultEmbeddedType(c.getComponentType())) 76 return true; 77 78 return false; 79 } 80 81 public static boolean isDefaultPersistentType(Class c) 82 { 83 if (c == null) 84 return false; 85 86 if (isDefaultEmbeddedType(c)) 87 return true; 88 89 if (defaultPersistentTypes.contains(c)) 90 return true; 91 92 if (isEnhancedClass(c)) 93 return true; 94 95 if (isDefaultPersistentType(c.getComponentType())) 96 return true; 97 98 return false; 99 } 100 101 public static boolean isEnhancedClass(Class c) 102 { 103 if (c.isInterface()) 104 return false; 105 106 117 try 118 { 119 c.getDeclaredMethod("jdoProvideField", new Class [] { int.class }); 120 } 121 catch (NoSuchMethodException e) 122 { 123 return false; 124 } 125 126 return true; 127 } 128 129 public static boolean isSecondClassMutableType(Class c) 130 { 131 return SCOProcessor.isSecondClassMutableType(c); 132 } 133 } 134 | Popular Tags |