Package org.eclipse.emf.ecore

Examples of org.eclipse.emf.ecore.EReference


            }
          }

          // use namespace declarations defined in the document (if any)
          EObject eRootObject = eDataGraph.getERootObject();
          EReference xmlnsPrefixMapFeature = extendedMetaData.getXMLNSPrefixMapFeature(eRootObject.eClass());
          if (xmlnsPrefixMapFeature != null)
          {
            EMap xmlnsPrefixMap = (EMap)eRootObject.eGet(xmlnsPrefixMapFeature);
            helper.setPrefixToNamespaceMap(xmlnsPrefixMap);
          }
View Full Code Here


    mixed.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY);
    ExtendedMetaData.INSTANCE.setName(mixed, ":mixed");
    ExtendedMetaData.INSTANCE.setFeatureKind(mixed, ExtendedMetaData.ELEMENT_WILDCARD_FEATURE);
    documentRootEClass.getEStructuralFeatures().add(mixed);
   
    EReference xmlnsPrefixMap = EcoreFactory.eINSTANCE.createEReference();
    xmlnsPrefixMap.setName("xMLNSPrefixMap");
    xmlnsPrefixMap.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry());
    xmlnsPrefixMap.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY);
    xmlnsPrefixMap.setContainment(true);
    xmlnsPrefixMap.setTransient(true);
    ExtendedMetaData.INSTANCE.setName(xmlnsPrefixMap, "xmlns:prefix");
    ExtendedMetaData.INSTANCE.setFeatureKind(xmlnsPrefixMap, ExtendedMetaData.ATTRIBUTE_FEATURE);
    documentRootEClass.getEStructuralFeatures().add(xmlnsPrefixMap);
   
    EReference xsiSchemaLocation = EcoreFactory.eINSTANCE.createEReference();
    xsiSchemaLocation.setName("xSISchemaLocation");
    xsiSchemaLocation.setEType(EcorePackage.eINSTANCE.getEStringToStringMapEntry());
    xsiSchemaLocation.setUpperBound(EStructuralFeature.UNBOUNDED_MULTIPLICITY);
    xsiSchemaLocation.setContainment(true);
    xsiSchemaLocation.setTransient(true);
    ExtendedMetaData.INSTANCE.setName(xsiSchemaLocation, "xsi:schemaLocation");
    ExtendedMetaData.INSTANCE.setFeatureKind(xsiSchemaLocation, ExtendedMetaData.ATTRIBUTE_FEATURE);
    documentRootEClass.getEStructuralFeatures().add(xsiSchemaLocation);
   
    return documentRootEClass;
