Java Code Examples for org.eclipse.emf.ecore.util.FeatureMap#Entry

The following examples show how to use org.eclipse.emf.ecore.util.FeatureMap#Entry . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractHiveFactory.java    From neoscada with Eclipse Public License 1.0 6 votes vote down vote up
protected Object getConfigurationData ( final HiveConfigurationType configuration )
{
    for ( FeatureMap.Entry entry : configuration.getAny () )
    {
        if ( entry.getValue () instanceof EObject )
        {
            return entry.getValue ();
        }
        else if ( FeatureMapUtil.isText ( entry ) )
        {
            return entry.getValue ();
        }
        else if ( FeatureMapUtil.isCDATA ( entry ) )
        {
            return entry.getValue ();
        }
    }
    return null;
}
 
Example 2
Source File: DefaultEObjectLabelProvider.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
protected EStructuralFeature getLabelFeature(EClass eClass) {
	EAttribute result = null;
	for (EAttribute eAttribute : eClass.getEAllAttributes()) {
		if (!eAttribute.isMany() && eAttribute.getEType().getInstanceClass() != FeatureMap.Entry.class) {
			if ("name".equalsIgnoreCase(eAttribute.getName())) {
				result = eAttribute;
				break;
			} else if (result == null) {
				result = eAttribute;
			} else if (eAttribute.getEAttributeType().getInstanceClass() == String.class
					&& result.getEAttributeType().getInstanceClass() != String.class) {
				result = eAttribute;
			}
		}
	}
	return result;
}
 
Example 3
Source File: DerivedEObjectEList.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected boolean scanNext(EStructuralFeature nextFeature,
		ListIterator<Object> nextValuesIterator) {
	boolean isFeatureMap = FeatureMapUtil.isFeatureMap(nextFeature);

	while (nextValuesIterator.hasNext()) {
		Object nextValue = nextValuesIterator.next();

		if (isFeatureMap) {
			FeatureMap.Entry entry = (FeatureMap.Entry) nextValue;
			nextFeature = entry.getEStructuralFeature();
			nextValue = entry.getValue();
		}

		if ((isIncluded(nextFeature) ? nextValue != null
				: isIncluded(nextValue))
				&& ((index < preparedValues.size() && nextValue == preparedValues
						.get(index)) || preparedValues.add(nextValue))) {

			valuesIterator = nextValuesIterator;
			preparedFeature = nextFeature;
			return true;
		}
	}

	return false;
}
 
Example 4
Source File: DerivedEObjectEList.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
protected boolean scanPrevious(EStructuralFeature previousFeature,
		ListIterator<Object> previousValuesIterator) {
	boolean isFeatureMap = FeatureMapUtil.isFeatureMap(previousFeature);

	while (previousValuesIterator.hasPrevious()) {
		Object previousValue = previousValuesIterator.previous();

		if (isFeatureMap) {
			FeatureMap.Entry entry = (FeatureMap.Entry) previousValue;
			previousFeature = entry.getEStructuralFeature();
			previousValue = entry.getValue();
		}

		if (index > 0 && previousValue == preparedValues.get(index - 1)) {
			valuesIterator = previousValuesIterator;
			preparedFeature = previousFeature;
			return true;
		}
	}

	return false;
}
 
Example 5
Source File: DocumentationImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public String getText() {
	
	
	 if (mixed != null && !mixed.isEmpty()) {
         StringBuilder result = new StringBuilder();
         if(mixed.size()>0){
        	 FeatureMap.Entry cur = mixed.get(0);
             result.append(cur.getValue());
             
             return result.toString();
         }
        
     }

     return null;
	
	/*
	
    if (mixed != null) {
        StringBuilder result = new StringBuilder();
        for (FeatureMap.Entry cur : mixed) {
            switch (cur.getEStructuralFeature().getFeatureID()) {
            case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
            case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
                result.append(cur.getValue());
                break;

            default:
                break;
            }
        }
        return result.toString();
    }

    return null;*/
}
 
Example 6
Source File: FormalExpressionImpl.java    From fixflow with Apache License 2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated NOT
 */
public String getBody() {
	
	
	 if (mixed != null && !mixed.isEmpty()) {
         StringBuilder result = new StringBuilder();
         if(mixed.size()>0){
        	 FeatureMap.Entry cur = mixed.get(0);
             result.append(cur.getValue());
             
             return result.toString();
         }
        
     }

     return null;
	
	/*
    if (mixed != null && !mixed.isEmpty()) {
        StringBuilder result = new StringBuilder();
        for (FeatureMap.Entry cur : mixed) {
            switch (cur.getEStructuralFeature().getFeatureID()) {
            case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__CDATA:
            case XMLTypePackage.XML_TYPE_DOCUMENT_ROOT__TEXT:
                result.append(cur.getValue());
                break;

            default:
                break;
            }
        }
        return result.toString();
    }

    return null;
    */
}
 
