public boolean hasReflectionSource() { // This method is used to determine if valid, so we pass on to use the final component. ArrayType jh = (ArrayType) getTarget(); JavaHelpers fc = jh.getFinalComponentType(); return (fc.isPrimitive() || ((JavaClass) fc).isExistingType()); }
public Class getType(JavaHelpers modelClass) { Class result = null; if (modelClass.isArray()) { ArrayType arrayType = (ArrayType) modelClass; Class componentClass = getType(arrayType.getFinalComponentType()); result = (Array.newInstance(componentClass, new int[arrayType.getArrayDimensions()])).getClass(); } else if (modelClass.isPrimitive()) { result = getType(modelClass.getQualifiedName()); } else { result = getType(((JavaClass) modelClass).getQualifiedNameForReflection()); } return result; } public Class getType(String qualifiedName) {
public EClassifier getArrayType(String typeName) { ArrayType arrayType = this.createArrayType(); arrayType.setName(typeName); // ((InternalEObject)arrayType).eSetID(typeName); //arrayType.eSetUUID((UUID) null); int pos = -1, braces = 0; do { pos = typeName.indexOf("[", pos+1);//$NON-NLS-1$ if (pos != -1) braces++; } while (pos != -1); arrayType.setArrayDimensions(braces); //arrayType.setEPackage(getPackage()); getPackage().getEClassifiers().add(arrayType); resource.setID(arrayType, typeName); return arrayType; } /*
if(array.isPrimitiveArray()) { return true; cl = array.getFinalComponentType();
public ArrayType createArrayType(JavaHelpers componentType) { ArrayType at = createArrayType(); String computedName = componentType.getQualifiedName() + "[]"; at.setName(computedName); return at; } public ArrayType createArrayType(JavaHelpers finalComponentType, int dimensions) {
public ArrayType createArrayType(JavaHelpers finalComponentType, int dimensions) { ArrayType at = createArrayType(); String computedName = finalComponentType.getQualifiedName(); for (int i = 0; i < dimensions; i++){ computedName = computedName + "[]"; } at.setName(computedName); return at; }
public boolean hasCachedReflectionSource() { ArrayType jh = (ArrayType) getTarget(); JavaHelpers fc = jh.getFinalComponentType(); if(fc.isPrimitive()) return true; else { JavaReflectionAdaptor reflectionAdaptor = (JavaReflectionAdaptor) EcoreUtil.getExistingAdapter(fc, ReflectionAdaptor.TYPE_KEY); return (reflectionAdaptor != null) ? reflectionAdaptor.hasCachedReflectionSource() : false; } }
return isSameType(ownerArray.getFinalComponentType(), objectArray.getFinalComponentType());
/** * Returns true if the type is either the compare type, or inherits/extends the compare type. */ public static boolean isAssignableFrom(JavaHelpers type, JavaHelpers compareType) { if((type == null) || (compareType == null)) { return false; } if(type.isPrimitive() || compareType.isPrimitive()) { if(type.isPrimitive() && compareType.isPrimitive()) { return type.getPrimitive().equals(compareType.getPrimitive()); } return false; } else if(type.isArray() && compareType.isArray()) { JavaClass classType = type.getWrapper(); JavaClass classCompareType = compareType.getWrapper(); if((classType == null) || (compareType == null)) { return false; } JavaHelpers finalType = ((ArrayType)classType).getFinalComponentType(); JavaHelpers finalCompareType = ((ArrayType)classCompareType).getFinalComponentType(); return isAssignableFrom(finalType, finalCompareType); } else { return compareType.getWrapper().isAssignableFrom(type.getWrapper()); } }
if(type.isArray()) { ArrayType array = (ArrayType)type; isValidType(array.getFinalComponentType());