1 21 package com.db4o.reflect.generic; 22 23 import com.db4o.reflect.*; 24 25 28 public class GenericArrayReflector implements ReflectArray{ 29 30 private final ReflectArray _delegate; 31 32 public GenericArrayReflector(GenericReflector reflector){ 33 _delegate = reflector.getDelegate().array(); 34 } 35 36 public int[] dimensions(Object arr) { 37 return _delegate.dimensions(arr); 38 } 39 40 public int flatten(Object a_shaped, int[] a_dimensions, int a_currentDimension, Object [] a_flat, int a_flatElement) { 41 return _delegate.flatten(a_shaped, a_dimensions, a_currentDimension, a_flat, a_flatElement); 42 } 43 44 public Object get(Object onArray, int index) { 45 if(onArray instanceof GenericArray){ 46 return ((GenericArray)onArray)._data[index]; 47 } 48 return _delegate.get(onArray, index); 49 } 50 51 public ReflectClass getComponentType(ReflectClass claxx) { 52 claxx = claxx.getDelegate(); 53 if(claxx instanceof GenericClass){ 54 return claxx; 55 } 56 return _delegate.getComponentType(claxx); 57 } 58 59 public int getLength(Object array) { 60 if(array instanceof GenericArray){ 61 return ((GenericArray)array).getLength(); 62 } 63 return _delegate.getLength(array); 64 } 65 66 public boolean isNDimensional(ReflectClass a_class) { 67 if(a_class instanceof GenericArrayClass){ 68 return false; 69 } 70 return _delegate.isNDimensional(a_class.getDelegate()); 71 } 72 73 public Object newInstance(ReflectClass componentType, int length) { 74 componentType = componentType.getDelegate(); 75 if(componentType instanceof GenericClass){ 76 return new GenericArray(((GenericClass)componentType).arrayClass(), length); 77 } 78 return _delegate.newInstance(componentType, length); 79 } 80 81 public Object newInstance(ReflectClass componentType, int[] dimensions) { 82 return _delegate.newInstance(componentType.getDelegate(), dimensions); 83 } 84 85 public void set(Object onArray, int index, Object element) { 86 if(onArray instanceof GenericArray){ 87 ((GenericArray)onArray)._data[index] = element; 88 return; 89 } 90 _delegate.set(onArray, index, element); 91 } 92 93 public int shape(Object [] a_flat, int a_flatElement, Object a_shaped, int[] a_dimensions, int a_currentDimension) { 94 return _delegate.shape(a_flat, a_flatElement, a_shaped, a_dimensions, a_currentDimension); 95 } 96 97 } 98 | Popular Tags |