本文整理汇总了Java中org.eclipse.emf.ecore.EObject.eGet方法的典型用法代码示例。如果您正苦于以下问题:Java EObject.eGet方法的具体用法?Java EObject.eGet怎么用?Java EObject.eGet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.emf.ecore.EObject
的用法示例。
在下文中一共展示了EObject.eGet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
}
示例2: objPath
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static void objPath(StringBuffer b, EObject obj) {
if (obj.eContainer() != null) {
objPath(b, obj.eContainer());
b.append(".");
b.append(obj.eContainingFeature().getName());
if (obj.eContainingFeature().isMany()) {
b.append("[");
b.append(((List<?>) obj.eContainer().eGet(obj.eContainingFeature())).indexOf(obj));
b.append("]");
}
b.append("->");
}
b.append(obj.eClass().getName());
EStructuralFeature nameF = obj.eClass().getEStructuralFeature("name");
Object name = nameF != null ? obj.eGet(nameF) : null;
if (name != null) {
b.append("'");
b.append(name);
b.append("'");
}
}
示例3: getName
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* @param eobj
* will be non-null and not a proxy
* @return may return null
*/
private String getName(EObject eobj) {
if (eobj != null) {
// use reflection (or duck typing) to obtain the name
EList<EAttribute> eAllAttributes = eobj.eClass().getEAllAttributes();
for (EAttribute attr : eAllAttributes) {
if ("name".equals(attr.getName())) {
final Object value = eobj.eGet(attr, false);
if (value instanceof String) {
return (String) value;
}
}
}
}
return null;
}
示例4: visit
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
public void visit(ContainerValue containerval, String param) {
Container container = (Container) containerval.getType();
EClass containerClass = this.m_typeToEcore.getContainerClass(container);
EObject containerObject = containerClass.getEPackage()
.getEFactoryInstance()
.create(containerClass);
setElement(containerval, containerObject);
this.m_eObjects.add(containerObject);
EStructuralFeature eFeature = containerClass.getEStructuralFeature("value");
@SuppressWarnings("unchecked") EList<Object> objectList =
(EList<Object>) containerObject.eGet(eFeature);
for (Value val : containerval.getValue()) {
Object eSubValue = getElement(val);
objectList.add(eSubValue);
}
}
示例5: exposeTypesReferencedBy
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static void exposeTypesReferencedBy(EObject root) {
final TreeIterator<EObject> i = root.eAllContents();
while (i.hasNext()) {
final EObject object = i.next();
for (EReference currRef : object.eClass().getEAllReferences()) {
if (!currRef.isContainment() && !currRef.isContainer()) {
final Object currTarget = object.eGet(currRef);
if (currTarget instanceof Collection<?>) {
for (Object currObj : (Collection<?>) currTarget) {
exposeType(currObj);
}
} else {
exposeType(currTarget);
}
}
}
}
}
示例6: writeEnum
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private void writeEnum(EObject object, EStructuralFeature feature) throws SerializerException, IOException {
Object val = object.eGet(feature);
if (feature.getEType().getName().equals("Tristate")) {
IfcParserWriterUtils.writePrimitive(val, outputStream);
} else {
if (val == null) {
print(DOLLAR);
} else {
if (((Enum<?>) val).toString().equals(NULL)) {
print(DOLLAR);
} else {
print(DOT);
print(val.toString());
print(DOT);
}
}
}
}
示例7: performValidation
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
protected void performValidation ( final EObject target, final EStructuralFeature feature, final ValidationContext ctx )
{
final Object service = target.eGet ( feature );
if ( service == null )
{
return;
}
if ( ! ( service instanceof HttpServiceModule ) )
{
throw new IllegalStateException ( String.format ( "Validator can only handle %s", HttpServiceModule.class.getName () ) );
}
if ( !HttpServices.isValid ( target, (HttpServiceModule)service ) )
{
ctx.add ( feature, "Selected HTTP Service is not present in the target application setup. The selected service must be either a module in the same application or in the selected configuration of the application." );
}
}
示例8: getEObject
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
protected EObject getEObject(final List<String> uriFragmentPath) {
if (uriFragmentPath.size() != 2) {
throw new AssertionError("Invalid uri fragment path:" + uriFragmentPath.stream().collect(Collectors.joining("/")));
}
if (uriFragmentPath.size() == 2) {
final EObject rootObject = getEObjectForURIFragmentRootSegment("");
final String featureName = uriFragmentPath.get(0);
final EReference feature = (EReference) rootObject.eClass().getEStructuralFeature(featureName);
final EClass eReferenceType = feature.getEReferenceType();
if (IDENTIFIABLE_ELEMENT.isSuperTypeOf(eReferenceType)) {
@SuppressWarnings("unchecked") final EList<EObject> children = (EList<EObject>) rootObject.eGet(feature);
final String name = uriFragmentPath.get(1);
return children.stream()
.filter(eObject -> name.equals(eObject.eGet(IDENTIFIABLE_ELEMENT__NAME)))
.findFirst()
.orElse(null);
}
}
return null;
}
示例9: refToStr
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private static void refToStr(EObject obj, EReference ref, String indent, Appendable buf) throws Exception {
Object o = obj.eGet(ref);
if (o instanceof EObject) {
EObject eo = (EObject) o;
if (eo instanceof ENamedElement)
buf.append("'").append(((ENamedElement) eo).getName()).append("' ");
buf.append("ref: ");
getURI(obj, eo, buf);
return;
}
if (o instanceof Collection<?>) {
String innerIndent = indent + INDENT;
buf.append("[");
int counter = 0;
Collection<?> coll = (Collection<?>) o;
for (Iterator<?> i = coll.iterator(); i.hasNext();) {
Object item = i.next();
if (counter == 0)
buf.append('\n');
buf.append(innerIndent);
printInt(counter++, coll.size(), buf);
buf.append(": ");
getURI(obj, (EObject) item, buf);
if (i.hasNext())
buf.append(",\n");
else
buf.append('\n').append(indent);
}
buf.append("]");
return;
}
buf.append("?????");
}
示例10: linkedPathname
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Similar to {@link #linkedName(IStringExpectation, ICrossEReferenceAndEObject)} but concatenating the fully
* qualified name again instead of using the qualified name provider, as the latter may not create a valid name for
* non-globally available elements.
* <p>
* The qualified name created by retrieving all "name" properties of the target and its containers, using '/' as
* separator.
*/
@Xpect
@ParameterParser(syntax = "('at' arg1=OFFSET)?")
public void linkedPathname(@StringExpectation IStringExpectation expectation,
ICrossEReferenceAndEObject arg1) {
EObject targetObject = (EObject) arg1.getEObject().eGet(arg1.getCrossEReference());
if (targetObject == null) {
Assert.fail("Reference is null");
return; // to avoid warnings in the following
}
if (targetObject.eIsProxy())
Assert.fail("Reference is a Proxy: " + ((InternalEObject) targetObject).eProxyURI());
Resource targetResource = targetObject.eResource();
if (targetResource instanceof TypeResource)
targetResource = arg1.getEObject().eResource();
if (!(targetResource instanceof XtextResource))
Assert.fail("Referenced EObject is not in an XtextResource.");
Deque<String> segments = new ArrayDeque<>();
do {
EStructuralFeature nameFeature = targetObject.eClass().getEStructuralFeature("name");
if (nameFeature != null) {
Object obj = targetObject.eGet(nameFeature);
if (obj instanceof String) {
segments.push((String) obj);
}
} else {
if (targetObject instanceof NamedElement) {
segments.push(((NamedElement) targetObject).getName());
}
}
targetObject = targetObject.eContainer();
} while (targetObject != null);
String pathname = Joiner.on('/').join(segments);
expectation.assertEquals(pathname);
}
示例11: haveEqualReference
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected boolean haveEqualReference(EObject eObject1, EObject eObject2, EReference reference) {
Object value1 = eObject1.eGet(reference, false);
Object value2 = eObject2.eGet(reference, false);
return reference.isMany() ? equals((List<EObject>) value1, (List<EObject>) value2)
: equals((EObject) value1, (EObject) value2);
}
示例12: getConnectedEdgesForEObject
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* Add outgoing references
*/
private void getConnectedEdgesForEObject(Node node, final List<Node> allNodes, final List<Edge> result,
final EObject eobj) {
for (EReference currRef : eobj.eClass().getEAllReferences()) {
if (!currRef.isDerived() && !currRef.isContainer()) {
if (currRef.isMany()) {
final Object targets = eobj.eGet(currRef, false);
if (targets instanceof Collection<?>) {
getConnectedEdgesForEObjectManyCase(node, allNodes, result, currRef, targets);
}
} else {
final Object target = eobj.eGet(currRef, false);
if (target instanceof EObject) {
getConnectedEdgesForEObjectSingleCase(node, allNodes, result, currRef, target);
}
}
}
}
// add reference to containing Resource if immediate container is not in graph
// (required when showing lower-level objects while hiding their ancestors)
Node nodeForElement = GraphUtils.getNodeForElement(eobj.eContainer(), allNodes);
if (eobj.eResource() != null && eobj.eContainer() != null && nodeForElement == null) {
final Node nodeForResource = GraphUtils.getNodeForElement(eobj.eResource(), allNodes);
if (nodeForResource != null) {
Edge edge = new Edge(
"<... containment omitted ...>",
false, // not a cross-link
nodeForResource,
Collections.singletonList(node),
Collections.emptyList());
result.add(edge);
}
}
}
示例13: writeEmbedded
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
private void writeEmbedded(EObject eObject) throws SerializerException, IOException {
EClass class1 = eObject.eClass();
print(getPackageMetaData().getUpperCase(class1));
print(OPEN_PAREN);
EStructuralFeature structuralFeature = class1.getEStructuralFeature(WRAPPED_VALUE);
if (structuralFeature != null) {
Object realVal = eObject.eGet(structuralFeature);
if (structuralFeature.getEType() == ECORE_PACKAGE_INSTANCE.getEDouble()) {
writeDoubleValue((Double)realVal, eObject, structuralFeature);
} else {
IfcParserWriterUtils.writePrimitive(realVal, outputStream);
}
}
print(CLOSE_PAREN);
}
示例14: getEMap
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@SuppressWarnings ( "unchecked" )
public EMap<String, String> getEMap ()
{
EObject container = eContainer ();
return container == null ? null : (EMap<String, String>)container.eGet ( eContainmentFeature () );
}
示例15: isValueTransient
import org.eclipse.emf.ecore.EObject; //导入方法依赖的package包/类
@Override
public ValueTransient isValueTransient(EObject semanticObject, EStructuralFeature feature) {
if (feature == OCCIPackage.Literals.ATTRIBUTE__MUTABLE) {
if (semanticObject.eContainer() instanceof Type || semanticObject.eContainer() instanceof RecordType) {
if ((boolean)semanticObject.eGet(feature)) {
return ValueTransient.NO;
}
}
}
if (feature == OCCIPackage.Literals.RESOURCE__RLINKS) {
return ValueTransient.YES;
}
return super.isValueTransient(semanticObject, feature);
}