Exemplo n.º 1
0
 protected EClassifier getTypeFromBeanField() {
   EClassifier type = null;
   Field field = getField();
   if (field != null) type = field.getEType();
   if (type == null) type = getKeyFieldTypeFromKeyClass();
   return type;
 }
Exemplo n.º 2
0
  /**
   * @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;
  }
Exemplo n.º 3
0
 /** @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;
 }