Example 7
Source File: BpmnModelUtil.java    From fixflow with Apache License 2.0 5 votes vote down vote up
/**
 * 增加扩展元素
 * @param baseElement
 * @param eReference
 * @param o
 * @return
 */
public static boolean addExtensionElement(BaseElement baseElement,EReference eReference,Object o){
	final FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((org.eclipse.emf.ecore.EStructuralFeature.Internal) eReference, o);
 	  	if(baseElement.getExtensionValues().size() > 0){
 	  		baseElement.getExtensionValues().get(0).getValue().add(extensionElementEntry);
 	  	}else{
 	  		ExtensionAttributeValue extensionElement = Bpmn2Factory.eINSTANCE.createExtensionAttributeValue();
 	  		extensionElement.getValue().add(extensionElementEntry);
 	  		baseElement.getExtensionValues().add(extensionElement);
 	  	} 
	return false;
}
 
Example 8
Source File: XPDLToProc.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param performerAssign
 * @return
 */
private String getPerformerAssignValue(ExtendedAttributeType performerAssign) {
    for (final FeatureMap.Entry entry : performerAssign.getMixed()) {
        if (entry.getValue() instanceof AnyType) {
            final AnyType any = (AnyType) entry.getValue();
            final String tag = entry.getEStructuralFeature().getName();
            if (tag.toLowerCase().equals("callback") || tag.toLowerCase().equals("custom")) {
                return (String) any.getMixed().get(0).getValue();
            }
        }
    }
    return null;
}
 
Example 9
Source File: XPDLToProc.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param hook
 * @return
 */
private ConnectorEvent getEvent(ExtendedAttributeType hook) {
    for (final FeatureMap.Entry entry : hook.getMixed()) {
        if (entry.getValue() instanceof AnyType) {
            final AnyType any = (AnyType) entry.getValue();
            final String tag = entry.getEStructuralFeature().getName();
            if (tag.equals("HookEventName")) {
                final String hookEventName = (String) any.getMixed().get(0).getValue();
                if (hookEventName.equals("task:onReady")) {
                    return ConnectorEvent.ON_ENTER;
                } else if (hookEventName.equals("task:onStart")) {
                    return ConnectorEvent.ON_ENTER;
                } else if (hookEventName.equals("task:onFinish")) {
                    return ConnectorEvent.ON_FINISH;
                } else if (hookEventName.equals("task:onSuspend")) {
                    return ConnectorEvent.ON_ENTER;
                } else if (hookEventName.equals("task:onResume")) {
                    return ConnectorEvent.ON_ENTER;
                } else if (hookEventName.equals("task:onCancel")) {
                    return ConnectorEvent.ON_ENTER;
                } else if (hookEventName.equals("automatic:onEnter")) {
                    return ConnectorEvent.ON_ENTER;
                }
            }
        }
    }
    return null;
}
 
Example 10
Source File: BPMNToProc.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected String retrieveDocumentation(final TBaseElement baseElement) {
    final StringBuilder sb = new StringBuilder();
    for (final TDocumentation doc : baseElement.getDocumentation()) {
        final Iterator<org.eclipse.emf.ecore.util.FeatureMap.Entry> iterator = doc
                .getMixed().iterator();
        while (iterator.hasNext()) {
            final FeatureMap.Entry entry = iterator.next();
            if (FeatureMapUtil.isText(entry)) {
                sb.append(entry.getValue()).append("\n");
            }
        }
    }
    final String documentation = sb.toString();
    return documentation;
}
 
