18 package testsuite.clusterj.domaintypehandler;
20 import com.mysql.clusterj.core.CacheManager;
21 import com.mysql.clusterj.core.query.CandidateIndexImpl;
22 import com.mysql.clusterj.core.spi.DomainFieldHandler;
23 import com.mysql.clusterj.core.spi.DomainTypeHandler;
24 import com.mysql.clusterj.core.spi.DomainTypeHandlerFactory;
25 import com.mysql.clusterj.core.spi.ValueHandler;
26 import com.mysql.clusterj.core.store.ClusterTransaction;
27 import com.mysql.clusterj.core.store.Column;
28 import com.mysql.clusterj.core.store.Dictionary;
29 import com.mysql.clusterj.core.store.Operation;
30 import com.mysql.clusterj.core.store.PartitionKey;
31 import com.mysql.clusterj.core.store.ResultData;
32 import com.mysql.clusterj.core.store.Table;
34 import java.lang.reflect.Constructor;
35 import java.lang.reflect.InvocationTargetException;
36 import java.util.BitSet;
37 import java.util.HashMap;
43 static Map<String, Constructor> constructorMap =
new HashMap<String, Constructor>();
45 static Class[] exceptions =
new Class[] {NullPointerException.class, IllegalAccessException.class};
48 for (Class exception: exceptions) {
50 constructorMap.put(exception.getSimpleName(), exception.getConstructor(
new Class[]{}));
51 }
catch (NoSuchMethodException ex) {
52 throw new RuntimeException(ex);
53 }
catch (SecurityException ex) {
54 throw new RuntimeException(ex);
59 public <T> DomainTypeHandler<T> createDomainTypeHandler(Class<T> domainClass,
Dictionary dictionary) {
60 String className = domainClass.getSimpleName();
61 if (className.startsWith(
"Throw")) {
62 String throwClassName = className.substring(5);
64 Constructor ctor = constructorMap.get(throwClassName);
65 RuntimeException throwable = (RuntimeException) ctor.newInstance(
new Object[]{});
67 }
catch (InstantiationException ex) {
68 throw new RuntimeException(ex);
69 }
catch (IllegalAccessException ex) {
70 throw new RuntimeException(ex);
71 }
catch (IllegalArgumentException ex) {
72 throw new RuntimeException(ex);
73 }
catch (InvocationTargetException ex) {
74 throw new RuntimeException(ex);
75 }
catch (SecurityException ex) {
76 throw new RuntimeException(ex);
78 }
else if (className.equals(
"CrazyDelegate")) {
79 final String delegateName = className;
80 return new DomainTypeHandler<T>() {
83 throw new UnsupportedOperationException(
"Not supported yet.");
90 public boolean isSupportedType() {
91 throw new UnsupportedOperationException(
"Not supported yet.");
94 public String getTableName() {
95 throw new UnsupportedOperationException(
"Not supported yet.");
99 throw new UnsupportedOperationException(
"Not supported yet.");
102 public Class getProxyClass() {
103 throw new UnsupportedOperationException(
"Nice Job!");
106 public T newInstance() {
107 throw new UnsupportedOperationException(
"Not supported yet.");
111 throw new UnsupportedOperationException(
"Not supported yet.");
115 throw new UnsupportedOperationException(
"Not supported yet.");
119 throw new UnsupportedOperationException(
"Not supported yet.");
123 throw new UnsupportedOperationException(
"Not supported yet.");
127 throw new UnsupportedOperationException(
"Not supported yet.");
130 public void objectSetCacheManager(
CacheManager cm, Object instance) {
131 throw new UnsupportedOperationException(
"Not supported yet.");
135 throw new UnsupportedOperationException(
"Not supported yet.");
138 public void operationGetValues(
Operation op) {
139 throw new UnsupportedOperationException(
"Not supported yet.");
142 public void operationGetValues(
Operation op, BitSet fields) {
143 throw new UnsupportedOperationException(
"Not supported yet.");
147 throw new UnsupportedOperationException(
"Not supported yet.");
151 throw new UnsupportedOperationException(
"Not supported yet.");
155 throw new UnsupportedOperationException(
"Not supported yet.");
159 throw new UnsupportedOperationException(
"Not supported yet.");
162 public ValueHandler createKeyValueHandler(Object keys) {
163 throw new UnsupportedOperationException(
"Not supported yet.");
166 public int[] getKeyFieldNumbers() {
167 throw new UnsupportedOperationException(
"Not supported yet.");
170 public Class getOidClass() {
171 throw new UnsupportedOperationException(
"Not supported yet.");
174 public Set<Column> getStoreColumns(BitSet fields) {
175 throw new UnsupportedOperationException(
"Not supported yet.");
178 public Table getStoreTable() {
179 throw new UnsupportedOperationException(
"Not supported yet.");
184 throw new UnsupportedOperationException(
"Not supported yet.");
187 public String[] getFieldNames() {
188 throw new UnsupportedOperationException(
"Not supported yet.");
191 public void operationSetValues(
ValueHandler valueHandler,
193 throw new UnsupportedOperationException(
"Not supported yet.");
196 public void objectSetKeys(Object keys, Object instance) {
197 throw new UnsupportedOperationException(
"Not supported yet.");