protected EClassifier getTypeFromBeanField() { EClassifier type = null; Field field = getField(); if (field != null) type = field.getEType(); if (type == null) type = getKeyFieldTypeFromKeyClass(); return type; }
/** * @deprecated - With EJB 2.0, assuming a Java field is no longer safe. Use getType() and * getName() to get the most common field info. Or use getEjbClass() to get additional Java * info. */ public Field getField() { ContainerManagedEntity ejb = getCMPEntity(); if (ejb == null) return null; Field field = null; switch (ejb.getVersionID()) { case J2EEVersionConstants.EJB_1_0_ID: case J2EEVersionConstants.EJB_1_1_ID: field = findExistingField(); // Set the field type based on the attribute type if necessary if (field != null && getEType() != null && field.getEType() == null) field.setEType(getEType()); break; case J2EEVersionConstants.EJB_2_0_ID: case J2EEVersionConstants.EJB_2_1_ID: default: field = ((JavaRefPackage) EPackage.Registry.INSTANCE.getEPackage(JavaRefPackage.eNS_URI)) .getJavaRefFactory() .createField(); field.setName(getName()); field.setEType(getAccessorType()); break; } return field; }
/** * getParentType - return the Class which corresponds to our parent JavaClass we're going to do * this a lot, so cache it. */ protected Class getParentType() { if (parentType == null) { Field targetField = (Field) getTarget(); JavaClass parentJavaClass = targetField.getJavaClass(); JavaClassJDKAdaptor pa = (JavaClassJDKAdaptor) EcoreUtil.getAdapter(parentJavaClass.eAdapters(), ReadAdaptor.TYPE_KEY); if (pa != null) parentType = pa.getSourceType(); } return parentType; }
/** @return */ private EClassifier getKeyFieldTypeFromKeyClass() { if (isKey()) { JavaClass key = getCMPEntity().getPrimaryKey(); if (key != null && key.getQualifiedName() != null && !key.getQualifiedName().startsWith("java.lang")) { // $NON-NLS-1$ Field field = key.getFieldExtended(getName()); if (field != null) return field.getEType(); } else return key; } return null; }
/** setModifiers - set the attribute values related to modifiers here */ protected void setModifiers() { Field javaFieldTarget = (Field) getTarget(); // For JDK reflection, I don't think we can set the initializer int modifiers = getSourceField().getModifiers(); javaFieldTarget.setStatic(java.lang.reflect.Modifier.isStatic(modifiers)); javaFieldTarget.setTransient(java.lang.reflect.Modifier.isTransient(modifiers)); javaFieldTarget.setVolatile(java.lang.reflect.Modifier.isVolatile(modifiers)); javaFieldTarget.setFinal(java.lang.reflect.Modifier.isFinal(modifiers)); // Set visibility if (java.lang.reflect.Modifier.isPublic(modifiers)) javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL); else if (java.lang.reflect.Modifier.isPrivate(modifiers)) javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PRIVATE_LITERAL); else if (java.lang.reflect.Modifier.isProtected(modifiers)) javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PROTECTED_LITERAL); else javaFieldTarget.setJavaVisibility(JavaVisibilityKind.PACKAGE_LITERAL); }