当前位置: 首页>>代码示例>>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;未经允许,请勿转载。