Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EReference


    if (!useEncodedAttributeStyle)
    {
      InternalEObject container = ((InternalEObject)top).eInternalContainer();
      if (container != null)
      {
        EReference containmentReference = top.eContainmentFeature();
        EReference containerReference = containmentReference.getEOpposite();
        if (containerReference != null && !containerReference.isTransient())
        {
          saveHref(container, containerReference);
          return true;
        }
      }
View Full Code Here


        if (resource != null && resource.getContents().size() >= 1)
        {
          EObject root =  getSchemaLocationRoot(resource.getContents().get(0));
          EClass eClass = root.eClass();

          EReference xsiSchemaLocationMapFeature = extendedMetaData.getXSISchemaLocationMapFeature(eClass);
          if (xsiSchemaLocationMapFeature != null)
          {
            @SuppressWarnings("unchecked") EMap<String, String> xsiSchemaLocationMap = (EMap<String, String>)root.eGet(xsiSchemaLocationMapFeature);
            if (!xsiSchemaLocationMap.isEmpty())
            {
View Full Code Here

        {
          saveNil(o, entryFeature);
        }
        else
        {
          EReference referenceEntryFeature = (EReference)entryFeature;
          if (referenceEntryFeature.isContainment())
          {
            saveElement((InternalEObject)value, entryFeature);
          }
          else if (referenceEntryFeature.isResolveProxies())
          {
            saveFeatureMapElementReference((EObject)value, referenceEntryFeature);
          }
          else
          {
View Full Code Here

    {
      FeatureMap.Entry entry = values.get(i);
      EStructuralFeature entryFeature = entry.getEStructuralFeature();
      if (entryFeature instanceof EReference)
      {
        EReference referenceEntryFeature = (EReference)entryFeature;
        if (referenceEntryFeature.isMany())
        {
          if (repeats == null)
          {
            repeats = new HashSet<EReference>();
          }
          else if (repeats.contains(referenceEntryFeature))
          {
            continue;
          }
         
          repeats.add(referenceEntryFeature);
         
          if (referenceEntryFeature.isResolveProxies())
          {
            saveEObjectMany(o, entryFeature);
          }
          else
          {
            saveIDRefMany(o, entryFeature);
          }
        }
        else
        {
          if (referenceEntryFeature.isResolveProxies())
          {
            saveEObjectSingle(o, entryFeature);
          }
          else
          {
View Full Code Here

      LOOP:
      for (EReference eReference : proxy.eClass().getEAllReferences())
      {
        // And find the one that holds this proxy.
        //
        EReference oppositeEReference = eReference.getEOpposite();
        if (oppositeEReference != null && oppositeEReference.isChangeable() && proxy.eIsSet(eReference))
        {
          // Try to resolve the proxy locally.
          //
          EObject resolvedEObject = xmlResource.getEObject(proxy.eProxyURI().fragment());
          if (resolvedEObject != null)
          {
            // We won't need to process this again later.
            //
            if (!isEndDocument)
            {
              i.remove();
            }

            // Compute the holder of the proxy
            //
            EObject proxyHolder = (EObject)(eReference.isMany() ? ((List<?>)proxy.eGet(eReference)).get(0) : proxy.eGet(eReference));

            // If the proxy holder can hold many values,
            // it may contain a duplicate that resulted when the other end was processed as an IDREF
            // and hence did both sides of the bidirectional relation.
            //
            if (oppositeEReference.isMany())
            {
              // So if the resolved object is also present...
              //
              InternalEList<?> holderContents = (InternalEList<?>)proxyHolder.eGet(oppositeEReference);
              int resolvedEObjectIndex = holderContents.basicIndexOf(resolvedEObject);
              if (resolvedEObjectIndex != -1)
              {
                // Move the resolved object to the right place, remove the proxy, and we're done.
                //
                int proxyIndex = holderContents.basicIndexOf(proxy);
                holderContents.move(proxyIndex, resolvedEObjectIndex);
                holderContents.remove(proxyIndex > resolvedEObjectIndex ? proxyIndex  - 1 : proxyIndex + 1);
                break LOOP;
              }
            }

            if (!oppositeEReference.getEType().isInstance(resolvedEObject))
            {
              error
                (new IllegalValueException
                   (proxyHolder,
                    oppositeEReference,
                    resolvedEObject,
                    null,
                    getLocation(),
                    getLineNumber(),
                    getColumnNumber()));
              break LOOP;
            }

            // If the resolved object doesn't contain a reference to the proxy holder as it should.
            //
            if (eReference.isMany() ?
                  !((InternalEList<?>)resolvedEObject.eGet(eReference)).basicContains(proxyHolder) :
                  resolvedEObject.eGet(eReference) != proxyHolder)
            {
              // The proxy needs to be replaced in a way that updates both ends of the reference.
              //
              if (oppositeEReference.isMany())
              {
                @SuppressWarnings("unchecked") InternalEList<EObject> proxyHolderList = (InternalEList<EObject>)proxyHolder.eGet(oppositeEReference);
                proxyHolderList.setUnique(proxyHolderList.basicIndexOf(proxy), resolvedEObject);
              }
              else
View Full Code Here

  }
 
  protected EMap<String, String> recordNamespacesSchemaLocations(EObject root)
  {
    EClass eClass = root.eClass();
    EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eClass);
    EMap<String, String> xmlnsPrefixMap = null;
    if (xmlnsPrefixMapFeature != null)
    {
      @SuppressWarnings("unchecked") EMap<String, String> newXMLNSPrefixMap = (EMap<String, String>)root.eGet(xmlnsPrefixMapFeature);
      xmlnsPrefixMap = newXMLNSPrefixMap;
      xmlnsPrefixMap.putAll(helper.getPrefixToNamespaceMap());
    }

    if (urisToLocations != null)
    {
      EReference xsiSchemaLocationMapFeature = extendedMetaData.getXSISchemaLocationMapFeature(eClass);
      if (xsiSchemaLocationMapFeature != null)
      {
        @SuppressWarnings("unchecked") EMap<String, String> newXSISchemaLocationMap = (EMap<String, String>)root.eGet(xsiSchemaLocationMapFeature);
        EMap<String, String> xsiSchemaLocationMap = newXSISchemaLocationMap;
        for (Map.Entry<String, URI> entry : urisToLocations.entrySet())
View Full Code Here

          text = new StringBuffer();
        }
      }
      else if (extendedMetaData != null)
      {
        EReference eReference = (EReference)feature;
        boolean isContainment = eReference.isContainment();     
        if (!isContainment && !eReference.isResolveProxies() && extendedMetaData.getFeatureKind(feature) != ExtendedMetaData.UNSPECIFIED_FEATURE)
        {
          isIDREF = true;
          objects.push(null);
          mixedTargets.push(null);
          types.push(feature);
          text = new StringBuffer();
        }
        else
        {
          createObject(peekObject, feature);
          EObject childObject = objects.peekEObject();
          if (childObject != null)
          {
            if (isContainment)
            {
              EStructuralFeature simpleFeature = extendedMetaData.getSimpleFeature(childObject.eClass());
              if (simpleFeature != null)
              {
                isSimpleFeature = true;
                isIDREF = simpleFeature instanceof EReference;
                objects.push(null);
                mixedTargets.push(null);
                types.push(simpleFeature);
                text = new StringBuffer();
              }
            }
            else if (!childObject.eIsProxy())
            {
              text = new StringBuffer();
            }
          }
        }
      }
      else
      {
        createObject(peekObject, feature);
      }
    }
    else
    {
      // Try to get a general-content feature.
      // Use a pattern that's not possible any other way.
      //
      if (xmlMap != null && (feature = getFeature(peekObject, null, "", true)) != null)
      {

        EFactory eFactory = getFactoryForPrefix(prefix);

        // This is for the case for a local unqualified element that has been bound.
        //
        if (eFactory == null)
        {
          eFactory = feature.getEContainingClass().getEPackage().getEFactoryInstance();
        }

        EObject newObject = null;
        if (useNewMethods)
        {
          newObject = createObject(eFactory, helper.getType(eFactory, name), false);
        }
        else
        {
            newObject = createObjectFromFactory(eFactory, name);
        }
        newObject = validateCreateObjectFromFactory(eFactory, name, newObject, feature);
        if (newObject != null)
        {
          setFeatureValue(peekObject, feature, newObject);
        }
        processObject(newObject);
      }
      else
      {
        // This handles the case of a substitution group.
        //
        if (xmlMap != null)
        {
          EFactory eFactory = getFactoryForPrefix(prefix);
          EObject newObject = createObjectFromFactory(eFactory, name);
          validateCreateObjectFromFactory(eFactory, name, newObject);
          if (newObject != null)
          {
            for (EReference eReference : peekObject.eClass().getEAllReferences())
            {
              if (eReference.getEType().isInstance(newObject))
              {
                setFeatureValue(peekObject, eReference, newObject);
                processObject(newObject);
                return;
              }
View Full Code Here

      if (!deferIDREFResolution)
      {
        if (isFirstID)
        {
          EReference eOpposite = eReference.getEOpposite();
          if (eOpposite == null)
          {
            mustAdd = true;
            mustAddOrNotOppositeIsMany = true;
          }
          else
          {
            mustAdd = eOpposite.isTransient() || eReference.isMany();
            mustAddOrNotOppositeIsMany = mustAdd || !eOpposite.isMany();
          }
          isFirstID = false;
        }
 
        if (mustAddOrNotOppositeIsMany)
View Full Code Here

  {
    if (settingDelegate == null)
    {
      EClass eClass  = getEContainingClass();
      eClass.getFeatureCount();
      EReference eOpposite = getEOpposite();
      if (eOpposite != null)
      {
        eOpposite.getEContainingClass().getFeatureCount();
      }

      EClassifier eType = getEType();
      Class<?> dataClass = EcoreUtil.wrapperClassFor(eType.getInstanceClass());
      Object defaultValue = getDefaultValue();
      Object intrinsicDefaultValue = eType.getDefaultValue();

      EStructuralFeature featureMapFeature;
      SettingDelegate.Factory settingDelegateFactory;
      if ((settingDelegateFactory = EcoreUtil.getSettingDelegateFactory(this)) != null)
      {
        settingDelegate = settingDelegateFactory.createSettingDelegate(this);
      }
      else if (isDerived() &&
                 (((featureMapFeature = ExtendedMetaData.INSTANCE.getMixedFeature(eClass)) != null &&
                    featureMapFeature != this) ||
                    ((featureMapFeature = ExtendedMetaData.INSTANCE.getGroup(this)) != null)))
      {
        settingDelegate = new InternalSettingDelegateFeatureMapDelegator(this, featureMapFeature);
      }
      else if (isMany())
      {
        if (isContainment())
        {
          if (eOpposite == null)
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE_DYNAMIC_RESOLVE, this);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE_DYNAMIC, this);
                }
              }
              else if (dataClass == Map.Entry.class)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EMAP_UNSETTABLE, BasicEMap.Entry.class, this);
              }
              else
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE_RESOLVE, dataClass, this);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.CONTAINMENT_UNSETTABLE, dataClass, this);
                }
              }
            }
            else
            {
              if (dataClass == null)
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_DYNAMIC_RESOLVE, this);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_DYNAMIC, this);
                }
              }
              else if (dataClass == Map.Entry.class)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EMAP, BasicEMap.Entry.class, this);
              }
              else
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_RESOLVE, dataClass, this);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT, dataClass, this);
                 
                }
              }
            }
          }
          else
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE_DYNAMIC_RESOLVE, this, eOpposite);
                }  
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE_DYNAMIC, this, eOpposite);
                }  
              }
              else
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE_RESOLVE, dataClass, this, eOpposite);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_UNSETTABLE, dataClass, this, eOpposite);
                }
              }
            }
            else
            {
              if (dataClass == null)
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_DYNAMIC_RESOLVE, this, eOpposite);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_DYNAMIC, this, eOpposite);
                }
              }
             
              else
              {
                if (isResolveProxies())
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE_RESOLVE, dataClass, this, eOpposite);
                }
                else
                {
                  settingDelegate =
                    new InternalSettingDelegateMany
                      (InternalSettingDelegateMany.CONTAINMENT_INVERSE, dataClass, this, eOpposite);
                }
              }
            }
          }
        }
        else if (eType instanceof EDataType)
        {
          if (dataClass == FeatureMap.Entry.class)
          {
            settingDelegate = createFeatureMapSettingDelegate();
          }
          else if (isUnique())
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNIQUE_UNSETTABLE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNIQUE_UNSETTABLE, dataClass, this);
              }
            }
            else
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNIQUE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNIQUE, dataClass, this);
              }
            }
          }
          else
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNSETTABLE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_UNSETTABLE, dataClass, this);
              }
            }
            else
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.DATA, dataClass, this);
              }
            }
          }
        }
        else if (eOpposite == null)
        {
          if (isResolveProxies())
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_RESOLVE_UNSETTABLE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_RESOLVE_UNSETTABLE, dataClass, this);
              }
            }
            else
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_RESOLVE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_RESOLVE, dataClass, this);
              }
            }
          }
          else
          {
            if (isUnsettable())
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_UNSETTABLE_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_UNSETTABLE, dataClass, this);
              }
            }
            else
            {
              if (dataClass == null)
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT_DYNAMIC, this);
              }
              else
              {
                settingDelegate =
                  new InternalSettingDelegateMany
                    (InternalSettingDelegateMany.EOBJECT, dataClass, this);
              }
            }
          }
        }
        else if (eOpposite.isMany())
        {
          if (isResolveProxies())
          {
            if (isUnsettable())
            {
View Full Code Here

  public FeatureMap.Entry.Internal getFeatureMapEntryPrototype()
  {
    if (prototypeFeatureMapEntry == null)
    {
      EReference eOpposite = getEOpposite();
      if (eOpposite != null)
      {
        prototypeFeatureMapEntry = new InverseUpdatingFeatureMapEntry(this, null);
      }
      else if (isContainment())
View Full Code Here

TOP

Related Classes of org.eclipse.emf.ecore.EReference

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.