Example 11
Source File: OrderedEmfFormatter.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
private static void objToStrImpl(Object obj, String indent, Appendable buf) throws Exception {
	String innerIdent = INDENT + indent;
	if (obj instanceof EObject) {
		EObject eobj = (EObject) obj;
		buf.append(eobj.eClass().getName()).append(" {\n");
		for (EStructuralFeature f : getAllFeatures(eobj.eClass())) {
			if (!eobj.eIsSet(f))
				continue;
			buf.append(innerIdent);
			if (f instanceof EReference) {
				EReference r = (EReference) f;
				if (r.isContainment()) {
					buf.append("cref ");
					buf.append(f.getEType().getName()).append(SPACE);
					buf.append(f.getName()).append(SPACE);
					objToStrImpl(eobj.eGet(f), innerIdent, buf);
				} else {
					buf.append("ref ");
					buf.append(f.getEType().getName()).append(SPACE);
					buf.append(f.getName()).append(SPACE);
					refToStr(eobj, r, innerIdent, buf);
				}
			} else if (f instanceof EAttribute) {
				buf.append("attr ");
				buf.append(f.getEType().getName()).append(SPACE);
				buf.append(f.getName()).append(SPACE);
				// logger.debug(Msg.create("Path:").path(eobj));
				Object at = eobj.eGet(f);
				if (eobj != at)
					objToStrImpl(at, innerIdent, buf);
				else
					buf.append("<same as container object>");
			} else {
				buf.append("attr ");
				buf.append(f.getEType().getName()).append(SPACE);
				buf.append(f.getName()).append(" ??????");
			}
			buf.append('\n');
		}
		buf.append(indent).append("}");
		return;
	}
	if (obj instanceof FeatureMap.Entry) {
		FeatureMap.Entry e = (FeatureMap.Entry) obj;
		buf.append(e.getEStructuralFeature().getEContainingClass().getName());
		buf.append(".");
		buf.append(e.getEStructuralFeature().getName());
		buf.append("->");
		objToStrImpl(e.getValue(), innerIdent, buf);
		return;
	}
	if (obj instanceof Collection<?>) {
		int counter = 0;
		Collection<?> coll = (Collection<?>) obj;
		buf.append("[\n");
		for (Object o : coll) {
			buf.append(innerIdent);
			printInt(counter++, coll.size(), buf);
			buf.append(": ");
			objToStrImpl(o, innerIdent, buf);
			buf.append("\n");
		}
		buf.append(indent + "]");
		return;
	}
	if (obj != null) {
		buf.append("'").append(Strings.notNull(obj)).append("'");
		return;
	}
	buf.append("null");
}
 
Example 12
Source File: EmfFormatter.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
private static void objToStrImpl(Object obj, String indent, Appendable buf, Predicate<EStructuralFeature> ignoredFeatures) throws Exception {
	String innerIdent = INDENT + indent;
	if (obj instanceof EObject) {
		EObject eobj = (EObject) obj;
		buf.append(eobj.eClass().getName()).append(" {\n");
		for (EStructuralFeature f : eobj.eClass().getEAllStructuralFeatures()) {
			if (!eobj.eIsSet(f) || ignoredFeatures.apply(f))
				continue;
			buf.append(innerIdent);
			if (f instanceof EReference) {
				EReference r = (EReference) f;
				if (r.isContainment()) {
					buf.append("cref ");
					buf.append(f.getEType().getName()).append(SPACE);
					buf.append(f.getName()).append(SPACE);
					objToStrImpl(eobj.eGet(f), innerIdent, buf, ignoredFeatures);
				} else {
					buf.append("ref ");
					buf.append(f.getEType().getName()).append(SPACE);
					buf.append(f.getName()).append(SPACE);
					refToStr(eobj, r, innerIdent, buf);
				}
			} else if (f instanceof EAttribute) {
				buf.append("attr ");
				buf.append(f.getEType().getName()).append(SPACE);
				buf.append(f.getName()).append(SPACE);
				// logger.debug(Msg.create("Path:").path(eobj));
				Object at = eobj.eGet(f);
				if (eobj != at)
					objToStrImpl(at, innerIdent, buf, ignoredFeatures);
				else
					buf.append("<same as container object>");
			} else {
				buf.append("attr ");
				buf.append(f.getEType().getName()).append(SPACE);
				buf.append(f.getName()).append(" ??????");
			}
			buf.append('\n');
		}
		buf.append(indent).append("}");
		return;
	}
	if(obj instanceof FeatureMap.Entry) {
		FeatureMap.Entry e = (FeatureMap.Entry)obj;
		buf.append(e.getEStructuralFeature().getEContainingClass().getName());
		buf.append(".");
		buf.append(e.getEStructuralFeature().getName());
		buf.append("->");
		objToStrImpl(e.getValue(), innerIdent, buf, ignoredFeatures);
		return ;
	}
	if (obj instanceof Collection<?>) {
		int counter = 0;
		Collection<?> coll = (Collection<?>) obj;
		buf.append("[\n");
		for (Object o : coll) {
			buf.append(innerIdent);
			printInt(counter++, coll.size(), buf);
			buf.append(": ");
			objToStrImpl(o, innerIdent, buf, ignoredFeatures);
			buf.append("\n");
		}
		buf.append(indent + "]");
		return;
	}
	if (obj != null) {
		buf.append("'").append(Strings.notNull(obj)).append("'");
		return;
	}
	buf.append("null");
}
 
Example 13
Source File: BpmnModelUtil.java    From fixflow with Apache License 2.0 2 votes vote down vote up
/**
 * 增加擴展屬性
 * @param baseElement
 * @param eReference
 * @param o
 * @return
 */
public static boolean addExtensionAttribute(BaseElement baseElement,EAttribute eAttribute,Object o){
	final FeatureMap.Entry extensionElementEntry = new SimpleFeatureMapEntry((org.eclipse.emf.ecore.EStructuralFeature.Internal) eAttribute, o);
	baseElement.getAnyAttribute().add(extensionElementEntry);
	return false;
}