Search in sources :

Example 21 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project mylyn.docs by eclipse.

the class PublicationProxy method getRights.

@SuppressWarnings("rawtypes")
public String getRights() {
    EList<Rights> rights = publication.getPackage().getMetadata().getRights();
    if (rights.size() > 0) {
        FeatureMap fm = rights.get(0).getMixed();
        Object o = fm.get(TEXT, false);
        if (o instanceof FeatureEList) {
            if (((FeatureEList) o).size() > 0) {
                return ((FeatureEList) o).get(0).toString();
            }
        }
    }
    return EMPTY_STRING;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) FeatureEList(org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList) Rights(org.eclipse.mylyn.docs.epub.dc.Rights)

Example 22 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project mylyn.docs by eclipse.

the class PublicationProxy method getCreator.

/**
 * Returns the name of the first instance of an {@link Creator} in the publication. If a value has not been assigned
 * an empty string will be returned.
 *
 * @return the creator name
 */
@SuppressWarnings("rawtypes")
public String getCreator() {
    EList<Creator> creators = publication.getPackage().getMetadata().getCreators();
    if (creators.size() > 0) {
        FeatureMap fm = creators.get(0).getMixed();
        Object o = fm.get(TEXT, false);
        if (o instanceof FeatureEList) {
            if (((FeatureEList) o).size() > 0) {
                return ((FeatureEList) o).get(0).toString();
            }
        }
    }
    return EMPTY_STRING;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) FeatureEList(org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList) Creator(org.eclipse.mylyn.docs.epub.dc.Creator)

Example 23 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project mylyn.docs by eclipse.

the class TestOPSPublication method getText.

@SuppressWarnings("rawtypes")
public String getText(Object element) {
    if (element instanceof NavPoint) {
        FeatureMap fm = ((NavPoint) element).getNavLabels().get(0).getText().getMixed();
        Object o = fm.get(TEXT, false);
        if (o instanceof FeatureEList) {
            if (((FeatureEList) o).size() > 0) {
                return ((FeatureEList) o).get(0).toString();
            }
        }
    }
    if (element instanceof Meta) {
        Object o = ((Meta) element).getContent();
        return o.toString();
    }
    return "null";
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) FeatureEList(org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList) Meta(org.eclipse.mylyn.docs.epub.ncx.Meta) NavPoint(org.eclipse.mylyn.docs.epub.ncx.NavPoint)

Example 24 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project statecharts by Yakindu.

the class DerivedEObjectEList method size.

@Override
public int size() {
    if (sourceFeatureIDs != null) {
        EList<Object> values = new UniqueEList.FastCompare<Object>();
        for (int i = 0; i < sourceFeatureIDs.length; i++) {
            int sourceFeatureID = sourceFeatureIDs[i];
            if (owner.eIsSet(sourceFeatureID)) {
                EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
                Object value = owner.eGet(sourceFeatureID, false, true);
                if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
                    FeatureMap featureMap = (FeatureMap) value;
                    for (int j = 0, size = featureMap.size(); j < size; j++) {
                        value = featureMap.getValue(j);
                        if (isIncluded(featureMap.getEStructuralFeature(j)) ? value != null : isIncluded(value)) {
                            values.add(value);
                        }
                    }
                } else if (isIncluded(sourceFeature)) {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                values.add(valuesList.basicGet(j));
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                values.add(v.next());
                            }
                        }
                    } else if (value != null) {
                        values.add(value);
                    }
                } else {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                value = valuesList.basicGet(j);
                                if (isIncluded(value)) {
                                    values.add(value);
                                }
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                value = v.next();
                                if (isIncluded(value)) {
                                    values.add(value);
                                }
                            }
                        }
                    } else if (isIncluded(value)) {
                        values.add(value);
                    }
                }
            }
        }
        return values.size();
    }
    return 0;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) RandomAccess(java.util.RandomAccess) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject)

Example 25 with FeatureMap

