예제 #1
0
 private void write(PrintWriter out, IdEObject object) throws SerializerException {
   EClass eClass = object.eClass();
   if (eClass.getEAnnotation("hidden") != null) {
     return;
   }
   out.print(DASH);
   int convertedKey = getExpressId(object);
   if (convertedKey == -1) {
     throw new SerializerException(
         "Going to serialize an object with id -1 (" + object.eClass().getName() + ")");
   }
   out.print(String.valueOf(convertedKey));
   out.print("= ");
   String upperCase = upperCases.get(eClass);
   if (upperCase == null) {
     throw new SerializerException("Type not found: " + eClass.getName());
   }
   out.print(upperCase);
   out.print(OPEN_PAREN);
   boolean isFirst = true;
   for (EStructuralFeature feature : eClass.getEAllStructuralFeatures()) {
     if (!feature.isDerived() && feature.getEAnnotation("hidden") == null) {
       EClassifier type = feature.getEType();
       if (type instanceof EEnum) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEnum(out, object, feature);
         isFirst = false;
       } else if (type instanceof EClass) {
         if (!isInverse(feature)) {
           if (!isFirst) {
             out.print(COMMA);
           }
           writeEClass(out, object, feature);
           isFirst = false;
         }
       } else if (type instanceof EDataType) {
         if (!isFirst) {
           out.print(COMMA);
         }
         writeEDataType(out, object, feature);
         isFirst = false;
       }
     }
   }
   out.println(PAREN_CLOSE_SEMICOLON);
 }
예제 #2
0
 public PropertiesEditionComponent genClass2Component(GenClass genClass, GenPackage genPackage) {
   PropertiesEditionComponent component =
       ComponentsFactory.eINSTANCE.createPropertiesEditionComponent();
   component.setName(genClass.getEcoreClass().getName());
   component.setModel(genClass.getEcoreClass());
   List<ViewElement> list = workingResolvTemp.get(genClass.getEcoreClass());
   for (ViewElement viewElement : list) {
     component.getViews().add((View) viewElement);
   }
   for (EStructuralFeature feature : genClass.getEcoreClass().getEAllStructuralFeatures()) {
     if (isSignificant(feature)
         && !feature.isDerived()
         && !inheritedMember(feature, genClass.getEcoreClass())) {
       PropertiesEditionElement structuralFeature2EditionElement =
           eStructuralFeature2EditionElement(list, feature);
       if (structuralFeature2EditionElement != null)
         component.getProperties().add(structuralFeature2EditionElement);
     }
   }
   return component;
 }
 /**
  * Returns whether an EStructuralFeature is valid for an EObject or not. A reference is valid, if
  * it can be set or added to.
  *
  * @param feature the EStructuralFeature in question
  * @param eObject the EObject to check the feature for
  * @param exceptionLog the current log of exceptions
  * @param ignoreAndLog should exceptions be ignored and added to <code>exceptionLog</code>?
  * @return if the feature can be set or added to
  */
 public static boolean isValid(
     EStructuralFeature feature,
     EObject eObject,
     Set<RuntimeException> exceptionLog,
     boolean ignoreAndLog) {
   boolean result = false;
   try {
     if (feature.isMany()) {
       // has the maximum amount of referenced objects been reached?
       Collection<?> referencedItems = (Collection<?>) eObject.eGet(feature);
       if (feature.getUpperBound() >= 0 && referencedItems.size() >= feature.getUpperBound()) {
         return false;
       }
     }
     // can the feature be changed reflectively?
     result = feature.isChangeable() && !feature.isVolatile() && !feature.isDerived();
   } catch (RuntimeException e) {
     handle(e, exceptionLog, ignoreAndLog);
   }
   return result;
 }