Package org.eclipse.emf.common.util

Examples of org.eclipse.emf.common.util.EMap$InternalMapView


        if (changeSummary.isLogging())
            ((ChangeSummaryImpl) changeSummary).summarize();
        ChangeDescription changeDescription = (ChangeDescription) changeSummary;
        Iterator createdDataObjects = changeDescription.getObjectsToDetach().iterator();
        deletedDataObjects = changeDescription.getObjectsToAttach();
        EMap objectChanges = changeDescription.getObjectChanges();
        modifiedDataObjects = objectChanges.keySet(); // may contain DO(s) from createdDataObjects and/or deletedDataObjects

        /*
         * 6-2. Prepare to compute (X)Path
         *  input: changeSummary
         *  output: rootResource
         */
        /*not to support DataGraph 3-3
        Object dataGraph = changeSummary.getDataGraph();
        if (dataGraph == null) {
            DataObject rootObject = changeSummary.getRootObject();
            // assert rootObject != null;
            rootResource = rootObject.getContainer() == null ? ((EObject) rootObject).eResource() // Can be null since this *StAX* writer does NOT
                    // require rootObject contained by an *EMF* Resource
                    : null; // eResource() direct content may not necessarily always be the XML document
        } else
            // assert dataGraph instanceof DataGraphImpl;
            rootResource = ((org.apache.tuscany.sdo.impl.DataGraphImpl) dataGraph).getRootResource(); */

        /*
         * 6-2. Start ChangeSummary element
         *  input: writer, options, elementCS, changeSummary & changeDescription (6-1)
         */
        nsPrefixSuffix = 0;
        this.writer = writer;
        this.options = options;
        lineBreak = "";
        indent = margin = pathRootObject = STRING_OPTION;
        nest = 0;
        changeSummaryElementNS = changeSummaryElement.getNamespaceURI();
        changeSummaryElementName = changeSummaryElement.getLocalPart();
        writeStartElement(changeSummaryElement.getPrefix(), changeSummaryElementNS, changeSummaryElementName);
        lineBreak = STRING_OPTION;
        rootObject = changeSummary.getRootObject();
        extendedMetaData = (ExtendedMetaData) options.get(XMLResource.OPTION_EXTENDED_META_DATA);
        if (extendedMetaData == null)
        {
            extendedMetaData = ExtendedMetaData.INSTANCE;
            xsdHelper = XSDHelper.INSTANCE;
        }
        else
            xsdHelper = new XSDHelperImpl(extendedMetaData, null);
        Property declaration = changeSummaryElementNS == null
                             ? rootObject.getType().getProperty(changeSummaryElementName)
                             : xsdHelper.getGlobalProperty(changeSummaryElementNS, changeSummaryElementName, true);
        if (declaration != null)
        {
            EClassifier type = changeDescription.eClass();
            if (type != declaration.getType() && type != CHANGE_SUMMARY)
                writeGlobalAttribute(ExtendedMetaData.XSI_PREFIX, ExtendedMetaData.XSI_URI, XMLResource.TYPE, new StringBuffer(prefix(extendedMetaData.getNamespace(type), null))
                        .append(':').append(extendedMetaData.getName(type)).toString());
        }
       
        /*
         * 6-3. "create" attribute
         *  input: createdDataObjects (6-1), rootResource (6-2), changeSummary & writer
         */
        rootElementNS = null;
        this.changeSummary = changeSummary;
        if (createdDataObjects.hasNext()) {
            StringBuffer buffer = new StringBuffer();
            while (true) {
                dataObject = (DataObject) createdDataObjects.next();
                buffer.append(ref());
                if (!createdDataObjects.hasNext())
                    break;
                buffer.append(' ');
            }
            writer.writeAttribute(CREATE_ATTRIBUTE, buffer.toString());
        }

        /*
         * 6-4. "delete" attribute
         *  input: deletedDataObjects (6-1), modifiedDataObjects (6-1) & writer
         */
        Iterator iterator = deletedDataObjects.iterator();
        if (iterator.hasNext()) {
            lengthDeleted = -1;
            StringBuffer buffer = null;
            do {
                dataObject = (DataObject) iterator.next();
                if (skipDeletedModification(changeSummary.getOldContainer(dataObject)))
                    continue;
                if (buffer == null)
                    buffer = new StringBuffer();
                else
                    buffer.append(' ');
                buffer.append(refDeleted());
            } while (iterator.hasNext());
            writer.writeAttribute(DELETE_ATTRIBUTE, buffer.toString());
        }

        /*
         * 6-5. "logging" attribute
         *  input: changeSummary & writer
         */
        writer.writeAttribute(LOGGING_ATTRIBUTE, changeSummary.isLogging() ? "true" : "false");

        /*
         * 6-6. Modified DataObjects
         *  input: modifiedDataObjects (6-1), rootResource (6-2), changeSummary & writer
         */
        iterator = modifiedDataObjects.iterator();
        if (iterator.hasNext()) {
            boolean optimizeList;
            if (options == null)
                optimizeList = false;
            else
            {
                Object option = options.get(OPTION_OPTIMIZE_LIST);
                optimizeList = option == null ? false : ((Boolean)option).booleanValue();
            }
            prefix(SDOAnnotations.COMMONJ_SDO_NS, SDOPackage.eNS_PREFIX);
            do {
                DataObject dataObject = (DataObject) iterator.next();
                if (skipDeletedModification(dataObject))
                    continue;
                Property containmentProperty = dataObject.getContainmentProperty();
                if (containmentProperty == null) {
                    ++nest;
                    startElement();
                    rootElementName();
                    writer.writeStartElement(rootElementNS, rootElementName);
                } else
                    writeStartElement(containmentProperty);
                this.dataObject = dataObject;
                writeRef();

                String lineBreak = null;
                Collection oldValues = (Collection) objectChanges.get(dataObject); // changeSummary.getOldValues repeats Sequence changes
                Iterator settings = oldValues.iterator();
                if (settings.hasNext()) {
                    do {
                        ChangeSummary.Setting oldValue = (ChangeSummary.Setting) settings.next();
                        if (oldValue.isSet())
View Full Code Here


          // 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);
          }
          ChangeSummary changeSummary = eDataGraph.getEChangeSummary();

          if (changeSummary != null)
View Full Code Here

              EObject dgroot = eDataGraph.getERootObject();
              if (dgroot == null)
              {
                return null;
              }
              EMap prefixToNamespaceMap = super.recordNamespacesSchemaLocations(dgroot);
              if (prefixToNamespaceMap != null)
              {
                for (Iterator i = prefixToNamespaceMap.iterator(); i.hasNext();)
                {
                  Map.Entry entry = (Map.Entry)i.next();
                  String prefix = (String)entry.getKey();
                  String namespace = (String)entry.getValue();
                  if (namespace.equals("commonj.sdo"))
                  {
                    prefixToNamespaceMap.removeKey(prefix);
                    break;
                  }
                }
              }
              return prefixToNamespaceMap;
View Full Code Here

          // 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);
          }
          ChangeSummary changeSummary = eDataGraph.getEChangeSummary();

          if (changeSummary != null)
View Full Code Here

              EObject dgroot = eDataGraph.getERootObject();
              if (dgroot == null)
              {
                return null;
              }
              EMap prefixToNamespaceMap = super.recordNamespacesSchemaLocations(dgroot);
              if (prefixToNamespaceMap != null)
              {
                for (Iterator i = prefixToNamespaceMap.iterator(); i.hasNext();)
                {
                  Map.Entry entry = (Map.Entry)i.next();
                  String prefix = (String)entry.getKey();
                  String namespace = (String)entry.getValue();
                  if (namespace.equals("commonj.sdo"))
                  {
                    prefixToNamespaceMap.removeKey(prefix);
                    break;
                  }
                }
              }
              return prefixToNamespaceMap;
View Full Code Here

  /**
   * @return an EMap containing the schema locations or null when no map
   */
  protected EMap getSchemaLocationMap()
  {
    EMap result = null;
    if ((documentRoot != null) && (extendedMetaData != null))
    {
      EReference xsiSchemaLocationMapFeature = extendedMetaData
          .getXSISchemaLocationMapFeature(documentRoot.eClass());
      if (xsiSchemaLocationMapFeature != null)
View Full Code Here

    return location.toString();
  }

  public String getSchemaLocation()
  {
    EMap xsiSchemaLocationMap = getSchemaLocationMap();
    if (xsiSchemaLocationMap != null)
    {
      if (!xsiSchemaLocationMap.isEmpty())
      {
        StringBuffer xsiSchemaLocation = new StringBuffer();
        for (Iterator i = xsiSchemaLocationMap.entrySet().iterator(); i
            .hasNext();)
        {
          Map.Entry entry = (Map.Entry) i.next();
          String namespace = (String) entry.getKey();
          if (namespace != null)
View Full Code Here

    return null;
  }

  public void setSchemaLocation(String schemaLocation)
  {
    EMap xsiSchemaLocationMap = getSchemaLocationMap();
    if (xsiSchemaLocationMap != null)
    {
      // only remove the entries from xsiSchemaLocationMap that contain a
      // non-null key
      for (Iterator i = xsiSchemaLocationMap.entrySet().iterator(); i.hasNext();)
      {
        Map.Entry entry = (Map.Entry) i.next();
        if (entry.getKey() != null)
        {
          i.remove();
        }
      }
      if (xsiSchemaLocationMap.size() == 0)
      {
        resource.getDefaultSaveOptions().put(
            XMLResource.OPTION_SCHEMA_LOCATION, Boolean.FALSE);
      }
      if (schemaLocation != null)
      {
        String[] values = schemaLocation.split(WHITESPACE_REGEX);
        for (int i = 0; i < values.length; i++) // note: also incremented in
        // loop
        {
          String key = values[i++];
          if (i < values.length)
          {
            xsiSchemaLocationMap.put(key, resolve(values[i]));
          }
        }
        if (xsiSchemaLocationMap.size() != 0)
        {
          resource.getDefaultSaveOptions().put(
              XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
        }
      }
View Full Code Here

    }
  }

  public String getNoNamespaceSchemaLocation()
  {
    EMap xsiSchemaLocationMap = getSchemaLocationMap();
    if (xsiSchemaLocationMap != null)
    {
      StringBuffer xsiSchemaLocation = new StringBuffer();
      if (!xsiSchemaLocationMap.isEmpty())
      {
        Object valueObject = xsiSchemaLocationMap.get(null);
        if (valueObject != null)
        {
          String valueString = (String) valueObject;
          String[] values = valueString.split(WHITESPACE_REGEX);
          for (int i = 0; i < values.length; i++)
View Full Code Here

    return null;
  }

  public void setNoNamespaceSchemaLocation(String schemaLocation)
  {
    EMap xsiSchemaLocationMap = getSchemaLocationMap();
    if (xsiSchemaLocationMap != null)
    {
      // only remove the entries from xsiSchemaLocationMap that contain a null
      // key
      xsiSchemaLocationMap.removeKey(null);
      if (xsiSchemaLocationMap.size() == 0)
      {
        resource.getDefaultSaveOptions().put(
            XMLResource.OPTION_SCHEMA_LOCATION, Boolean.FALSE);
      }
      if (schemaLocation != null)
      {
        String[] values = schemaLocation.split(WHITESPACE_REGEX);
        for (int i = 0; i < values.length; i++)
        {
          xsiSchemaLocationMap.put(null, resolve(values[i]));
        }
        if (xsiSchemaLocationMap.size() != 0)
        {
          resource.getDefaultSaveOptions().put(
              XMLResource.OPTION_SCHEMA_LOCATION, Boolean.TRUE);
        }
      }
View Full Code Here

TOP

Related Classes of org.eclipse.emf.common.util.EMap$InternalMapView

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.