use of org.eclipse.emf.ecore.util.FeatureMap in project statecharts by Yakindu.

the class DerivedEObjectEList method contains.

@Override
public boolean contains(Object object) {
    if (sourceFeatureIDs != null) {
        for (int i = 0; i < sourceFeatureIDs.length; i++) {
            int sourceFeatureID = sourceFeatureIDs[i];
            if (owner.eIsSet(sourceFeatureID)) {
                EStructuralFeature sourceFeature = getEStructuralFeature(sourceFeatureID);
                Object value = owner.eGet(sourceFeatureID, true, true);
                if (FeatureMapUtil.isFeatureMap(sourceFeature)) {
                    FeatureMap featureMap = (FeatureMap) value;
                    for (int j = 0, size = featureMap.size(); j < size; j++) {
                        value = featureMap.getValue(j);
                        if (isIncluded(featureMap.getEStructuralFeature(j)) ? value == object : isIncluded(value) && derive(value) == object) {
                            return true;
                        }
                    }
                } else if (isIncluded(sourceFeature)) {
                    if (sourceFeature.isMany() ? ((List<?>) value).contains(object) : value == object) {
                        return true;
                    }
                } else {
                    if (sourceFeature.isMany()) {
                        InternalEList<?> valuesList = (InternalEList<?>) value;
                        if (valuesList instanceof RandomAccess) {
                            for (int j = 0, size = valuesList.size(); j < size; j++) {
                                value = valuesList.basicGet(j);
                                if (isIncluded(value) && derive(value) == object) {
                                    return true;
                                }
                            }
                        } else {
                            for (Iterator<?> v = valuesList.basicIterator(); v.hasNext(); ) {
                                value = v.next();
                                if (isIncluded(value) && derive(value) == object) {
                                    return true;
                                }
                            }
                        }
                    } else if (isIncluded(value) && derive(value) == object) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
Also used : FeatureMap(org.eclipse.emf.ecore.util.FeatureMap) EStructuralFeature(org.eclipse.emf.ecore.EStructuralFeature) Iterator(java.util.Iterator) ListIterator(java.util.ListIterator) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) InternalEList(org.eclipse.emf.ecore.util.InternalEList) RandomAccess(java.util.RandomAccess) EObject(org.eclipse.emf.ecore.EObject) InternalEObject(org.eclipse.emf.ecore.InternalEObject) AbstractSequentialInternalEList(org.eclipse.emf.ecore.util.AbstractSequentialInternalEList) EList(org.eclipse.emf.common.util.EList) UniqueEList(org.eclipse.emf.common.util.UniqueEList) List(java.util.List) InternalEList(org.eclipse.emf.ecore.util.InternalEList)

Aggregations

FeatureMap (org.eclipse.emf.ecore.util.FeatureMap)25 FeatureEList (org.eclipse.emf.ecore.util.FeatureMapUtil.FeatureEList)10 List (java.util.List)8 ExtensionAttributeValue (org.eclipse.bpmn2.ExtensionAttributeValue)8 ArrayList (java.util.ArrayList)5 EList (org.eclipse.emf.common.util.EList)5 EObject (org.eclipse.emf.ecore.EObject)5 MetaDataType (org.jboss.drools.MetaDataType)5 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)4 Iterator (java.util.Iterator)3 ListIterator (java.util.ListIterator)3 RandomAccess (java.util.RandomAccess)3 InternalEObject (org.eclipse.emf.ecore.InternalEObject)3 AbstractSequentialInternalEList (org.eclipse.emf.ecore.util.AbstractSequentialInternalEList)3 InternalEList (org.eclipse.emf.ecore.util.InternalEList)3 BPSimDataType (bpsim.BPSimDataType)2 HashMap (java.util.HashMap)2 Entry (java.util.Map.Entry)2 Relationship (org.eclipse.bpmn2.Relationship)2 EStructuralFeatureImpl (org.eclipse.emf.ecore.impl.EStructuralFeatureImpl)2