1 16 package com.google.gwt.lang; 17 18 20 24 public final class Array { 25 26 30 public static Array initDims(String typeName, Object typeIdExprs, 31 Object queryIdExprs, Object dimExprs, Object defaultValue) { 32 return initDims(typeName, typeIdExprs, queryIdExprs, dimExprs, 0, 35 getValueCount(dimExprs), defaultValue); 36 } 37 38 42 public static final Array initValues(String typeName, int typeId, 43 int queryId, Object values) { 44 int length = getValueCount(values); 45 Array result = new Array(length, typeId, queryId, typeName); 46 for (int i = 0; i < length; ++i) { 47 _set(result, i, getValue(values, i)); 48 } 49 return result; 50 } 51 52 55 public static Object setCheck(Array array, int index, Object value) { 56 if (value != null && array.queryId != 0 57 && !Cast.instanceOf(value, array.queryId)) { 58 throw new ArrayStoreException (); 59 } 60 return _set(array, index, value); 61 } 62 63 66 private static native Object _set(Array array, int index, Object value) ; 69 70 73 private static native int getIntValue(Object values, int index) ; 76 77 80 private static native Object getValue(Object values, int index) ; 83 84 87 private static native int getValueCount(Object values) ; 90 91 95 private static Array initDims(String typeName, Object typeIdExprs, 96 Object queryIdExprs, Object dimExprs, int index, int count, 97 Object defaultValue) { 98 int length; 99 if ((length = getIntValue(dimExprs, index)) < 0) { 100 throw new NegativeArraySizeException (); 101 } 102 103 Array result = new Array(length, getIntValue(typeIdExprs, index), 104 getIntValue(queryIdExprs, index), typeName); 105 106 ++index; 107 if (index < count) { 108 typeName = typeName.substring(1); 109 for (int i = 0; i < length; ++i) { 110 _set(result, i, initDims(typeName, typeIdExprs, queryIdExprs, dimExprs, 111 index, count, defaultValue)); 112 } 113 } else { 114 for (int i = 0; i < length; ++i) { 115 _set(result, i, defaultValue); 116 } 117 } 118 119 return result; 120 } 121 122 public final int length; 123 124 protected final int queryId; 125 126 public Array(int length, int typeId, int queryId, String typeName) { 127 this.length = length; 128 this.queryId = queryId; 129 130 133 this.typeName = typeName; 134 this.typeId = typeId; 135 } 136 } 137 138 | Popular Tags |