Java 类org.eclipse.emf.common.util.AbstractEList 实例源码

项目:BIMserver    文件:ReferenceCounter.java   
@SuppressWarnings({ "rawtypes", "unchecked" })
        @Override
        public Reference reAttach(IdEObject mainObject) {
//          System.out.println("Re-attaching M " + getReferredObject() + " to " + mainObject + " on " + getIdEObject() + "." + geteReference().getName());
            AbstractEList list = (AbstractEList) getIdEObject().eGet(geteReference());
            int index = list.indexOf(getReferredObject());
            if (index != -1) {
                try {
                    list.set(index, mainObject);
                } catch (IllegalArgumentException e) {
//                  e.printStackTrace();
                }
            }

            // TODO if the old object really does exist multiple times, the new object should also exist multiple times... but it's probably a bug that it's there multiple times in the first place...
            while (list.contains(getReferredObject())) {
                list.remove(getReferredObject());
            }
            return new MultiReference(getIdEObject(), mainObject, geteReference());
        }
项目:BIMserver    文件:SharedJsonDeserializer.java   
@SuppressWarnings({ "unchecked", "rawtypes" })
private void processRef(IfcModelInterface model, WaitingList<Long> waitingList, IdEObjectImpl object,
        EStructuralFeature eStructuralFeature, int index, AbstractEList list, long refOid)
                throws DeserializeException {
    EntityDefinition entityBN = model.getPackageMetaData().getSchemaDefinition().getEntityBN(object.eClass().getName());
    Attribute attributeBN = entityBN.getAttributeBNWithSuper(eStructuralFeature.getName());
    if (skipInverses && attributeBN instanceof InverseAttribute && ((EReference)eStructuralFeature).getEOpposite() != null) {
        // skip
    } else {
        if (model.contains(refOid)) {
            EObject referencedObject = model.get(refOid);
            if (referencedObject != null) {
                addToList(eStructuralFeature, index, list, referencedObject);
            }
        } else {
            waitingList.add(refOid, new ListWaitingObject(-1, object, (EReference) eStructuralFeature, index));
        }
    }
}
项目:BIMplatform    文件:WaitingList.java   
@SuppressWarnings("unchecked")
public void updateNode(T expressId, EClass ec, IdEObject eObject) throws DeserializeException {
    for (WaitingObject waitingObject : waitingObjects.get(expressId)) {
        if (waitingObject.getStructuralFeature().isMany()) {
            AbstractEList<EObject> list = (AbstractEList<EObject>) waitingObject.getObject().eGet(waitingObject.getStructuralFeature());
            if (waitingObject instanceof SingleWaitingObject) {
                list.addUnique(eObject);
            } else {
                ListWaitingObject listWaitingObject = (ListWaitingObject)waitingObject;
                if (((EClass) waitingObject.getStructuralFeature().getEType()).isSuperTypeOf(eObject.eClass())) {
                    while (list.size() <= listWaitingObject.getIndex()) {
                        EObject create = ec.getEPackage().getEFactoryInstance().create(eObject.eClass());
                        ((IdEObjectImpl)create).setOid(-2);
                        list.addUnique(create);
                    }
                    list.setUnique(listWaitingObject.getIndex(), eObject);
                } else {
                    throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getStructuralFeature().getName() + " of "
                            + waitingObject.getStructuralFeature().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName());
                }
            }
        } else {
            if (((EClass) waitingObject.getStructuralFeature().getEType()).isSuperTypeOf(eObject.eClass())) {
                waitingObject.getObject().eSet(waitingObject.getStructuralFeature(), eObject);
            } else {
                throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getStructuralFeature().getName() + " of "
                        + waitingObject.getStructuralFeature().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName() + "/" + eObject.getOid());
            }
        }
    }
    waitingObjects.remove(expressId);
}
项目:BIMserver    文件:SharedJsonDeserializer.java   
private void addToList(EStructuralFeature eStructuralFeature, int index, AbstractEList list, EObject referencedObject) throws DeserializeException {
    EClass referenceEClass = referencedObject.eClass();
    if (((EClass) eStructuralFeature.getEType()).isSuperTypeOf(referenceEClass)) {
        while (list.size() <= index) {
            list.addUnique(referencedObject);
        }
    } else {
        throw new DeserializeException(-1, referenceEClass.getName() + " cannot be stored in " + eStructuralFeature.getName());
    }
}
项目:BIMserver    文件:WaitingList.java   
@SuppressWarnings("unchecked")
public void updateNode(T expressId, EClass ec, IdEObject eObject) throws DeserializeException {
    for (WaitingObject waitingObject : waitingObjects.get(expressId)) {
        if (waitingObject.getEReference().isMany()) {
            AbstractEList<EObject> list = (AbstractEList<EObject>) waitingObject.getObject().eGet(waitingObject.getEReference());
            if (waitingObject instanceof SingleWaitingObject) {
                list.addUnique(eObject);
            } else {
                ListWaitingObject listWaitingObject = (ListWaitingObject)waitingObject;
                if (((EClass) waitingObject.getEReference().getEType()).isSuperTypeOf(eObject.eClass())) {
                    while (list.size() <= listWaitingObject.getIndex()) {
                        EObject create = ec.getEPackage().getEFactoryInstance().create(eObject.eClass());
                        ((IdEObjectImpl)create).setOid(-2);
                        list.addUnique(create);
                    }
                    list.setUnique(listWaitingObject.getIndex(), eObject);
                } else {
                    throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
                            + waitingObject.getEReference().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName());
                }
            }
        } else {
            if (((EClass) waitingObject.getEReference().getEType()).isSuperTypeOf(eObject.eClass())) {
                waitingObject.getObject().eSet(waitingObject.getEReference(), eObject);
            } else {
                throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
                        + waitingObject.getEReference().getEContainingClass().getName() + " cannot contain a " + eObject.eClass().getName() + "/" + eObject.getOid());
            }
        }
    }
    waitingObjects.remove(expressId);
}
项目:BIMserver    文件:EDelegatingList.java   
public EDelegatingList(ClientIfcModel model, IdEObject subject, EStructuralFeature feature, AbstractEList<E> delegate) {
    this.model = model;
    this.subject = subject;
    this.feature = feature;
    this.delegate = delegate;
}