View Full Code Here

  }

  protected void save(OutputStream outputStream, Object options) throws IOException
  {
    EObject oldContainer = null;
    EReference oldContainmentReference = null;
    int oldContainmentIndex = -1;

    if (documentRoot != null)
    {
      //TODO also check if rootObject is directly contained in a resource
      oldContainer = rootObject.eContainer();
      if (oldContainer != null)
      {
        oldContainmentReference = rootObject.eContainmentFeature();
      }
      if (oldContainer != documentRoot || oldContainmentReference != rootElement)
      {
        if (oldContainmentReference != null && oldContainmentReference.isMany())
        {
          oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject);
        }
       
        Object rootValue =
          rootElement instanceof EAttribute && rootObject instanceof SimpleAnyTypeDataObject ?
            ((SimpleAnyTypeDataObject)rootObject).getValue() : rootObject;
           
        documentRoot.eSet(rootElement, rootValue);
      }
    }

    resource.save(outputStream, (Map)options);

    if (oldContainer != null)
    {
      if (oldContainer != documentRoot || oldContainmentReference != rootElement)
      {
        if (oldContainmentReference.isMany())
        {
          ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject);
        }
        else
        {
View Full Code Here

  protected EMap getSchemaLocationMap()
  {
    EMap result = null;
    if ((documentRoot != null) && (extendedMetaData != null))
    {
      EReference xsiSchemaLocationMapFeature = extendedMetaData
          .getXSISchemaLocationMapFeature(documentRoot.eClass());
      if (xsiSchemaLocationMapFeature != null)
      {
        result = (EMap) documentRoot.eGet(xsiSchemaLocationMapFeature);
      }
View Full Code Here

 
  protected void createGlobalProperty(String name, Type type, String[] xsdMappings)
  {
    int propertyNumber = documentRootEClass.getEStructuralFeatures().size();
    createEReference(documentRootEClass, propertyNumber);
    EReference globalProperty = (EReference)documentRootEClass.getEStructuralFeatures().get(propertyNumber);
    initEReference(globalProperty, (EClass)type, null, name, null, 0, -2, null, IS_TRANSIENT, IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, IS_DERIVED, IS_ORDERED);
    addAnnotation((ENamedElement)globalProperty, ANNOTATION_SOURCE, xsdMappings);
  }
View Full Code Here

    if (eContainer != null)
    {
      EStructuralFeature eContainingFeature = eStore().getContainingFeature(this);
      if (eContainingFeature instanceof EReference)
      {
        EReference eContainingReference = (EReference)eContainingFeature;
        EReference eOpposite = eContainingReference.getEOpposite();
        if (eOpposite != null)
        {
          eContainerFeatureID = eClass().getFeatureID(eOpposite);
          return;
        }
View Full Code Here

            EClass propertyEClass = (EClass)eClasses.get(propertyClass);

            if (propertyEClass != null)
            {
              // The property is another SDO, create an EReference to represent the property
              EReference reference = EcoreFactory.eINSTANCE.createEReference();
              reference.setName(propertyName);
              reference.setContainment(true);
              reference.setEType(propertyEClass);
              implEClass.getEStructuralFeatures().add(reference);

            }
            else
            {
              // The property is a List<T> and T is an SDO, created a 0..many EReference to represent the property
              if (propertyClass == List.class)
              {
                Type genericType = method.getGenericReturnType();
                if (genericType instanceof ParameterizedType)
                {
                  ParameterizedType parameterizedType = (ParameterizedType)genericType;
                  Type[] targs = parameterizedType.getActualTypeArguments();
                  if (targs.length != 0 && eClasses.containsKey(targs[0]))
                  {
                    propertyEClass = (EClass)eClasses.get(targs[0]);
                    if (propertyEClass != null)
                    {
                      EReference reference = EcoreFactory.eINSTANCE.createEReference();
                      reference.setName(propertyName);
                      reference.setContainment(true);
                      reference.setEType(propertyEClass);
                      reference.setUpperBound(-1);
                      implEClass.getEStructuralFeatures().add(reference);
                    }
                  }
                }
                continue;
View Full Code Here

            EClass propertyEClass = (EClass)eClasses.get(propertyClass);

            if (propertyEClass != null)
            {
              // The property is another SDO, create an EReference to represent the property
              EReference reference = EcoreFactory.eINSTANCE.createEReference();
              reference.setName(propertyName);
              reference.setContainment(true);
              reference.setEType(propertyEClass);
              implEClass.getEStructuralFeatures().add(reference);

            }
            else
            {
              // The property is a List<T> and T is an SDO, created a 0..many EReference to represent the property
              if (propertyClass == List.class)
              {
                Type genericType = method.getGenericReturnType();
                if (genericType instanceof ParameterizedType)
                {
                  ParameterizedType parameterizedType = (ParameterizedType)genericType;
                  Type[] targs = parameterizedType.getActualTypeArguments();
                  if (targs.length != 0 && eClasses.containsKey(targs[0]))
                  {
                    propertyEClass = (EClass)eClasses.get(targs[0]);
                    if (propertyEClass != null)
                    {
                      EReference reference = EcoreFactory.eINSTANCE.createEReference();
                      reference.setName(propertyName);
                      reference.setContainment(true);
                      reference.setEType(propertyEClass);
                      reference.setUpperBound(-1);
                      implEClass.getEStructuralFeatures().add(reference);
                    }
                  }
                }
                continue;
View Full Code Here

  }

  protected void save(OutputStream outputStream, Object options) throws IOException
  {
    EObject oldContainer = null;
    EReference oldContainmentReference = null;
    int oldContainmentIndex = -1;

    if (documentRoot != null)
    {
      //TODO also check if rootObject is directly contained in a resource
      oldContainer = rootObject.eContainer();
      if (oldContainer != null)
      {
        oldContainmentReference = rootObject.eContainmentFeature();
      }
      if (oldContainer != documentRoot || oldContainmentReference != rootElement)
      {
        if (oldContainmentReference != null && oldContainmentReference.isMany())
        {
          oldContainmentIndex = ((List)oldContainer.eGet(oldContainmentReference)).indexOf(rootObject);
        }
       
        Object rootValue =
          rootElement instanceof EAttribute && rootObject instanceof SimpleAnyTypeDataObject ?
            ((SimpleAnyTypeDataObject)rootObject).getValue() : rootObject;
           
        documentRoot.eSet(rootElement, rootValue);
      }
    }

    resource.save(outputStream, (Map)options);

    if (oldContainer != null)
    {
      if (oldContainer != documentRoot || oldContainmentReference != rootElement)
      {
        if (oldContainmentReference.isMany())
        {
          ((List)oldContainer.eGet(oldContainmentReference)).add(oldContainmentIndex, rootObject);
        }
        else
        {
View Full Code Here

  protected EMap getSchemaLocationMap()
  {
    EMap result = null;
    if ((documentRoot != null) && (extendedMetaData != null))
    {
      EReference xsiSchemaLocationMapFeature = extendedMetaData
          .getXSISchemaLocationMapFeature(documentRoot.eClass());
      if (xsiSchemaLocationMapFeature != null)
      {
        result = (EMap) documentRoot.eGet(xsiSchemaLocationMapFeature);
      }
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.