當前位置: 首頁>>代碼示例>>Java>>正文


Java EObject.eSet方法代碼示例

本文整理匯總了Java中org.eclipse.emf.ecore.EObject.eSet方法的典型用法代碼示例。如果您正苦於以下問題:Java EObject.eSet方法的具體用法?Java EObject.eSet怎麽用?Java EObject.eSet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.emf.ecore.EObject的用法示例。


在下文中一共展示了EObject.eSet方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setAttribute

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private void setAttribute(final EObject eObject, final EAttribute eAttribute, final List<RAMLParser.IdContext> valueTokens) {
    if (eAttribute.isMany()) {
        final List<Object> values = valueTokens.stream()
                .map(v -> createFromString(eAttribute, v))
                .collect(Collectors.toList());

        eObject.eSet(eAttribute, values);
    } else {
        final String messagePattern = "Trying to set attribute {0} with many values";
        if (valueTokens.isEmpty()) {
            scope.addError(messagePattern, eAttribute);
        } else {
            scope.addError(messagePattern + " at {1}", eAttribute, valueTokens.get(0).getStart());
        }
    }
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:17,代碼來源:AbstractScopedVisitor.java

示例2: merge

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private void merge(final EObject extension, final EObject extendsEObject, final Map<String, EObject> idToEObject) {
    mergeAttributes(extension, extendsEObject);
    mergeCrossReferences(extension, extendsEObject, idToEObject);
    for (final EObject extensionChild : extension.eContents()) {
        final String uriFragment = uriFragmentBuilder.getURIFragment(extensionChild);
        if (idToEObject.containsKey(uriFragment)) {
            final EObject extendsChild = idToEObject.get(uriFragment);
            merge(extensionChild, extendsChild, idToEObject);
        } else {
            final EObject copy = copy(extensionChild);
            final EReference containmentFeature = extensionChild.eContainmentFeature();
            if (containmentFeature.isMany()) {
                final List<EObject> containment = (List<EObject>) extendsEObject.eGet(containmentFeature);
                containment.add(copy);
            } else {
                extendsEObject.eSet(containmentFeature, copy);
            }
        }
    }
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:21,代碼來源:RamlModelBuilder.java

示例3: mergeAttributes

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private void mergeAttributes(final EObject extension, final EObject extendsEObject) {
    final List<EAttribute> commonAttributes = new ArrayList<>();
    commonAttributes.addAll(extension.eClass().getEAllAttributes());
    commonAttributes.retainAll(extendsEObject.eClass().getEAllAttributes());

    final List<EAttribute> nonDerivedAttributes = commonAttributes.stream()
            .filter(a -> !a.isDerived())
            .collect(Collectors.toList());
    for (final EAttribute attribute : nonDerivedAttributes) {
        if (extension.eIsSet(attribute)) {
            final Object attributeValue = extension.eGet(attribute);
            if (attribute.isMany()) {
                final List<Object> values = (List<Object>) extendsEObject.eGet(attribute);
                final List<Object> mergeAttributeValues = (List<Object>) attributeValue;
                for (final Object mergeAttributeValue : mergeAttributeValues) {
                    if (!values.contains(mergeAttributeValue)) {
                        values.add(mergeAttributeValue);
                    }
                }
            } else {
                extendsEObject.eSet(attribute, attributeValue);
            }
        }
    }
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:26,代碼來源:RamlModelBuilder.java

示例4: createEReferenceByAtoms

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
@SuppressWarnings({"unchecked", "rawtypes"})
private void createEReferenceByAtoms(String refName, String fromAtom, String toAtom)
    throws TraceException {
  EObject sourceAtom = atom2EClass.get(fromAtom);
  EObject targetAtom = atom2EClass.get(toAtom);
  for (EReference eReference : sourceAtom.eClass().getEAllReferences()) {
    if (eReference.getName().equals(refName)) {
      if (eReference.isMany()) {
        ((List) sourceAtom.eGet(eReference)).add(targetAtom);
      } else {
        sourceAtom.eSet(eReference, targetAtom);
      }
      break;
    }
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:17,代碼來源:AlloyToEMF.java

示例5: createAndSetProxy

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 * Creates a proxy instance that will later on allow to lazily resolve the semantically referenced instance for the
 * given {@link CrossReference xref}.
 */
@SuppressWarnings("unchecked")
private void createAndSetProxy(N4JSResource resource, EObject obj, INode node, EReference eRef,
		CrossReference xref,
		IDiagnosticProducer diagnosticProducer) {
	final EObject proxy = createProxy(resource, obj, node, eRef, xref, diagnosticProducer);
	proxy.eSetDeliver(false);
	if (eRef.isMany()) {
		((InternalEList<EObject>) obj.eGet(eRef, false)).addUnique(proxy);
	} else {
		obj.eSet(eRef, proxy);
	}
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:17,代碼來源:N4JSLinker.java

示例6: readReference

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
private void readReference(String val, EObject object, EStructuralFeature structuralFeature) throws DeserializeException {
	int referenceId;
	try {
		referenceId = Integer.parseInt(val.substring(1));
	} catch (NumberFormatException e) {
		throw new DeserializeException(lineNumber, "'" + val + "' is not a valid reference");
	}
	if (model.contains(referenceId)) {
		object.eSet(structuralFeature, model.get(referenceId));
	} else {
		waitingList.add(referenceId, new SingleWaitingObject(lineNumber, object, (EReference) structuralFeature));
	}
}
 
開發者ID:shenan4321,項目名稱:BIMplatform,代碼行數:14,代碼來源:IfcStepDeserializer.java

示例7: replaceName

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
protected void replaceName ( final EObject object, final EStructuralFeature feature )
{
    final String hostname = (String)object.eGet ( feature );

    if ( hostname == null )
    {
        return;
    }

    final Mappings mappings = getMappings ();

    for ( final MappingEntry entry : mappings.getEntries () )
    {
        final String newName = entry.map ( hostname );
        if ( newName != null )
        {
            object.eSet ( feature, newName );
            return;
        }
    }

    switch ( mappings.getFallbackMode () )
    {
        case IGNORE:
            return;
        case FAIL:
            throw new IllegalStateException ( String.format ( "No node mapping for: %s", hostname ) );
    }
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:30,代碼來源:AbstractMapper.java

示例8: createInitialModel

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 * Create a new model.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
protected EObject createInitialModel ()
{
    EClass eClass = ExtendedMetaData.INSTANCE.getDocumentRoot ( configurationPackage );
    EStructuralFeature eStructuralFeature = eClass.getEStructuralFeature ( initialObjectCreationPage.getInitialObjectName () );
    EObject rootObject = configurationFactory.create ( eClass );
    rootObject.eSet ( eStructuralFeature, EcoreUtil.create ( (EClass)eStructuralFeature.getEType () ) );
    return rootObject;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:15,代碼來源:ConfigurationModelWizard.java

示例9: createAndCopy

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
protected EObject createAndCopy(final EObject eObject, final ParserRuleContext ruleContext) {
    final EClass eClass = eObject.eClass();
    final EObject newEObject = create(eClass, ruleContext);
    final Consumer<EAttribute> copyAttribute = attribute -> newEObject.eSet(attribute, eObject.eGet(attribute));
    eClass.getEAllAttributes().forEach(copyAttribute);

    return newEObject;
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:9,代碼來源:AbstractConstructor.java

示例10: visitArrayType

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
@Override
public EObject visitArrayType(final TypeExpressionParser.ArrayTypeContext ctx) {
    final EObject arrayType = EcoreUtil.create(arrayTypeDeclarationType);
    scope.addValue(INLINE_TYPE_CONTAINER__INLINE_TYPES, arrayType);
    final EObject itemsType = visit(ctx.primary_type_expr());
    arrayType.eSet(itemsFeature, itemsType);

    return arrayType;
}
 
開發者ID:vrapio,項目名稱:rest-modeling-framework,代碼行數:10,代碼來源:TypeExpressionConstructor.java

示例11: visit

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
@Override
public void visit(TupleValue tupleval, String param) {
    if (hasElement(tupleval)) {
        return;
    }

    Tuple tuple = (Tuple) tupleval.getType();
    EClass tupleClass = this.m_typeToEcore.getTupleClass(tuple);

    EObject tupleObject = tupleClass.getEPackage()
        .getEFactoryInstance()
        .create(tupleClass);
    setElement(tupleval, tupleObject);
    this.m_eObjects.add(tupleObject);

    for (Entry<Integer,Value> entry : tupleval.getValue()
        .entrySet()) {
        String indexName = this.m_typeToEcore.getTupleElementName(tuple, entry.getKey());
        EStructuralFeature eFeature = tupleClass.getEStructuralFeature(indexName);
        Value tupValue = entry.getValue();
        if (eFeature.isMany()) {
            // Expecting a container value, which will be iterated with all elements added to the (implicit) ELIST
            ContainerValue cv = (ContainerValue) tupValue;
            @SuppressWarnings("unchecked") EList<Object> objectList =
                (EList<Object>) tupleObject.eGet(eFeature);
            for (Value subValue : cv.getValue()) {
                Object eSubValue = getElement(subValue);
                objectList.add(eSubValue);
            }
        } else {
            // Just insert the value directly
            Object eValue = getElement(tupValue);
            tupleObject.eSet(eFeature, eValue);
        }
    }
}
 
開發者ID:meteoorkip,項目名稱:JavaGraph,代碼行數:37,代碼來源:InstanceToEcore.java

示例12: putIntoContainer

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 * Puts given dynamic EObject to corresponding container
 * 
 * @param container
 * @param eObject
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static void putIntoContainer(EObject container, EObject eObject) {
  for (EReference eReference : container.eClass().getEAllReferences()) {
    if (eObject.eClass().getName().equals(eReference.getEReferenceType().getName())) {
      if (eReference.isMany())
        ((List) container.eGet(eReference)).add(eObject);
      else
        container.eSet(eReference, eObject);
      break;
    }
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:19,代碼來源:AlloyToEMF.java

示例13: eSetAttributeByName

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 *
 * @param @EObject object to be set
 * @param name reference name
 * @param newVal new value
 */
public static void eSetAttributeByName(final EObject eObject, final String name,
    final Object newVal) {
  for (final EAttribute eAttribute : eObject.eClass().getEAllAttributes()) {
    if (eAttribute.getName().equals(name)) {
      eObject.eSet(eAttribute, newVal);
      break;
    }
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:16,代碼來源:EcoreUtilities.java

示例14: eSetReferenceByName

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 *
 * @param @EObject object to be set
 * @param name reference name
 * @param newVal new value
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static void eSetReferenceByName(final EObject eObject, final String name,
    final Object newVal) {
  for (final EReference eReference : eObject.eClass().getEAllReferences()) {
    if (eReference.getName().equals(name)) {
      if (eReference.isMany()) {
        ((List) eObject.eGet(eReference)).add(newVal);
      } else {
        eObject.eSet(eReference, newVal);
      }
      break;
    }
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:21,代碼來源:EcoreUtilities.java

示例15: eSetStructuralFeatureByName

import org.eclipse.emf.ecore.EObject; //導入方法依賴的package包/類
/**
 *
 * @param @EObject object to be set
 * @param name structural feature name
 * @param newVal new value
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public static void eSetStructuralFeatureByName(final EObject eObject, final String name,
    final Object newVal) {
  for (final EStructuralFeature eStructuralFeature : eObject.eClass().getEAllStructuralFeatures()) {
    if (eStructuralFeature.getName().equals(name)) {
      if (eStructuralFeature.isMany()) {
        ((List) eObject.eGet(eStructuralFeature)).add(newVal);
      } else {
        eObject.eSet(eStructuralFeature, newVal);
      }
      break;
    }
  }
}
 
開發者ID:ModelWriter,項目名稱:Tarski,代碼行數:21,代碼來源:EcoreUtilities.java


注:本文中的org.eclipse.emf.ecore.EObject.eSet方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。