Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource')
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java152
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java35
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java585
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java149
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java59
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java53
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java61
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java55
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java17
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java48
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java41
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java240
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java127
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java54
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java101
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java95
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java68
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java1743
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRenderer.java264
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactory.java29
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactoryDefaultHandler.java46
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXDocumentHandler.java210
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRenderer.java175
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRendererFactory.java42
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXWriter.java387
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java90
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/GenericTranslator.java110
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/IDTranslator.java75
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/LinkUpdaterTarget.java59
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MappedXMIHelper.java295
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MultiObjectTranslator.java83
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/NamespaceTranslator.java112
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ObjectTranslatorFilter.java35
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReadAheadHelper.java92
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedResource.java116
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIFactoryImpl.java100
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIResourceImpl.java301
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Renderer.java62
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactory.java157
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactoryDefaultHandler.java30
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RootTranslator.java62
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/SourceLinkTranslator.java72
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Translator.java792
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorFilter.java220
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorPath.java94
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResource.java79
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceFactory.java68
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceImpl.java392
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/UnsupportedFeature.java43
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/VariableTranslatorFactory.java42
-rw-r--r--plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/XMLEncoderDecoder.java170
51 files changed, 0 insertions, 8587 deletions
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java
deleted file mode 100644
index 9112aef59..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AbstractRendererImpl.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-public abstract class AbstractRendererImpl implements Renderer {
-
-
- protected TranslatorResource resource;
- private int versionId;
- private boolean validating = true;
-
- /**
- * Constructor for AbstractRendererImpl.
- */
- public AbstractRendererImpl() {
- super();
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#setResource(TranslatorResource)
- */
- public void setResource(TranslatorResource aResource) {
- resource = aResource;
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#getResource()
- */
- public TranslatorResource getResource() {
- return resource;
- }
-
- public int getVersionId() {
- return this.versionId;
- }
-
- public void setVersionId(int versionId) {
- this.versionId = versionId;
- }
-
- /**
- * @return
- */
- public boolean isValidating() {
- return validating;
- }
-
- /**
- * @param b
- */
- public void setValidating(boolean b) {
- validating = b;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#accessForRead()
- */
- public void accessForRead() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#accessForWrite()
- */
- public void accessForWrite() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isModified()
- */
- public boolean isModified() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isShared()
- */
- public boolean isShared() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#isSharedForWrite()
- */
- public boolean isSharedForWrite() {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#preDelete()
- */
- public void preDelete() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#preUnload()
- */
- public void preUnload() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#releaseFromRead()
- */
- public void releaseFromRead() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#releaseFromWrite()
- */
- public void releaseFromWrite() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#setBatchMode(boolean)
- */
- public void setBatchMode(boolean isBatch) {
- }
-
- public boolean useStreamsForIO() {
- return true;
- }
-
- public boolean isBatchMode() {
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java
deleted file mode 100644
index b0d08696f..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/AttributeTranslatorFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-/*
- * Created on Sep 21, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-public final class AttributeTranslatorFilter extends TranslatorFilter {
-
- public AttributeTranslatorFilter() {
- super(null, -1);
- }
-
- public AttributeTranslatorFilter(Translator trans, int version) {
- super(trans, version);
- }
-
- public final int scanNextTranslator(Translator[] children, int start) {
- int found = start + 1;
- for (; found < children.length; ++found) {
- if (children[found].isDOMAttribute())
- break;
- }
- found = (found < children.length) ? found : -1;
- return found;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java
deleted file mode 100644
index e57583388..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventNode.java
+++ /dev/null
@@ -1,585 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.xml.sax.Attributes;
-
-
-/**
- * CacheEventNodes (CENOs) store information collected from SAX Events. This information can then be
- * used once all necessary SAX Events have been generated to create and/or set values on EMF model
- * objects.
- *
- * CacheEventNodes (CENOs) have a simple lifecycle: initialize, collect data, commit, discard. When
- * initialized, CENOs will attempt to find the appropriate translator for a given XML element name,
- * and also create/set any necessary EMF model values. Data is collected as SAX character() events
- * are generated. On the SAX endElement event, the CENO is committed(), which is where it will
- * complete its processing to create EMF model features. In those cases where it cannot complete its
- * processing, it will defer its processing to the updateEMF() method of its parent. Defered
- * processing is necessary to handle EMF features that require read ahead cues from the XML. CENOs
- * will add themselves to their parents as children in a tree data structure. When an CENO
- * determines it is the golden piece of information required to instantiate its parent feature, it
- * will trigger its parent CENO to process the rest of the cached CENO tree. As mentioned, the
- * building of a CENO tree will only occur for nodes with read ahead cues.
- *
- * discard() is invoked by init() to ensure that no junk state is left from a previous use of the
- * CENO. commit() will call discard as needed. Because of the use of discard, CENOs can be pooled
- * and reused. If a CENO determines that it is contained in a pool, it will manage its own release
- * from that pool. Self- management is necessary because of the way in which CENOs might cache
- * certain children while waiting to create the parent EMF feature.
- *
- * @author mdelder
- */
-public class CacheEventNode {
-
- public static final String ROOT_NODE = "EMF_ROOT_NODE"; //$NON-NLS-1$
-
- private String nodeName = null;
- private Translator translator = null;
- private Notifier emfOwner = null;
- private StringBuffer buffer = null;
- private List children = null;
- private int versionID;
-
- /*
- * The internal data structure used to store the attributes is a String[]. The choice was made
- * to use an array to avoid the creation of another object (probably a Hashtable) and to exploit
- * array-access times to get the name and value of the attributes (opposed to full fledged
- * method invocations).
- *
- */
- private String[] attributes = null;
- private CacheEventNode parent = null;
- private CacheEventPool containingPool = null;
- private Boolean ignorable = null;
-
- public CacheEventNode(CacheEventPool containingPool) {
- this.containingPool = containingPool;
- }
-
- /**
- * Lifecycle method. init(TranslatorResource) will configure this Adapter as a ROOT node.
- *
- * This method will invoke discard() before completing its tasks.
- */
- public void init(TranslatorResource resource) {
- this.discard();
- this.setEmfOwner(resource);
- this.setTranslator(resource.getRootTranslator());
- this.setVersionID(resource.getVersionID());
- this.nodeName = CacheEventNode.ROOT_NODE;
- }
-
- /**
- * Lifecycle method. init(CacheEventNode, String, Attributes) will configure this Adapter to be
- * a non-ROOT node of the Adapter data structure
- *
- * This method will invoke discard() before completing its tasks.
- */
- public void init(CacheEventNode parentArg, String nodeNameArg, Attributes attributesArg) {
- this.discard();
- this.nodeName = nodeNameArg;
- init(parentArg, attributesArg);
- }
-
- private void init(CacheEventNode parentRecord, Attributes attributesArg) {
- setParent(parentRecord);
-
- setAttributes(attributesArg);
- if (parent != null) {
- /* I am not the root */
-
- /*
- * If the parent is part of the DOM Path, then we ignore it and interact with the grand
- * parent
- */
- if (parent.translator != null && parent.isInDOMPath()) {
- setParent(parent.getParent());
- }
-
- setVersionID(parent.getVersionID());
- if (parent.getEmfOwner() != null && parent.getTranslator() != null) {
-
- /* My parent had enough information to create themself */
-
- if (parent.getParent() != null) {
- setTranslator(parent.getTranslator().findChild(nodeName, parent.getEmfOwner(), getVersionID()));
-
- } else {
- setTranslator(parent.getTranslator());
- }
-
- if (this.translator == null) {
- /* Our translator is null! Ahh! Run! */
- throw new IllegalStateException("Parent Translator (" + parent.getTranslator() + //$NON-NLS-1$
- ") did not find a Child Translator for \"" + //$NON-NLS-1$
- nodeName + "\"."); //$NON-NLS-1$
- }
-
- if (this.translator.getReadAheadHelper(nodeName) == null && !this.translator.isManagedByParent()) {
- /*
- * I do not require a read ahead cue, and I am not managed by my parent so I can
- * create an instance of my EMF object
- */
-
- Notifier myEmfOwner = this.translator.createEMFObject(getNodeName(), null);
- setEmfOwner(myEmfOwner);
- this.translator.setMOFValue(parent.getEmfOwner(), myEmfOwner);
- }
- /*
- * Else I require a read ahead value or I am being managed by my parent, so I have
- * no need to create an EMF object
- */
- }
- /*
- * Else I am not mapped to the EMF stack (XML Elements found in the DOMPath are ignored)
- */
- }
- /* processAttributes is guarded and will not execute unless ready */
- processAttributes();
-
- }
-
- /**
- * commit() is invoked only if the CacheEventNode (CENO) has all the information they need and
- * should be able to determine what to do to the EMF feature.
- *
- * The commit() method will invoke discard() when it has completed its tasks, if needed. Thus,
- * after invoking this method, the CENO may have no meaningful state. If discard() is invoked,
- * all previously held reference will be released in order to be made eligible for Garbage
- * Collection.
- *
- */
- public void commit() {
-
- if (parent == null || this.isIgnorable()) {
- discard();
- releaseFromContainingPool();
- return;
- }
-
- ReadAheadHelper helper = null;
- Translator activeTranslator = getTranslator();
- Translator parentTranslator = getParent().getTranslator();
-
- if (parent != null && parent.getEmfOwner() == null) {
-
- /*
- * Not enough information yet, add the CacheEventNode to the DOM Cache tree
- */
-
- parent.appendToBuffer(this);
- if ((helper = getParent().getReadAheadHelper()) != null) {
- /*
- * If the parentRecord's emfOwner is null, then it must not be initialized therefore
- * it or one of its ancestors must require read ahead clues
- *
- * The following if statement checks if the parent is the node waiting for a
- * readAhead cue
- */
- EObject parentOwner = null;
- if (helper.nodeValueIsReadAheadName(getNodeName())) {
- /* The readAheadName is the value of the qName child node */
-
- /* We have enough information to create the EmfOwner in the parent! */
- parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getBuffer());
-
- /*
- * Now we need to parse the cached DOM tree and update the emfOwner of the
- * parent
- */
- getParent().updateEMF(parentOwner);
-
- } else if (helper.nodeNameIsReadAheadName(getNodeName())) {
- /* The readAheadName is the actual name of the child node (qName) */
-
- /* We have enough information to create the EmfOwner in the parent! */
- parentOwner = parentTranslator.createEMFObject(getParent().getNodeName(), getNodeName());
-
- /*
- * Now we need to parse the cached DOM tree and update the emfOwner of the
- * parent
- */
- getParent().updateEMF(parentOwner);
- }
-
- } /* Else an ancestor of the parent is waiting */
-
- } else {
- if (activeTranslator != null) {
- if (activeTranslator.isManagedByParent()) {
-
- Object value = activeTranslator.convertStringToValue(getNodeName(), null, getBuffer(), getParent().getEmfOwner());
- activeTranslator.setMOFValue(getParent().getEmfOwner(), value);
- processAttributes();
- } else {
-
- activeTranslator.setTextValueIfNecessary(getBuffer(), getEmfOwner(), getVersionID());
- }
-
- }
- discard();
- releaseFromContainingPool();
- }
- }
-
- /**
- * Instruct the CacheEventNode to discard all references to make everything eligible for garbage
- * collection. This should ONLY be called after commit has succeeded. In the case of EMF
- * features that require a readAheadName, process not be completed in commit(), but rather will
- * be defered to the updateEMF() method. This method was made private specifically because it
- * could erase all information contained in the CacheEventNode before it has been processed.
- *
- */
- private void discard() {
- translator = null;
- emfOwner = null;
- buffer = null;
- if (children != null)
- children.clear();
- children = null;
- attributes = null;
- parent = null;
- }
-
- private void releaseFromContainingPool() {
- if (containingPool != null)
- containingPool.releaseNode(this);
- }
-
- public boolean isIgnorable() {
- if (ignorable == null) {
- boolean result = false;
- if (this.translator != null) {
- if (this.translator.isEmptyContentSignificant()) {
- result = false;
- } else {
- String domPath = this.translator.getDOMPath();
- result = (domPath != null) ? domPath.indexOf(this.nodeName) >= 0 : false;
- }
- }
- ignorable = result ? Boolean.TRUE : Boolean.FALSE;
- }
- return ignorable.booleanValue();
- }
-
- /**
- * Determines if a given child has a translator.
- *
- * @param childNodeName
- * the name of the current XML child node
- * @return true only if the childNodeName can be ignored (e.g. it is part of the DOM Path)
- */
- public boolean isChildIgnorable(String childNodeName) {
- boolean result = false;
-
- Translator childTranslator = null;
- if (this.getTranslator() != null) {
- childTranslator = this.getTranslator().findChild(childNodeName, this.getEmfOwner(), this.getVersionID());
-
- if (childTranslator != null) {
- if (childTranslator.isEmptyContentSignificant()) {
- result = false;
- } else {
- String temp = null;
- result = ((temp = childTranslator.getDOMPath()) != null) ? temp.indexOf(childNodeName) >= 0 : false;
- }
- }
- }
-
- return result;
- }
-
- public boolean isInDOMPath() {
- boolean result = false;
-
- if (this.getTranslator() != null) {
-
- result = this.getNodeName().equals(this.getTranslator().getDOMPath());
- }
-
- return result;
- }
-
- public String toString() {
- StringBuffer output = new StringBuffer("CacheEventNode[");//$NON-NLS-1$
- output.append("nodeName=");//$NON-NLS-1$
- output.append(nodeName);
- output.append("; translator=");//$NON-NLS-1$
- output.append(translator);
- output.append("; emfOwner=");//$NON-NLS-1$
- try {
- output.append(emfOwner);
- } catch (RuntimeException re) {
- output.append("Could not render as string!");//$NON-NLS-1$
- }
- output.append("; buffer=");//$NON-NLS-1$
- output.append(this.buffer);
- output.append("; hasChildren=");//$NON-NLS-1$
- output.append((children != null && children.size() > 0));
- if (children != null) {
- for (int i = 0; i < this.children.size(); i++) {
- output.append("\n\tchildren(");//$NON-NLS-1$
- output.append(i);
- output.append("): ");//$NON-NLS-1$
- output.append(this.children.get(i));
- }
- }
- output.append("]");//$NON-NLS-1$
- return output.toString();
- }
-
- /**
- * Updates the EMF model by creating EMF Features as necessary from the DOM Tree Cache
- *
- * @param owner
- */
- public void updateEMF(EObject owner) {
- this.setEmfOwner(owner);
- if (this.parent != null) {
- this.translator.setMOFValue((EObject) this.parent.getEmfOwner(), owner);
- this.processAttributes();
- }
-
- this.updateEMF();
- }
-
- /**
- * The translator and the owner of the parent CENO passed to this method should be nonnull
- */
- public void updateEMF() {
- if (this.children == null)
- return;
-
- CacheEventNode child = null;
- Translator childTranslator = null;
- Object value = null;
- if (this.getEmfOwner() != null) {
- Notifier parentOwner = this.getEmfOwner();
- Translator parentTranslator = this.getTranslator();
- for (int i = 0; i < this.children.size(); i++) {
-
- child = (CacheEventNode) this.children.get(i); /* Create the EMF feature */
- if (this.isChildIgnorable(child.getNodeName())) {
- this.addChildren(child.getChildren());
- } else {
- childTranslator = parentTranslator.findChild(child.getNodeName(), parentOwner, child.getVersionID());
- child.setTranslator(childTranslator);
-
- value = childTranslator.convertStringToValue(child.getNodeName(), null, child.getBuffer(), parentOwner);
- childTranslator.setMOFValue(parentOwner, value);
-
- if (childTranslator.isObjectMap()) {
- child.setEmfOwner((Notifier) value);
- childTranslator.setTextValueIfNecessary(child.getBuffer(), child.getEmfOwner(), getVersionID());
- }
-
- child.processAttributes();
- child.updateEMF(); /* update the EMF of the child */
-
- }
- child.discard();
- child.releaseFromContainingPool();
- }
- this.children = null;
- }
- }
-
- public void addChild(CacheEventNode child) {
- if (this.children == null) {
- this.children = new ArrayList();
- }
- if (parent != null && this.isIgnorable()) {
- parent.addChild(child);
- } else {
- this.children.add(child);
- }
- }
-
- protected void addChildren(List childrenArg) {
- if (this.children == null) {
- this.children = new ArrayList();
- }
- this.children.addAll(childrenArg);
- }
-
- public boolean removeChild(CacheEventNode child) {
- if (this.children == null) {
- return false;
- }
- return this.children.remove(child);
- }
-
- public List getChildren() {
- return this.children;
- }
-
- public ReadAheadHelper getReadAheadHelper() {
- if (this.translator != null && this.translator.hasReadAheadNames()) {
- return translator.getReadAheadHelper(nodeName);
- }
- return null;
- }
-
-
- /* See the documentation for the attributes field for info on how it is structured */
- public void setAttributes(Attributes attr) {
-
- /*
- * The attributes returned from the parser may be stored by reference, so we must copy them
- * over to a local data store
- */
- if (attr != null && attr.getLength() > 0) {
-
- if (this.attributes == null) {
- this.attributes = new String[attr.getLength() * 2];
- }
- for (int i = 0; i < attr.getLength(); i++) {
- this.attributes[i] = attr.getQName(i);
- this.attributes[i + attr.getLength()] = attr.getValue(i);
- }
-
- }
- }
-
- /**
- * processAttributes may be invoked multiple times. It is configured to only carry out the
- * processing one time. After it successfully completes the construction of Translators and
- * values it will discard the value of the attributes field by setting it to null.
- *
- */
- public void processAttributes() {
- /* See the documentation for the attributes field for info on how it is structured */
- if (this.attributes != null && this.attributes.length > 0) {
-
- if (this.emfOwner != null && this.translator != null) {
- Translator attrTranslator = null;
- final int limit = this.attributes.length / 2;
- Object value = null;
- for (int i = 0; i < limit; i++) {
-
- /* Find the attribute translator by using the attribute name (attributes[i]) */
- attrTranslator = this.translator.findChild(this.attributes[i], this.emfOwner, this.versionID);
-
- if (attrTranslator != null) {
-
- /*
- * Convert the value of corresponding attribute value (attributes[i+limit])
- * to a meaningful value
- */
- value = attrTranslator.convertStringToValue(this.attributes[i + limit], (EObject) this.emfOwner);
- attrTranslator.setMOFValue((EObject) this.emfOwner, value);
- }
- }
-
- /* Forget the attributes so we do not process them again */
- this.attributes = null;
- }
- }
- }
-
- /**
- * Appends data to the buffer stored by this CENO. Text will be extracted from the data array
- * begining at positiong <i>start </i> and ending at position <i>start+length </i>.
- *
- * @param data
- * @param start
- * @param length
- */
- public void appendToBuffer(char[] data, int start, int length) {
-
- if (parent != null && this.isIgnorable()) {
- parent.appendToBuffer(data, start, length);
- return;
- }
-
- if (buffer == null) {
- this.buffer = new StringBuffer();
- }
-
- /*
- * acts as a more efficient form of "append". Using this method avoids the need to copy the
- * data into its own data structure (e.g. String) before being added to the buffer
- */
- this.buffer.insert(buffer.length(), data, start, length);
-
- }
-
- /**
- * Add the given CENO as a child of this CENO.
- *
- * @param record
- */
- public void appendToBuffer(CacheEventNode record) {
-
- this.addChild(record);
- }
-
- public String getBuffer() {
- if (this.buffer == null) {
- return null;
- }
- return this.buffer.toString();
- }
-
- public Notifier getEmfOwner() {
- return emfOwner;
- }
-
- public CacheEventNode getParent() {
- return parent;
- }
-
- private void setParent(CacheEventNode record) {
- this.parent = record;
- }
-
- public Translator getTranslator() {
- return this.translator;
- }
-
- public void setEmfOwner(Notifier notifier) {
-
- this.emfOwner = notifier;
- }
-
- public void setTranslator(Translator translator) {
- this.translator = translator;
- }
-
- public String getNodeName() {
- return nodeName;
- }
-
- public int getVersionID() {
-
- if (this.parent == null) {
- try {
- return ((TranslatorResource) this.getEmfOwner()).getVersionID();
-
- } catch (RuntimeException re) {
- }
- }
- return this.versionID;
- }
-
- public void setVersionID(int i) {
- versionID = i;
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java
deleted file mode 100644
index 55799e248..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventPool.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.xml.sax.Attributes;
-
-/**
- * Provides an instance pool of reusable CacheEventNodes. The pool will default to 10 live
- * instances. When its available instances reach five times its initial capacity, it will shrink
- * itself down to the initial capacity.
- *
- * @author mdelder
- */
-public class CacheEventPool {
-
- public static final int DEFAULT_CAPACITY = 10;
- public static final int DEFAULT_CAPACITY_INCREMENT = 25;
-
- private int poolCapacity = DEFAULT_CAPACITY;
- private CacheEventStack availablePool = null;
- private Collection inusePool = null;
-
- public CacheEventPool() {
- this(DEFAULT_CAPACITY);
- }
-
- /**
- * Create a CacheEventPOol with the given initial capacity
- *
- * @param initialCapacity
- * The number of available instances to create.
- */
- public CacheEventPool(int initialCapacity) {
- poolCapacity = (initialCapacity > 0) ? initialCapacity : DEFAULT_CAPACITY;
- availablePool = new CacheEventStack();
- inusePool = new ArrayList(poolCapacity);
- }
-
- /**
- * Create a CacheEventNode (CENO) initialized to use the given resource as its EMF Owner.
- *
- * THIS METHOD SHOULD ONLY BE USED TO CREATE ROOT NODES.
- *
- * @param resource
- * the resource that will be populated
- * @return a CacheEventNode to serve as the root.
- */
- public CacheEventNode createCacheEventNode(TranslatorResource resource) {
- CacheEventNode adapter = fetchFreeNode();
- adapter.init(resource);
- return adapter;
- }
-
- /**
- * Create child CacheEventNodes (CENOs) that will branch from the given parent.
- *
- * @param parent
- * the containing CENO
- * @param nodeName
- * The value of the XML element node name
- * @param attributes
- * The attributes that were part of the given XML element
- * @return A CENO that has been properly initialized.
- */
- public CacheEventNode createCacheEventNode(CacheEventNode parent, String nodeName, Attributes attributes) {
- CacheEventNode adapter = fetchFreeNode();
- adapter.init(parent, nodeName, attributes);
- return adapter;
- }
-
- /**
- * Release the CacheEventNode CENO back to the pool of availabe instances. This method should
- * not be invoked directly. CENOs which are acquired from a given pool will automatically
- * release themselves when necessary.
- *
- * @param adapter
- */
- public void releaseNode(CacheEventNode adapter) {
- freeNode(adapter);
- }
-
- /**
- * freezePool() should be invoked to free any unused resources. After freezePool has been
- * invoked, warmPool() will need to be invoked before the pool can be used again.
- *
- */
- public void freezePool() {
- availablePool.clear();
- availablePool = null;
- }
-
- /**
- * warmPool() must be invoked to notify the pool it is about to be used. This should occur only
- * once per document rendering. Until the pool is in use, it contains no available
- * CacheEventNodes (CENOs) in order to limit the size of the in-memory footprint of the
- * EMF2SAXWriter.
- *
- */
- public void warmPool() {
- ensureMinimumCapacity();
- }
-
- private CacheEventNode fetchFreeNode() {
- CacheEventNode result = null;
-
- if (availablePool == null || availablePool.isEmpty())
- warmPool();
-
- result = availablePool.pop();
- inusePool.add(result);
-
- return result;
- }
-
- private void freeNode(CacheEventNode adapter) {
- if (inusePool.remove(adapter))
- availablePool.push(adapter);
- //else
- // throw new IllegalStateException("Adapter not contained in pool!");
- if (availablePool.size() > (5 * poolCapacity)) {
- availablePool.clear();
- ensureMinimumCapacity();
- }
- }
-
- private void ensureMinimumCapacity() {
- if (availablePool == null) {
- availablePool = new CacheEventStack();
- }
- if (availablePool.size() < poolCapacity) {
- final int minimumCapacity = poolCapacity - availablePool.size();
- for (int i = 0; i < minimumCapacity; i++)
- availablePool.push(new CacheEventNode(this));
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java
deleted file mode 100644
index 03f419858..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CacheEventStack.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 24, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.EmptyStackException;
-
-/**
- * An unsynchronized implementation of a Stack (LIFO) data structure. No casting is required when
- * using this data structure.
- *
- * @author mdelder
- */
-public class CacheEventStack extends ArrayList {
-
- /**
- *
- * @return the top of the stack without removing it
- */
- public CacheEventNode peek() {
- if (size() == 0)
- throw new EmptyStackException();
-
- return (CacheEventNode) get(size() - 1);
- }
-
- /**
- *
- * @return the top of the stack and removing it
- */
- public CacheEventNode pop() {
- if (size() == 0)
- throw new EmptyStackException();
-
- return (CacheEventNode) remove(size() - 1);
- }
-
- /**
- *
- * @param adapter
- * A CENO to push onto the top of the stack
- */
- public void push(CacheEventNode adapter) {
- add(adapter);
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java
deleted file mode 100644
index 25367c8a1..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityPackageMappingRegistry.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * This class is used to register mappings for a package prefix to its current namespace URI. Also,
- * this registry is used to map the package
- */
-public class CompatibilityPackageMappingRegistry {
- public static CompatibilityPackageMappingRegistry INSTANCE = new CompatibilityPackageMappingRegistry();
- private Map prefixToPackageURIs = new HashMap();
- private Map packageURIsToPrefixes = new HashMap();
-
- /**
- *
- */
- private CompatibilityPackageMappingRegistry() {
- super();
- }
-
- /**
- * @return
- */
- public Map getPackageURIsToPrefixes() {
- return packageURIsToPrefixes;
- }
-
- /**
- * @return
- */
- public Map getPrefixToPackageURIs() {
- return prefixToPackageURIs;
- }
-
- public void registerPrefixToPackageURI(String prefix, String uri) {
- if (prefix != null && uri != null) {
- prefixToPackageURIs.put(prefix, uri);
- packageURIsToPrefixes.put(uri, prefix);
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java
deleted file mode 100644
index f824de384..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityResourceFactory.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 23, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilityResourceFactory extends XMIResourceFactoryImpl {
- /**
- *
- */
- public CompatibilityResourceFactory() {
- super();
- }
-
- protected Map prefixToPackageURIs;
-
- protected Map packageURIsToPrefixes;
-
- public Map getPrefixToPackageURI() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
- }
-
- public Map getPackageURIsToPrefixes() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl#createResource(org.eclipse.emf.common.util.URI)
- */
- public Resource createResource(URI uri) {
- return new CompatibilityXMIResourceImpl(uri);
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java
deleted file mode 100644
index ee6ff3e9e..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilitySAXXMIHandler.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 30, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.SAXXMIHandler;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilitySAXXMIHandler extends SAXXMIHandler {
- protected final static String NULL_ATTRIB = XMLResource.XSI_NS + ":null"; //$NON-NLS-1$
-
- /**
- * @param xmiResource
- * @param helper
- * @param options
- */
- public CompatibilitySAXXMIHandler(XMLResource xmiResource, XMLHelper helper, Map options) {
- super(xmiResource, helper, options);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLHandler#isNull()
- */
- protected boolean isNull() {
- boolean isnull = super.isNull();
- if (!isnull)
- isnull = attribs.getValue(NULL_ATTRIB) != null;
- return isnull;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java
deleted file mode 100644
index ba135f505..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityURIConverter.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.URIConverter;
-
-public interface CompatibilityURIConverter extends URIConverter {
- URI deNormalize(URI uri);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java
deleted file mode 100644
index 5f17a46ed..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMILoadImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 30, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.impl.SAXWrapper;
-import org.eclipse.emf.ecore.xmi.impl.XMILoadImpl;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * @author DABERG
- *
- * To change the template for this generated type comment go to Window>Preferences>Java>Code
- * Generation>Code and Comments
- */
-public class CompatibilityXMILoadImpl extends XMILoadImpl {
-
- /**
- * @param helper
- */
- public CompatibilityXMILoadImpl(XMLHelper helper) {
- super(helper);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLLoadImpl#makeDefaultHandler()
- */
- protected DefaultHandler makeDefaultHandler() {
- return new SAXWrapper(new CompatibilitySAXXMIHandler(resource, helper, options));
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java
deleted file mode 100644
index a954f5fd2..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResource.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-
-public interface CompatibilityXMIResource extends XMIResource {
- int FORMAT_EMF1 = 0;
- /**
- * format for MOF5 compatibility; note that this can NOT be used with resources usings the
- * "platform:/plugin" protocol"
- */
- int FORMAT_MOF5 = 1;
-
- void addOriginalPackageURI(String packageUri, String originalUri);
-
- int getFormat();
-
- /**
- * Set the serialization format. By default it is FORMAT_EMF1.
- *
- * @see CompatibilityXMIResource#FORMAT_EMF1
- * @see CompatibilityXMIResource#FORMAT_MOF5
- */
- void setFormat(int format);
-
- boolean usesDefaultFormat();
-
- /**
- * @param rootObject
- */
- void removePreservingIds(EObject rootObject);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java
deleted file mode 100644
index adc44b221..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMIResourceImpl.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLLoad;
-import org.eclipse.emf.ecore.xmi.XMLSave;
-import org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl;
-import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.IDUtil;
-
-
-public class CompatibilityXMIResourceImpl extends XMIResourceImpl implements CompatibilityXMIResource {
- protected static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
- protected int format = FORMAT_EMF1;
- protected Map originalPackageURIs = new HashMap();
- private boolean preserveIDs = false;
-
- private static final String PLATFORM_PROTOCOL = "platform"; //$NON-NLS-1$
- private static final String PLATFORM_PLUGIN = "plugin"; //$NON-NLS-1$
-
- /**
- * Constructor for MappableXMIResourceImpl.
- */
- public CompatibilityXMIResourceImpl() {
- super();
- initDefaultSaveOptions();
- }
-
- public CompatibilityXMIResourceImpl(URI uri) {
- super(uri);
- initDefaultSaveOptions();
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl#createXMLHelper()
- */
- protected final XMLHelper createXMLHelper() {
- MappedXMIHelper helper = doCreateXMLHelper();
- helper.setPackageURIsToPrefixes(getPackageURIsToPrefixes());
- return helper;
- }
-
- protected MappedXMIHelper doCreateXMLHelper() {
- return new MappedXMIHelper(this, getPrefixToPackageURIs());
- }
-
- /**
- * Subclasses should not need to override this method.
- *
- * @see CompatibilityPackageMappingRegistry#getPrefixToPackageURIs()
- */
- protected Map getPrefixToPackageURIs() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPrefixToPackageURIs();
- }
-
- /**
- * Subclasses should not need to override this method.
- *
- * @see CompatibilityPackageMappingRegistry#getPrefixToPackageURIs()
- */
- protected Map getPackageURIsToPrefixes() {
- return CompatibilityPackageMappingRegistry.INSTANCE.getPackageURIsToPrefixes();
- }
-
- public void addOriginalPackageURI(String packageUri, String originalUri) {
- originalPackageURIs.put(packageUri, originalUri);
- }
-
- public int getFormat() {
- return format;
- }
-
- public void setFormat(int format) {
- if (!isPlatformPluginResourceURI())
- this.format = format;
- }
-
- private boolean isPlatformPluginResourceURI() {
- URI aURI = getURI();
-
- return aURI != null && PLATFORM_PROTOCOL.equals(uri.scheme()) && PLATFORM_PLUGIN.equals(uri.segment(0));
- }
-
- /**
- * @see org.eclipse.emf.ecore.resource.Resource#getURIFragment(EObject)
- */
- public String getURIFragment(EObject eObject) {
- if (usesDefaultFormat())
- return super.getURIFragment(eObject);
- return IDUtil.getOrAssignID(eObject, this);
- }
-
- public boolean usesDefaultFormat() {
- return format == CompatibilityXMIResource.FORMAT_EMF1;
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMIResourceImpl#createXMLSave()
- */
- protected XMLSave createXMLSave() {
- if (usesDefaultFormat())
- return super.createXMLSave();
- return new CompatibilityXMISaveImpl(createXMLHelper());
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doSave(OutputStream, Map)
- */
- public void doSave(OutputStream outputStream, Map options) throws IOException {
- super.doSave(outputStream, options);
- }
-
- /**
- * Method initDefaultOptions.
- */
- protected void initDefaultSaveOptions() {
- if (defaultSaveOptions == null) {
- getDefaultSaveOptions();
- }
- }
-
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceImpl#getEObjectByID(String)
- */
- protected EObject getEObjectByID(String id) {
- if (idToEObjectMap != null) {
- EObject eObject = (EObject) idToEObjectMap.get(id);
- if (eObject != null) {
- return eObject;
- }
- }
- return null;
- }
-
- /**
- * Called when the object is unloaded. This implementation
- * {@link InternalEObject#eSetProxyURI sets}the object to be a proxy and clears the
- * {@link #eAdapters adapters}.
- */
- protected void unloaded(InternalEObject internalEObject) {
- //overridden from the super class; call super.getURIFragment instead of the implementation
- //at this level, to avoid ID generation during unload
- //internalEObject.eSetProxyURI(uri.appendFragment(getURIFragment(internalEObject)));
- internalEObject.eSetProxyURI(uri.appendFragment(super.getURIFragment(internalEObject)));
- internalEObject.eAdapters().clear();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doLoad(java.io.InputStream,
- * java.util.Map)
- */
- public final void doLoad(InputStream inputStream, Map options) throws IOException {
- ExtendedEcoreUtil.addLoadingTag(this);
- try {
- basicDoLoad(inputStream, options);
- } finally {
- ExtendedEcoreUtil.removeLoadingTag(this);
- }
- }
-
- protected void basicDoLoad(InputStream inputStream, Map options) throws IOException {
- super.doLoad(inputStream, options);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#init()
- */
- protected void init() {
- super.init();
- setEncoding(DEFAULT_ENCODING);
- }
-
- protected XMLLoad createXMLLoad() {
- return new CompatibilityXMILoadImpl(createXMLHelper());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emf.resource.CompatibilityXMIResource#removePreservingIds(org.eclipse.emf.ecore.EObject)
- */
- public void removePreservingIds(EObject rootObject) {
- setPreserveIDs(true);
- getContents().remove(rootObject);
- }
-
- /**
- * @return Returns the preserveIDs.
- */
- public boolean isPreserveIDs() {
- return preserveIDs;
- }
-
- /**
- * @param preserveIDs
- * The preserveIDs to set.
- */
- public void setPreserveIDs(boolean preserveIDs) {
- this.preserveIDs = preserveIDs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#detachedHelper(org.eclipse.emf.ecore.EObject)
- */
- protected void detachedHelper(EObject eObject) {
- if (modificationTrackingAdapter != null) {
- eObject.eAdapters().remove(modificationTrackingAdapter);
- }
-
- if (useUUIDs()) {
- DETACHED_EOBJECT_TO_ID_MAP.put(eObject, getID(eObject));
- }
-
- if (!isPreserveIDs() && idToEObjectMap != null && eObjectToIDMap != null) {
- idToEObjectMap.remove(eObjectToIDMap.remove(eObject));
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java
deleted file mode 100644
index c1a7bf291..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/CompatibilityXMISaveImpl.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.XMISaveImpl;
-
-public class CompatibilityXMISaveImpl extends XMISaveImpl {
-
- /**
- * Constructor for CompatibilityXMISaveImpl.
- *
- * @param helper
- */
- public CompatibilityXMISaveImpl(XMLHelper helper) {
- super(helper);
- }
-
- /**
- * Constructor for CompatibilityXMISaveImpl.
- *
- * @param options
- * @param helper
- * @param encoding
- */
- public CompatibilityXMISaveImpl(Map options, XMLHelper helper, String encoding) {
- super(options, helper, encoding);
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMISaveImpl#init(XMLResource, Map)
- */
- protected void init(XMLResource resource, Map options) {
- super.init(resource, options);
- xmiType = true;
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMISaveImpl#addNamespaceDeclarations()
- */
- public void addNamespaceDeclarations() {
- doc.addAttribute(XMI_VER_NS, XMIResource.VERSION_VALUE);
- doc.addAttribute(XMI_XMLNS, XMIResource.XMI_URI);
- EPackage[] packages = helper.packages();
- StringBuffer xsiSchemaLocation = null;
- if (declareSchemaLocation) {
- for (int i = 0; i < packages.length; i++) {
- EPackage ePackage = packages[i];
-
- EObject root = EcoreUtil.getRootContainer(ePackage);
- if (root instanceof EPackage) {
- EPackage rootEPackage = (EPackage) root;
- Resource resource = rootEPackage.eResource();
- if (resource != null) {
- URI uri = resource.getURI();
- String rootNsURI = rootEPackage.getNsURI();
- if (uri == null ? rootNsURI != null : !uri.toString().equals(rootNsURI)) {
- declareXSI = true;
- if (xsiSchemaLocation == null) {
- xsiSchemaLocation = new StringBuffer();
- } else {
- xsiSchemaLocation.append(' ');
- }
- xsiSchemaLocation.append(rootNsURI);
- xsiSchemaLocation.append(' ');
- xsiSchemaLocation.append(helper.getHREF(rootEPackage));
- }
- }
- }
- }
- }
-
- if (declareXSI) {
- doc.addAttribute(XSI_XMLNS, XMLResource.XSI_URI);
- }
-
- for (int i = 0; i < packages.length; i++) {
- EPackage ePackage = packages[i];
- //Modified from superclass - dispatch back to helper for compatibility
- //String nsURI = ePackage.getNsURI();
- //String nsPrefix = ePackage.getNsPrefix();
- String[] nsInfo = ((MappedXMIHelper) helper).getNSInfo(ePackage);
- doc.addAttributeNS(XMLResource.XML_NS, nsInfo[0], nsInfo[1]);
- }
-
- if (xsiSchemaLocation != null) {
- doc.addAttribute(XSI_SCHEMA_LOCATION, xsiSchemaLocation.toString());
- }
- }
-
- protected void saveHref(EObject remote, EStructuralFeature f) {
- String name = helper.getQName(f);
- String href = helper.getHREF(remote);
- if (href != null) {
- doc.startElement(name);
- EClass eClass = remote.eClass();
-
- EClass expectedType = (EClass) f.getEType();
- //Changed next line to always write type if expectedType
- //is different from eClass
- if (eClass != expectedType) {
- saveTypeAttribute(eClass);
- }
-
- doc.addAttribute(XMLResource.HREF, href);
- doc.endEmptyElement();
- }
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java
deleted file mode 100644
index 356f102d4..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ConstantAttributeTranslator.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 15, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-
-/**
- * @author schacher
- */
-public class ConstantAttributeTranslator extends Translator {
-
- protected String attributeValue;
-
- /**
- * @param domNameAndPath
- * @param eClass
- */
- public ConstantAttributeTranslator(String domNameAndPath, String attributeValue) {
- super(domNameAndPath, null, DOM_ATTRIBUTE);
- this.attributeValue = attributeValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#getMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public Object getMOFValue(EObject mofObject) {
- return attributeValue;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isSetMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public boolean isSetMOFValue(EObject emfObject) {
- return true;
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java
deleted file mode 100644
index 7518472fc..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DefaultTranslatorFactory.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Aug 20, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.internal.emf.utilities.Namespace;
-import org.eclipse.wst.common.internal.emf.utilities.NamespaceAdapter;
-
-
-/**
- * @author schacher
- */
-public class DefaultTranslatorFactory implements VariableTranslatorFactory {
-
- public static final String XMLNS = "xmlns:"; //$NON-NLS-1$
- public static final DefaultTranslatorFactory INSTANCE = new DefaultTranslatorFactory();
-
- public DefaultTranslatorFactory() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#accepts(java.lang.String)
- */
- public boolean accepts(String domName) {
- return domName != null && domName.startsWith(XMLNS);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#accepts(org.eclipse.emf.common.notify.Notification)
- */
- public boolean accepts(Notification notif) {
- return notif.getFeature() == NamespaceAdapter.NOTIFICATION_FEATURE;
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(java.lang.String)
- */
- public Translator create(String domName) {
- return new NamespaceTranslator(domName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(org.eclipse.emf.ecore.EObject)
- */
- public List create(Notifier target) {
- if (!(target instanceof EObject))
- return null;
- List namespaces = NamespaceAdapter.getNamespaces((EObject) target);
- if (namespaces == null || namespaces.isEmpty())
- return null;
- List result = new ArrayList(namespaces.size());
- for (int i = 0; i < namespaces.size(); i++) {
- result.add(create((Namespace) namespaces.get(i)));
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.VariableTranslatorFactory#create(org.eclipse.emf.common.notify.Notification)
- */
- public Translator create(Notification notif) {
- Namespace ns = (Namespace) notif.getNewValue();
- return create(ns);
- }
-
- private Translator create(Namespace ns) {
- return new NamespaceTranslator(XMLNS + ns.getPrefix());
- }
-
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java
deleted file mode 100644
index c7d1c6257..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/DependencyTranslator.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Mar 25, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author schacher
- */
-public class DependencyTranslator extends Translator {
-
- /**
- * @param domNameAndPath
- * @param aFeature
- */
- public DependencyTranslator(String domNameAndPath, EStructuralFeature aFeature, EStructuralFeature aDependentFeature) {
- super(domNameAndPath, aFeature);
- dependencyFeature = aDependentFeature;
- }
-
- public EObject getChild(EObject parent) {
- EObject child = basicGetDependencyObject(parent);
- if (child == null)
- return createChild(parent);
- return child;
- }
-
-
- protected EObject createChild(EObject parent) {
- EObject child = createEMFObject(dependencyFeature);
- parent.eSet(dependencyFeature, child);
- return child;
- }
-
- public List getMOFChildren(EObject mofObject) {
- //return super.getMOFChildren(getChild(mofObject));
- return super.getMOFChildren(mofObject);
- }
-
- public Object getMOFValue(EObject mofObject) {
- return super.getMOFValue(getChild(mofObject));
- }
-
- public void setMOFValue(EObject emfObject, Object value) {
- //super.setMOFValue(getChild(emfObject), value);
- super.setMOFValue(getChild(emfObject), value, -1);
- }
-
- public void setMOFValue(Notifier owner, Object value, int newIndex) {
- super.setMOFValue(getChild((EObject) owner), value, newIndex);
- }
-
- public void removeMOFValue(Notifier owner, Object value) {
- super.removeMOFValue(getChild((EObject) owner), value);
- }
-
- public boolean isSetMOFValue(EObject emfObject) {
- return super.isSetMOFValue(getChild(emfObject));
- }
-
- public void unSetMOFValue(EObject emfObject) {
- super.unSetMOFValue(getChild(emfObject));
- }
-
-
- public boolean isDependencyChild() {
- return true;
- }
-
- public boolean featureExists(EObject emfObject) {
- return super.featureExists(getChild(emfObject));
- }
-
- public void clearList(EObject mofObject) {
- super.clearList(getChild(mofObject));
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java
deleted file mode 100644
index 9782ea143..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapter.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.ecore.EObject;
-import org.w3c.dom.Node;
-
-public interface EMF2DOMAdapter extends Adapter {
-
-
- Class ADAPTER_CLASS = EMF2DOMAdapter.class;
-
- /**
- * Return the DOM node that the target of this adapter maps to. If the target MOF object maps to
- * more than one DOM node, this node is the top-most node.
- */
- Node getNode();
-
- void setNode(Node aNode);
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- boolean isNotificationEnabled();
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- void setNotificationEnabled(boolean isEnabled);
-
- /**
- * Updates the DOM tree for this adapter from the current values of the MOF Object. This method
- * updates ALL the DOM nodes from all the MOF attributes.
- */
- void updateDOM();
-
- /**
- * Updates the MOF Object from the DOM tree. All the children of the DOM tree are updated into
- * the MOF object.
- */
- void updateMOF();
-
- public void updateDOMFeature(Translator map, Node node, EObject mofObject);
-
- public void updateMOFFeature(Translator map, Node node, EObject mofObject);
-
- EObject getEObject();
-
- /**
- * Return true if MOF object is a proxy.
- */
- boolean isMOFProxy();
-
- /**
- * Remove the DOM adapters from the node AND all its child nodes, recursively.
- */
- void removeAdapters(Node node);
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
deleted file mode 100644
index b36737fe5..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMAdapterImpl.java
+++ /dev/null
@@ -1,1743 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.Assert;
-import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities;
-import org.eclipse.wst.common.internal.emf.utilities.EtoolsCopySession;
-import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.FeatureValueConversionException;
-import org.eclipse.wst.common.internal.emf.utilities.Revisit;
-import org.eclipse.wst.common.internal.emf.utilities.StringUtil;
-import org.eclipse.wst.common.internal.emf.utilities.WFTUtilsResourceHandler;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-
-public class EMF2DOMAdapterImpl extends AdapterImpl implements EMF2DOMAdapter {
-
- final protected static boolean fDebug = false;
-
- protected boolean fNotificationEnabled = true;
-
- protected Node fNode;
-
- protected Translator fTranslator;
-
- protected EMF2DOMRenderer fRenderer;
-
- protected Translator[] childTranslators;
-
- protected boolean isRoot = false;
-
- private class DependencyAdapter extends org.eclipse.emf.common.notify.impl.AdapterImpl {
-
- static final String KEY = "EMF2DOMDependencyAdapter"; //$NON-NLS-1$
-
- public void notifyChanged(Notification msg) {
- EMF2DOMAdapterImpl.this.notifyChanged(msg);
- }
-
- /**
- * @see org.eclipse.emf.common.notify.impl.AdapterImpl#isAdapterForType(Object)
- */
- public boolean isAdapterForType(Object type) {
- return KEY.equals(type);
- }
- }
-
- /**
- * Constructor for root adapters.
- */
- public EMF2DOMAdapterImpl(TranslatorResource resource, Document document, EMF2DOMRenderer renderer, Translator translator) {
- this((Notifier) resource, (Node) document, renderer, translator);
- isRoot = true;
- }
-
- /**
- * Construct an Adapter given an EObject and a node
- */
- public EMF2DOMAdapterImpl(Notifier object, Node node, EMF2DOMRenderer renderer, Translator translator) {
- super();
- setTarget(object);
- fNode = node;
- fRenderer = renderer;
- fTranslator = translator;
- initChildTranslators();
- addEMFAdapter();
- addDOMAdapter();
- addDependencyAdapterIfNecessary();
- }
-
- /**
- * Construct an adapter from a DOM Node. The EObject will be created
- */
- public EMF2DOMAdapterImpl(Node node, EMF2DOMRenderer renderer, Translator translator) {
- fNode = node;
- fRenderer = renderer;
- fTranslator = translator;
- setTargetFromNode();
- initChildTranslators();
- addEMFAdapter();
- addDOMAdapter();
- addDependencyAdapterIfNecessary();
-
- }
-
- protected void addDependencyAdapterIfNecessary() {
- if (!fTranslator.isDependencyParent())
- return;
- EObject child = fTranslator.basicGetDependencyObject(getEObject());
- if (child != null)
- addDependencyAdapter(child);
- }
-
- protected void initChildTranslators() {
-
- List children = new ArrayList();
- children.addAll(Arrays.asList(fTranslator.getChildren(getTarget(), fRenderer.getVersionID())));
-
- VariableTranslatorFactory factory = fTranslator.getVariableTranslatorFactory();
- if (factory != null) {
- String domName = null;
- NamedNodeMap map = fNode.getAttributes();
-
- if (map != null) {
- int length = map.getLength();
- for (int i = 0; i < length; i++) {
- Node attrNode = map.item(i);
- domName = attrNode.getNodeName();
- //Handle variable translators
- Translator t = fTranslator.findChild(domName, getTarget(), fRenderer.getVersionID());
- if (t != null && !children.contains(t))
- children.add(t);
- }
- }
- List childrenFromEMF = factory.create(getTarget());
- if (childrenFromEMF != null)
- children.addAll(childrenFromEMF);
- }
-
- childTranslators = (Translator[]) children.toArray(new Translator[children.size()]);
- }
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- public boolean isNotificationEnabled() {
- return fNotificationEnabled;
- }
-
- /**
- * Set to false and notification of changes from both the DOM node and the MOF object will be
- * ignored.
- */
- public void setNotificationEnabled(boolean isEnabled) {
- fNotificationEnabled = isEnabled;
- }
-
- public boolean isAdapterForType(Object type) {
- return EMF2DOMAdapter.ADAPTER_CLASS == type;
- }
-
- protected void addEMFAdapter() {
- target.eAdapters().add(this);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- sb.append(shortClassName(this));
- sb.append('(');
- sb.append(getNode().getNodeName());
- sb.append(',');
- sb.append(shortClassName(getTarget()));
- sb.append(')');
- return sb.toString();
- }
-
- protected String shortClassName(Object o) {
- String cn = o.getClass().getName();
- int i = cn.lastIndexOf('.');
- return cn.substring(i + 1, cn.length());
- }
-
- /*
- * Prints out a MOF notification for debugging
- */
- protected void debugMOFNotify(Notification msg) {
- if (fDebug) {
- String notifType = ""; //$NON-NLS-1$
- switch (msg.getEventType()) {
- case Notification.ADD :
- notifType = "ADD"; //$NON-NLS-1$
- break;
- case Notification.REMOVE :
- notifType = "REMOVE"; //$NON-NLS-1$
- break;
- case Notification.ADD_MANY :
- notifType = "ADD_MANY"; //$NON-NLS-1$
- break;
- case Notification.REMOVE_MANY :
- notifType = "REMOVE_MANY"; //$NON-NLS-1$
- break;
- case Notification.SET : {
- if (msg.getPosition() == Notification.NO_INDEX)
- notifType = "REPLACE"; //$NON-NLS-1$
- else
- notifType = "SET"; //$NON-NLS-1$
- break;
- }
- case Notification.UNSET :
- notifType = "UNSET"; //$NON-NLS-1$
- break;
- }
-
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("MOF Change: " + notifType); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tnotifier : " + msg.getNotifier()); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tchangedFeature: " + msg.getFeature()); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\toldValue : " + msg.getOldValue()); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tnewValue : " + msg.getNewValue()); //$NON-NLS-1$
- }
- }
-
- /*
- * Override this method to create the feature maps for the adapter.
- */
- protected Translator[] getChildTranslators() {
- return childTranslators;
- }
-
- protected Translator findTranslator(Notification not) {
- if (not.getFeature() == null)
- return null;
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- if (maps[i].isMapFor(not.getFeature(), not.getOldValue(), not.getNewValue()))
- return maps[i];
- }
- return null;
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- protected void primUpdateDOMMultiFeature(Translator map, Node node, List mofChildren, List domChildren, Notifier owner) {
-
- //Used for inserting primitives
- List inorderDOMChildren = null;
- if (!map.isObjectMap() || map.isManagedByParent()) {
- inorderDOMChildren = new ArrayList();
- inorderDOMChildren.addAll(domChildren);
- }
- Node parent = findDOMPath(node, map, false);
-
- // Go though the MOF children checking to see if the corresponding
- // MOF Adapter children exists. If not, create the adapter.
- // Also handles reordering children that have moved.
- int i = 0;
- for (; i < mofChildren.size(); i++) {
- Object child = mofChildren.get(i);
- EObject mofChild = null;
-
- EMF2DOMAdapter adapter = null;
-
- // Check to see if the child is a MOF Object.
- if (!map.isManagedByParent() && child instanceof EObject) {
- mofChild = (EObject) mofChildren.get(i);
- adapter = getExistingAdapter(mofChild);
- }
-
- if (adapter != null && i < domChildren.size() && domChildren.get(i) == adapter.getNode())
- continue;
- if (adapter != null) {
- if (domChildren.isEmpty())
- continue;
- // A node has been reordered in the list
- Node reorderNode = adapter.getNode();
- Node insertBeforeNode = (Node) domChildren.get(i);
- domChildren.remove(reorderNode);
- domChildren.add(i, reorderNode);
- if (reorderNode != insertBeforeNode) {
- reorderDOMChild(parent, reorderNode, insertBeforeNode, map);
- }
- } else {
- // A new node has been added, create it
- parent = createDOMPath(node, map);
- if (mofChild != null) {
- adapter = createAdapter(mofChild, map);
- Node newNode = adapter.getNode();
- Node insertBeforeNode = findInsertBeforeNode(parent, map, mofChildren, i, domChildren);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, newNode, insertBeforeNode);
- domChildren.add(i, newNode);
- boolean notificationFlag = adapter.isNotificationEnabled();
- adapter.setNotificationEnabled(false);
- try {
- indent(newNode, map);
- } finally {
- adapter.setNotificationEnabled(notificationFlag);
- }
- adapter.updateDOM();
- } else {
- // The mof feature is a collection of primitives.
- // create a new dom node and listen to it.
- Element newNode = createNewNode(null, map);
- Node insertBeforeNode = findInsertBeforeNode(parent, map, mofChildren, i, inorderDOMChildren);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, newNode, insertBeforeNode);
- indent(newNode, map);
- addDOMAdapter(newNode); // Hook up listeners
- domChildren.add(i, newNode);
- inorderDOMChildren.add(newNode);
- Text newText = parent.getOwnerDocument().createTextNode(map.convertValueToString(child, (EObject) owner));
- DOMUtilities.insertBeforeNode(newNode, newText, null);
- }
- }
- }
-
- // Remove any remaining adapters.
- for (; i < domChildren.size(); i++) {
- removeDOMChild(parent, (Element) domChildren.get(i));
- }
-
- // If there are no MOF children, remove any unnecessary DOM node paths
- if (mofChildren.size() == 0 && map.hasDOMPath()) {
- if (map.shouldRenderEmptyDOMPath((EObject) owner))
- createDOMPath(node, map);
- else
- removeDOMPath(node, map);
- }
-
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- protected void primUpdateMOFMultiFeature(Translator map, Node node, List mofChildren, List domChilren) {
-
- Hashtable nodeToAdapter = new Hashtable();
-
- for (int i = 0; i < mofChildren.size(); i++) {
- EMF2DOMAdapter adapter = getExistingAdapter((EObject) mofChildren.get(i));
- if (adapter != null)
- nodeToAdapter.put(adapter.getNode(), adapter);
- }
-
- // Go though the DOM children checking to see if the corresponding
- // MOF Adapter children exists. If not, create the adapter.
- // Also handles reordering children that have moved.
- int i = 0;
- int mofIndex = 0;
- List adaptersToUpdate = new ArrayList();
- for (; i < domChilren.size(); i++) {
- Element childNode = (Element) domChilren.get(i);
- EMF2DOMAdapter adapter = i < mofChildren.size() ? getExistingAdapter((EObject) mofChildren.get(i)) : null;
- if (adapter != null && !adapter.isMOFProxy() && adapter.getNode() == childNode) {
- // Because the adapter is processing STRUCTURE_CHANGED from the
- // DOM, we
- // must update all the way down the tree since anything under
- // the notifying
- // DOM node could have changed.
- adapter.updateMOF();
- mofIndex++;
- continue;
- }
-
- adapter = (EMF2DOMAdapter) nodeToAdapter.get(childNode);
- if (adapter != null) {
- reorderIfNecessary((EList) mofChildren, adapter.getEObject(), mofIndex);
- mofIndex++;
- } else {
- adapter = createAdapter(childNode, map);
- if (adapter != null) {
- try {
- //We don't want to push anything back to the child dom
- adapter.setNotificationEnabled(false);
- map.setMOFValue(getTarget(), adapter.getTarget(), mofIndex);
- } finally {
- adapter.setNotificationEnabled(true);
- }
-
- adaptersToUpdate.add(adapter);
- mofIndex++;
- }
- }
- }
-
- // Remove any remaining adapters.
- for (; i < mofChildren.size();) {
- removeMOFValue((EObject) mofChildren.get(i), map);
- }
-
- // The adapters cannot be updated as they created. We must wait until
- // all of the adapters are created and removed before updating,
- // otherwise
- // we can get in a state where there are adapters fighting with
- // eachother
- // (one for the old node and one for the new node).
- for (int j = 0; j < adaptersToUpdate.size(); j++) {
- ((EMF2DOMAdapter) adaptersToUpdate.get(j)).updateMOF();
- }
- }
-
- /**
- * Removes a feature's value.
- *
- * @param childAdapter
- * com.ibm.etools.mof2dom.EMF2DOMAdapter The child to remove
- * @param mofAttributeName
- * String The name of the mofAttribute to remove the child from.
- */
- protected void removeMOFValue(EObject value, Translator translator) {
-
- if (value == null)
- return;
-
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(value, EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null) {
- // Remove the adapter from BOTH the MOF Object and the DOM Nodes
- value.eAdapters().remove(adapter);
- removeAdapters(adapter.getNode());
- }
-
- EStructuralFeature feature = translator.getFeature();
- boolean doUnload = feature == null || (translator.isObjectMap() && ((EReference) feature).isContainment());
-
- // translator.removeMOFValue() was here originally
-
- // Unload the objects.
- if (doUnload)
- ExtendedEcoreUtil.unload(value);
-
- // Remove the MOF value
- translator.removeMOFValue(getTarget(), value);
- }
-
- protected void reorderIfNecessary(EList emfChildren, EObject eObj, int emfIndex) {
- int currIndex = emfChildren.indexOf(eObj);
- if (currIndex > -1 && currIndex != emfIndex)
- emfChildren.move(emfIndex, eObj);
- }
-
- /**
- * default is to do nothing; subclasses can override
- */
- protected void indent(Node newNode, Translator map) {
-
- }
-
- protected Node findInsertBeforeNode(Node parentNode, Translator map, List mofList, int mofInx, List domList) {
- Node insertBeforeNode = null;
-
- // If there are no current dom children for this map, find the initial
- // insert pos.
- if (domList.size() == 0)
- return findInitialInsertBeforeNode(parentNode, map);
-
- // If some dom nodes then find the correct one to insert before.
- int i = mofInx + 1;
- while (i < mofList.size() && insertBeforeNode == null) {
- // Start at the mofInx passed in and look forward for the first
- // adapted
- // MOF object. Use that node as the insert before node.
- Object o = mofList.get(i);
- if (!map.isObjectMap() || map.isManagedByParent())
- break;
- EObject tMOFObject = (EObject) o;
- EMF2DOMAdapter tAdapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(tMOFObject, EMF2DOMAdapter.ADAPTER_CLASS);
- if (tAdapter != null) {
- insertBeforeNode = tAdapter.getNode();
- }
- i++;
- }
-
- // Handle inserting at the end of the list
- if (insertBeforeNode == null)
- insertBeforeNode = DOMUtilities.getNextNodeSibling((Node) domList.get(domList.size() - 1));
- if (insertBeforeNode == null)
- insertBeforeNode = ((Node) domList.get(domList.size() - 1)).getNextSibling();
-
- return insertBeforeNode;
- }
-
- protected Node findInitialInsertBeforeNode(Node parentNode, Translator mapNode) {
- Translator[] maps = getChildTranslators();
-
- // First, skip past all the maps in the ordered collection
- // of maps. We want to begin the search with this node.
- int i = 0;
- for (; i < maps.length; i++) {
- if (maps[i] == mapNode)
- break;
- }
-
- // Now search go through each map node until a child node matching
- // its DOM name is found.
- Node insertBeforeNode = null;
- for (int j = i; j < maps.length && insertBeforeNode == null; j++) {
- NodeList childNodes = parentNode.getChildNodes();
- Translator nodeToFindMap = maps[j];
- for (int k = 0; k < childNodes.getLength(); k++) {
- Node node = childNodes.item(k);
- if (nodeToFindMap.isMapFor(node.getNodeName())) {
- insertBeforeNode = node;
- break;
- }
- }
- }
- return insertBeforeNode;
- }
-
- /*
- * Traverses the path that <map> specifies. Returns the last node of the path that was able to
- * be traversed or null if the path could not be traversed. The <addAdapters> boolean is used to
- * determine if the receiver is added as an adapter to every node found on the path.
- */
- protected Node findDOMPath(Node parent, Translator map, boolean addAdapters) {
-
- String path = map.getDOMPath();
- Node curNode = parent;
- Iterator iter = DOMUtilities.createPathIterator(path);
-
- while (curNode != null && iter.hasNext()) {
- String nodeName = (String) iter.next();
- curNode = DOMUtilities.getNodeChild(curNode, nodeName);
- if (addAdapters && curNode != null) {
- addDOMAdapter(curNode);
- }
- }
- return curNode;
- }
-
- /**
- * Return the list of DOM node children that currently exist with the specified tagname.
- */
- protected List getDOMChildren(Node node, Translator map) {
- Node parent = findDOMPath(node, map, true);
- if (parent != null)
- return DOMUtilities.getNodeChildren(parent, map.getDOMNames());
- return new ArrayList();
- }
-
- protected EMF2DOMAdapter getExistingAdapter(EObject refObject) {
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(refObject, EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null && adapter.isMOFProxy()) {
- refObject.eAdapters().remove(adapter);
- removeDOMAdapter(adapter.getNode(), adapter);
- adapter = null;
- }
- return adapter;
- }
-
- protected void primAddDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- fRenderer.registerDOMAdapter(aNode, anAdapter);
- }
-
- protected EMF2DOMAdapter primGetExistingAdapter(Node aNode) {
- return fRenderer.getExistingDOMAdapter(aNode);
- }
-
- protected void removeDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- fRenderer.removeDOMAdapter(aNode, anAdapter);
- }
-
- protected void addDOMAdapter(Node childNode) {
-
- // Only add the adapter if this is an child node that will not be
- // adapted. For instance a subtree that maps to a MOF attribute
- // setting.
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- EMF2DOMAdapter attrAdapter = primGetExistingAdapter(childNode);
-
- if (attrAdapter == null || attrAdapter.getNode() != getNode()) {
- // If the node is adapted, but not by this adapter then remove
- // it. This happens to non-object children when the parent tag
- // name is changed.
- removeDOMAdapter(childNode, attrAdapter);
-
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tCHILD: Adding DOM adapter: " + this); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\t\tto: " + childNode); //$NON-NLS-1$
- }
- primAddDOMAdapter(childNode, this);
- }
- }
- }
-
- /**
- * Reorder a child before a given node
- */
- protected void reorderDOMChild(Node parentNode, Node childNode, Node insertBeforeNode, Translator map) {
- try {
- removeDOMChild(parentNode, childNode, false);
- parentNode.insertBefore(childNode, insertBeforeNode);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- protected String getNewlineString(Node node) {
- return DOMUtilities.NEWLINE_STRING;
- }
-
- protected String primGetIndentString(Node node) {
- return DOMUtilities.getIndentString(node);
- }
-
- /**
- * Remove a child node
- */
- protected void removeDOMChild(Node parentNode, Node childNode) {
- removeDOMChild(parentNode, childNode, true);
- }
-
- /**
- * Remove a child node
- */
- protected void removeDOMChild(Node parentNode, Node childNode, boolean removeAdapter) {
- try {
- if (childNode == null)
- return;
- // Look for any whitespace preceeding the node being
- // removed and remove it as well.
- Text prevText = DOMUtilities.getPreviousTextSibling(childNode);
- if (prevText != null && DOMUtilities.isWhitespace(prevText)) {
- parentNode.removeChild(prevText);
- }
- // Remove the node.
- if (removeAdapter)
- removeAdapters(childNode);
- parentNode.removeChild(childNode);
- } catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Remove the DOM adapters from the node AND all its child nodes, recursively.
- */
- public void removeAdapters(Node node) {
- EMF2DOMAdapter adapter = primGetExistingAdapter(node);
- if (adapter != null) {
- // Remove the adapter from both the DOM node and the MOF Object.
- removeDOMAdapter(node, adapter);
- if (adapter.getNode() == node) {
- Notifier localTarget = adapter.getTarget();
- if (localTarget != null)
- localTarget.eAdapters().remove(adapter);
- }
- }
-
- NodeList nl = node.getChildNodes();
- for (int i = 0; i < nl.getLength(); i++) {
- Node n = nl.item(i);
- removeAdapters(n);
- }
- }
-
- /**
- * Creates the path specified by <map>under <node>. Only the portion of the path that does not
- * exist (if any) is created
- *
- * @param node
- * org.w3c.dom.Node
- * @param map
- * com.ibm.etools.mof2dom.Translator
- */
- protected Node createDOMPath(Node node, Translator map) {
- Iterator i = DOMUtilities.createPathIterator(map.getDOMPath());
- Node curNode = node;
- while (i.hasNext()) {
- String nodeName = (String) i.next();
- curNode = findOrCreateNode(node, map, nodeName);
- }
- return curNode;
- }
-
- protected Element findOrCreateNode(Node parent, Translator map, String segment) {
- Node node = DOMUtilities.getNodeChild(parent, segment);
- if (node == null) {
- // The node did not already exist, create it.
- Document doc = parent.getOwnerDocument();
- node = doc.createElement(segment);
- if (map.isEmptyTag())
- setEmptyTag((Element) node);
-
- Node insertBeforeNode = findInitialInsertBeforeNode(parent, map);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, node, insertBeforeNode);
- indent(node, map);
- addDOMAdapter(node); // Hook up listeners
- }
- return (Element) node;
- }
-
- /**
- * Remove the node passed in if it has only whitespace nodes as children
- *
- * @param node
- * org.w3c.dom.Node The node to check
- */
- protected void removeIfEmpty(Node node) {
- NodeList nl = node.getChildNodes();
-
- // Run through all the nodes children. If a non-whitespace node
- // pis found, bail.
- for (int i = 0; i < nl.getLength(); i++) {
- Node childNode = nl.item(i);
- if (!DOMUtilities.isWhitespace(childNode))
- return;
- }
-
- // We only get here if there are no non-whitespace chars, so
- // simply remove the node.
- removeDOMChild(node.getParentNode(), node);
- }
-
- /**
- * Remove the DOM path specified by <map>from <node>
- */
- protected void removeDOMPath(Node node, Translator map) {
- Node childNode = findDOMPath(node, map, false);
- while (childNode != null && childNode != node) {
- removeIfEmpty(childNode);
- childNode = childNode.getParentNode();
- }
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter createAdapter(EObject mofObject, Translator childMap) {
- // Assert.isNotNull(childMap.getChildAdapterClass());
- Assert.isNotNull(mofObject);
-
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getAdapter(mofObject.eAdapters(), EMF2DOMAdapter.ADAPTER_CLASS);
-
- if (adapter != null && adapter.isMOFProxy()) {
- mofObject.eAdapters().remove(adapter);
- removeAdapters(adapter.getNode());
- adapter = null;
- }
- if (adapter == null)
- adapter = primCreateAdapter(mofObject, childMap);
- return adapter;
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(EObject mofObject, Translator childMap) {
-
- Element newNode = createNewNode(mofObject, childMap);
- return new EMF2DOMAdapterImpl(mofObject, newNode, fRenderer, childMap);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter primCreateAdapter(Node node, Translator childMap) {
- return new EMF2DOMAdapterImpl(node, fRenderer, childMap);
- }
-
- /**
- * Create an adapter for a child DOM node
- *
- * @param node
- * org.w3c.dom.Node The node to create the adapter for.
- */
- protected EMF2DOMAdapter createAdapter(Node node, Translator childMap) {
-
- //Assert.isNotNull(childMap.getChildAdapterClass());
- Assert.isNotNull(node);
-
- EMF2DOMAdapter adapter = primGetExistingAdapter(node);
-
- if (adapter != null && adapter.isMOFProxy()) {
- removeDOMAdapter(node, adapter);
- adapter.getTarget().eAdapters().remove(adapter);
- adapter = null;
- }
-
- if (adapter == null) {
- adapter = primCreateAdapter(node, childMap);
- }
- return adapter;
- }
-
- protected Element createNewNode(EObject mofObject, Translator childMap) {
- Node node = getNode();
- Document doc = (node instanceof Document) ? (Document) node : node.getOwnerDocument();
-
- Element element = doc.createElement(childMap.getDOMName(mofObject));
- if (childMap.isEmptyTag())
- setEmptyTag(element);
-
- return element;
- }
-
- protected void setEmptyTag(Element element) {
- Revisit.toDo();
- //Need to figure out how to do this with pure DOM apis, if it is
- // possible
- }
-
- /*
- * Return true if MOF object is a proxy.
- */
- public boolean isMOFProxy() {
- if (isRoot || target == null)
- return false;
- return ((InternalEObject) target).eIsProxy();
- }
-
- public EObject getEObject() {
- if (isRoot)
- return null;
- return (EObject) target;
- }
-
- /**
- * Return the DOM node that the target of this adapter maps to. If the target MOF object maps to
- * more than one DOM node, this node is the top-most node.
- */
- public Node getNode() {
- return fNode;
- }
-
- public void setNode(Node aNode) {
- fNode = aNode;
- }
-
- public void updateDOM() {
- if (!isNotificationEnabled())
- return;
- primUpdateDOM();
- }
-
- public void updateMOF() {
- if (!isNotificationEnabled())
- return;
- primUpdateMOF();
- }
-
- protected void primUpdateDOM() {
- if (isRoot)
- updateDOMRootFeature();
- else {
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- updateDOMFeature(maps[i], getNode(), getEObject());
- }
- }
- }
-
- public void primUpdateMOF() {
- if (isRoot)
- updateMOFRootFeature();
- else {
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- updateMOFFeature(maps[i], getNode(), getEObject());
- }
- }
- }
-
- protected void updateDOMRootFeature() {
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateDOMMultiFeature(fTranslator, fNode, getResourceContents(), getDOMChildren(fNode, fTranslator), null);
- updateDOMDocumentType();
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- protected void updateMOFRootFeature() {
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- updateMOFDocumentType();
- primUpdateMOFMultiFeature(fTranslator, fNode, getResourceContents(), getDOMChildren(fNode, fTranslator));
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- protected DocumentType getDocumentType() {
- return ((Document) fNode).getDoctype();
- }
-
- protected TranslatorResource getResource() {
- return (TranslatorResource) getTarget();
- }
-
- protected EList getResourceContents() {
- if (!isRoot)
- throw new IllegalStateException();
- return ((Resource) getTarget()).getContents();
- }
-
- protected void updateDOMDocumentType() {
-
- DocumentType docType = getDocumentType();
- String publicId = null, systemId = null, oldPublicId, oldSystemId;
- oldPublicId = docType == null ? null : docType.getPublicId();
- oldSystemId = docType == null ? null : docType.getSystemId();
- TranslatorResource resource = getResource();
- if (resource != null) {
- publicId = resource.getPublicId();
- systemId = resource.getSystemId();
- }
- if (!(StringUtil.stringsEqual(publicId, oldPublicId) && StringUtil.stringsEqual(systemId, oldSystemId)))
- fRenderer.replaceDocumentType(resource.getDoctype(), publicId, systemId);
- }
-
- protected void updateDOMDocumentType(Notification msg) {
- if (msg.getFeature() == TranslatorResource.DOC_TYPE_FEATURE)
- updateDOMDocumentType();
- }
-
- protected void updateMOFDocumentType() {
-
- TranslatorResource resource = getResource();
- if (resource == null)
- return;
-
- String publicId = null, systemId = null;
- DocumentType docType = getDocumentType();
-
- if (docType != null) {
- publicId = docType.getPublicId();
- systemId = docType.getSystemId();
- }
- if (!(StringUtil.stringsEqual(publicId, resource.getPublicId()) && StringUtil.stringsEqual(systemId, resource.getSystemId())))
- resource.setDoctypeValues(publicId, systemId);
- }
-
- public void notifyChanged(Notification msg) {
-
- if (isRoot) {
- notifyChangedForRoot(msg);
- return;
- }
- if (isDependencyFeature(msg))
- handleDependencyFeature(msg);
-
- if (!isNotificationEnabled())
- return;
-
- debugMOFNotify(msg);
-
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.REMOVE :
- case Notification.ADD_MANY :
- case Notification.REMOVE_MANY :
- case Notification.SET :
- case Notification.UNSET :
- case Notification.MOVE :
- Translator translator = findTranslator(msg);
- if (translator == null)
- translator = addVariableTranslatorIfNecessary(msg);
- if (translator != null)
- updateDOMFeature(translator, getNode(), getEObject());
- break;
- }
- }
-
- protected void notifyChangedForRoot(Notification msg) {
- if (!isNotificationEnabled())
- return;
-
- debugMOFNotify(msg);
-
- switch (msg.getEventType()) {
- case Notification.ADD :
- case Notification.REMOVE :
- case Notification.ADD_MANY :
- case Notification.REMOVE_MANY :
- primUpdateDOM();
- break;
- case Notification.SET :
- updateDOMDocumentType(msg);
- break;
- case EtoolsCopySession.RESOURCE_COPIED :
- updateDOM();
- break;
- }
- }
-
- protected void addDependencyAdapter(EObject child) {
- Adapter existing = EcoreUtil.getExistingAdapter(child, DependencyAdapter.KEY);
- if (existing != null)
- return;
- DependencyAdapter forwarder = new DependencyAdapter();
- child.eAdapters().add(forwarder);
- forwarder.setTarget(child);
- }
-
- protected void addDOMAdapter() {
-
- primAddDOMAdapter(fNode, this);
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Adding DOM adapter: " + this); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tto: " + fNode); //$NON-NLS-1$
- }
-
- // Go through the maps. All of the DOM nodes that are not listened
- // to by another DOM Node adapter, must be listened to by this adapter.
- NodeList childNodes = fNode.getChildNodes();
- for (int j = 0; j < childNodes.getLength(); j++) {
- Node childNode = childNodes.item(j);
- int nodeType = childNode.getNodeType();
- if (!DOMUtilities.isTextNode(childNode) && nodeType != Node.COMMENT_NODE) {
- Translator map = findTranslator(childNode.getNodeName(), false);
- if (map != null && map.isManagedByParent())
- addDOMAdapter(childNode);
- }
- }
- }
-
- protected Translator addVariableTranslatorIfNecessary(Notification msg) {
- VariableTranslatorFactory fact = fTranslator.getVariableTranslatorFactory();
- Translator trans = null;
- if (fact != null && fact.accepts(msg)) {
- trans = fact.create(msg);
- if (trans != null)
- childTranslators = (Translator[]) Translator.concat(childTranslators, trans);
- }
- return trans;
- }
-
- protected Text createTextNode(Document doc, Translator map, String text) {
- String nonnulltext = (text != null) ? text : ""; //$NON-NLS-1$
- return map.isCDATAContent() ? doc.createCDATASection(nonnulltext) : doc.createTextNode(nonnulltext);
- }
-
- protected String extractReadAheadName() {
- if (!fTranslator.hasReadAheadNames())
- return null;
- String readAheadName = null;
-
- ReadAheadHelper helper = fTranslator.getReadAheadHelper(fNode.getNodeName());
- if (helper == null)
- return null;
-
- Node child = null;
- String[] names = helper.getValues();
- if (helper.getChildDOMName() == null) {
- for (int i = 0; i < names.length; i++) {
- child = DOMUtilities.getNodeChild(fNode, names[i]);
- if (child != null) {
- readAheadName = names[i];
- break;
- }
- }
- } else {
- child = DOMUtilities.getNodeChild(fNode, helper.getChildDOMName());
- if (child != null)
- readAheadName = DOMUtilities.getChildText(child);
- }
- if (readAheadName == null)
- readAheadName = names[0];
- return readAheadName;
- }
-
- /**
- * Extracts the text from <node>and converts it to an object suitable for setting into <feature>
- */
- protected Object extractValue(Node node, Translator map, EObject emfObject) {
-
- // Extract the value from the text child
- Node textNode = DOMUtilities.getChildTextNode(node);
- String trimmedValue = null;
- if (textNode != null)
- trimmedValue = textNode.getNodeValue();
- try {
- return map.convertStringToValue(trimmedValue, emfObject);
- } catch (FeatureValueConversionException ex) {
- handleFeatureValueConversionException(ex);
- return null;
- }
- }
-
- /**
- * @param ex
- */
- protected void handleFeatureValueConversionException(FeatureValueConversionException ex) {
- throw ex;
-
- }
-
- /*
- * Finds the child node that <map> specifies. If there is more than one child that satisfies
- * <map> then the first one is returned.
- *
- * This method traverses past the domPath if one is specified in the <map>.
- */
- protected Node findDOMNode(Node parent, Translator map) {
- return findDOMNode(parent, map, false);
- }
-
- /*
- * Finds the child node that <map> specifies. If there is more than one child that satisfies
- * <map> then the first one is returned. The <addAdapters> boolean is used to determine if the
- * receiver is added as an adapter to every node found on the path.
- *
- * This method traverses past the domPath if one is specified in the <map>.
- */
- protected Node findDOMNode(Node parent, Translator map, boolean addAdapters) {
-
- // First, trace down the path
- Node curNode = findDOMPath(parent, map, addAdapters);
- if (map.isDOMTextValue() || map.isDOMAttribute() || curNode == null)
- return curNode;
-
- // Now look for the first DOM name we can find
- String[] domNames = map.getDOMNames();
- Node node = null;
- for (int i = 0; i < domNames.length; i++) {
- String nodeName = domNames[i];
- List nodes = DOMUtilities.getNodeChildren(curNode, nodeName);
- if (nodes != null && !nodes.isEmpty()) {
- if (nodes.size() > 1)
- handleInvalidMultiNodes(nodeName);
- node = (Node) nodes.get(0);
- if (node != null) {
- if (addAdapters && (map != null || map.isManagedByParent()))
- addDOMAdapter(curNode);
- break;
- }
- }
- }
- return node;
- }
-
- protected void handleInvalidMultiNodes(String nodeName) {
- throw new IllegalStateException(WFTUtilsResourceHandler.getString(WFTUtilsResourceHandler.EMF2DOMAdapterImpl_ERROR_0, new Object[]{nodeName})); //$NON-NLS-1$
- }
-
- /**
- * Creates the path specified by <map>under <node>. Only the portion of the path that does not
- * exist (if any) is created
- *
- * @param node
- * org.w3c.dom.Node
- * @param map
- * com.ibm.etools.mof2dom.Translator
- */
- protected Text findOrCreateTextNode(Node parent, Translator map, String text) {
- Text textNode = DOMUtilities.getChildTextNode(parent);
- if (textNode != null) {
- textNode.setData(text);
- } else {
- if (!isEmptyTag((Element) parent)) {
- Text newNode = createTextNode(parent.getOwnerDocument(), map, text);
- DOMUtilities.insertBeforeNode(parent, newNode, null);
- return newNode;
- }
- }
- return textNode;
- }
-
- protected Translator findTranslator(String tagName, boolean attributeMap) {
- Translator[] maps = getChildTranslators();
- for (int i = 0; i < maps.length; i++) {
- Translator map = maps[i];
- if (map.isMapFor(tagName) && attributeMap == map.isDOMAttribute())
- return maps[i];
- }
-
- return null;
- }
-
- protected EMF2DOMAdapter getExistingAdapter(Node aNode) {
- EMF2DOMAdapter adapter = primGetExistingAdapter(aNode);
- if (adapter != null && adapter.isMOFProxy()) {
- removeDOMAdapter(aNode, adapter);
- adapter.getTarget().eAdapters().remove(adapter);
- adapter = null;
- }
- return adapter;
- }
-
- protected void handleDependencyFeature(Notification msg) {
- if (msg.getOldValue() != null)
- removeDependencyAdapter((EObject) msg.getOldValue());
- if (msg.getNewValue() != null)
- addDependencyAdapter((EObject) msg.getNewValue());
- }
-
- protected boolean isDependencyFeature(Notification msg) {
- switch (msg.getEventType()) {
- case Notification.SET :
- return fTranslator.isDependencyParent() && fTranslator.getDependencyFeature() == msg.getFeature();
- default :
- return false;
- }
- }
-
- protected boolean isEmptyTag(Element parent) {
- Revisit.toDo();
- //Determine how to implement this with pure DOM apis, if possible.
- return false;
- }
-
- protected void postUpdateDOMFeature(Translator map, Node node, EObject mofObject) {
- }
-
- protected void preUpdateDOMFeature(Translator map, Node node, EObject mofObject) {
- }
-
- /**
- * Update an attribute of the target DOM object from with the values currently stored in the MOF
- * object. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator
- */
- protected void primUpdateDOMFeature(Translator map, Node node, EObject mofObject) {
- Object attrValue = null;
- boolean isSet = false;
- if (map.isIDMap()) {
- try {
- attrValue = map.getMOFValue(mofObject);
- } catch (IDTranslator.NoResourceException ex) {
- //If the object has been removed from the resource,
- //No need to update
- return;
- }
- isSet = attrValue != null;
- } else {
- attrValue = map.getMOFValue(mofObject);
- isSet = map.isSetMOFValue(mofObject);
- }
-
- if (map.isDOMAttribute()) {
- // An attribute of the MOF object maps to an attribute of the
- // DOM node. Get the value of the MOF attribute and set it
- // into DOM node.
- Element e = (Element) createDOMPath(node, map);
- if (attrValue != null && isSet)
- e.setAttribute(map.getDOMName(mofObject), map.convertValueToString(attrValue, mofObject));
- else
- e.removeAttribute(map.getDOMName(mofObject));
- } else {
- updateDOMSubtree(map, node, mofObject, attrValue);
- }
- }
-
- /**
- * Update an attribute of the target DOM object from with the values currently stored in the MOF
- * object. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- */
- protected void primUpdateDOMLinkFeature(Translator map, Node node, EObject mofObject) {
- LinkUpdaterTarget.INSTANCE.updateDOM(map, node, mofObject);
-
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- */
- protected void primUpdateDOMMultiFeature(Translator map, Node node, EObject mofObject) {
-
- List mofChildren = map.getMOFChildren(mofObject);
- List domChildren = getDOMChildren(node, map);
-
- primUpdateDOMMultiFeature(map, node, mofChildren, domChildren, mofObject);
- }
-
- /**
- * Update an attribute of the target MOF object from the DOM node subtree. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- */
- protected boolean primUpdateMOFFeature(Translator map, Node node, EObject mofObject) {
- if (!map.featureExists(mofObject))
- return false;
- Object domValue = null;
- boolean updateMOFAttAdapter = false;
- boolean isUnset = false;
- EMF2DOMAdapter attrAdapter = null;
-
- Node child = findDOMNode(node, map, true);
-
- if (map.isDOMAttribute() && child != null) {
- // An attribute of the MOF object maps to an attribute of the
- // DOM node. Get the value of the DOM attribute and set it
- // into the MOF object.
-
- Attr domAttr = (Attr) child.getAttributes().getNamedItem(map.getDOMName(mofObject));
- if (domAttr != null) {
- domValue = domAttr.getValue();
- domValue = map.convertStringToValue((String) domValue, mofObject);
- } else
- isUnset = true;
- } else {
- // An attribute of the MOF object is actually a sub-element
- // of the DOM node. Search for the first sub-element with
- // the correct name to use as an attribute.
- if (child != null) {
- // Check to see if this is a single valued attribute that has
- // a MOF object as its value
- if (!map.isManagedByParent()) {
- attrAdapter = createAdapter(child, map);
- updateMOFAttAdapter = true;
- domValue = attrAdapter.getTarget();
- } else {
- // Check to make sure the child is adapted. If not, adapt
- // it.
- addDOMAdapter(child);
-
- // Extract the value from the text child
- domValue = extractValue(child, map, mofObject);
- }
- } else
- isUnset = true;
- }
-
- // Set the attribute extracted from the DOM to the MOF object.
- boolean hasChanged = true;
- try {
- if (map.isIDMap())
- map.setMOFValue(mofObject, domValue);
- else {
- Object oldValue = null;
- oldValue = map.getMOFValue(mofObject);
- boolean isSet = map.isSetMOFValue(mofObject);
- //In the case of enums with default values, we need to trip
- // the attribute from
- //default to a set value
- if (oldValue == domValue) {
- if (oldValue == null || isSet)
- hasChanged = false;
- } else if (domValue == null && !isSet)
- //If the domValue is null and the feature is not set, then
- // we don't need
- //to do anything
- hasChanged = false;
- else if (oldValue != null && oldValue.equals(domValue) && isSet)
- hasChanged = false;
- if (oldValue == null && domValue == null && map.isSetMOFValue(mofObject) == isUnset)
- hasChanged = true;
- if (hasChanged) {
- if (!(map.isDataType()) && !map.isShared())
- removeMOFValue((EObject) oldValue, map);
- if (domValue == null)
- map.unSetMOFValue(mofObject);
- else
- map.setMOFValue(mofObject, domValue);
-
- if ((domValue == null && !(map.isEnumFeature())) || isUnset)
- map.unSetMOFValue(mofObject); //unset
- // null
- // for
- // non
- // enum
- // features
-
- if (updateMOFAttAdapter)
- attrAdapter.updateMOF();
- }
- }
- } catch (FeatureValueConversionException ex) {
- handleFeatureValueConversionException(ex);
- map.unSetMOFValue(mofObject);
- }
- return hasChanged;
- }
-
- /**
- * Update an attribute of the target MOF object from the DOM node subtree. This method is only
- * called if the DOM node changes and the map is an object link map. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator
- * @return Return true if the MOF feature was updated, false if no update was done.
- */
- protected void primUpdateMOFLinkFeature(Translator map, Node node, EObject mofObject) {
- LinkUpdaterTarget.INSTANCE.updateMOF(map, node, mofObject);
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- protected void primUpdateMOFMultiFeature(Translator map, Node node, EObject mofObject) {
- // If the feature is a collection of strings or ints, call a special
- // method
- // that handles this.
- if (map.isManagedByParent()) {
- updateMOFMultiPrimitiveFeature(map, node, mofObject);
- return;
- }
-
- List nodeChildren = getDOMChildren(node, map);
- List mofChildren = map.getMOFChildren(mofObject);
-
- primUpdateMOFMultiFeature(map, node, mofChildren, nodeChildren);
- }
-
- protected void removeDependencyAdapter(EObject obj) {
- Adapter existing = EcoreUtil.getExistingAdapter(obj, DependencyAdapter.KEY);
- if (existing != null)
- obj.eAdapters().remove(existing);
- }
-
- /**
- * Removes all the DOM children from <parent>that are represented by <map>.
- */
- protected void removeDOMChildren(Node parent, Translator map) {
- String[] domNames = map.getDOMNames();
- HashSet domNamesSet = new HashSet(domNames.length);
- for (int i = 0; i < domNames.length; i++)
- domNamesSet.add(domNames[i]);
-
- // Walk through all the children and find any that match the map.
- NodeList nl = parent.getChildNodes();
- List toRemove = new ArrayList();
- for (int i = 0; i < nl.getLength(); i++) {
- Node childNode = nl.item(i);
- if (domNamesSet.contains(childNode.getNodeName()))
- toRemove.add(childNode);
- }
-
- // Remove any children that were found.
- for (int i = 0; i < toRemove.size(); i++) {
- Node childNode = (Node) toRemove.get(i);
- removeDOMChild(parent, childNode, true);
- }
- }
-
- protected void setTargetFromNode() {
- setTarget(fTranslator.createEMFObject(fNode.getNodeName(), extractReadAheadName()));
- }
-
- /**
- * Update an attribute of the target DOM object from with the values currently stored in the MOF
- * object. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator
- */
- final public void updateDOMFeature(Translator map, Node node, EObject mofObject) {
- if (!isNotificationEnabled())
- return;
- try {
- preUpdateDOMFeature(map, node, mofObject);
- if (map.isMultiValued()) {
- updateDOMMultiFeature(map, node, mofObject);
- return;
- }
-
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating DOM Node: " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateDOMFeature(map, node, mofObject);
- } finally {
- setNotificationEnabled(notificationFlag);
- }
-
- if (map.isTargetLinkMap()) {
- updateDOMLinkFeature(map, node, mofObject);
- }
- } finally {
- postUpdateDOMFeature(map, node, mofObject);
- }
- }
-
- /**
- * Update an attribute of the target DOM object from the values currently stored in the MOF
- * object. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator
- */
- final protected void updateDOMLinkFeature(Translator map, Node node, EObject mofObject) {
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating DOM Node (link): " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- primUpdateDOMLinkFeature(map, node, mofObject);
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- final protected void updateDOMMultiFeature(Translator map, Node node, EObject mofObject) {
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating DOM Node (multi): " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateDOMMultiFeature(map, node, mofObject);
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- /**
- * Update a DOM subtree to reflect the mofObject and map passed in. The subtree is of <node>is
- * updated.
- */
- protected void updateDOMSubtree(Translator map, Node node, EObject mofObject, Object attrValue) {
-
- if (map.featureExists(mofObject)) {
- if ((map.isEnumFeature() || map.isBooleanFeature()) && (map.isUnsettable() && !map.isSetMOFValue(mofObject)))
- attrValue = null;
- } else
- attrValue = map.extractStringValue(mofObject);
-
- // Create and/or update the DOM subtree
- if (attrValue != null) {
- Node parent = createDOMPath(node, map);
- if (map.isManagedByParent()) {
- // Handle the case where the mof value is not another
- // mof object (primitive)
- if (map.getDOMName(mofObject) != null && map.getDOMName(mofObject).startsWith("#")) //$NON-NLS-1$
- return;
-
- Element child = map.isDOMTextValue() ? (Element) parent : findOrCreateNode(parent, map, map.getDOMName(mofObject));
-
- findOrCreateTextNode(child, map, map.convertValueToString(attrValue, mofObject));
- } else {
- // Handle the case were the mof value is a mof object.
- EObject mofValue = (EObject) attrValue;
- EMF2DOMAdapter valueAdapter = (EMF2DOMAdapter) EcoreUtil.getExistingAdapter(mofValue, EMF2DOMAdapter.ADAPTER_CLASS);
- if (valueAdapter != null)
- valueAdapter.updateDOM();
- else {
- removeDOMChildren(parent, map);
- EMF2DOMAdapter adapter = createAdapter(mofValue, map);
- List mofChildren = map.getMOFChildren(mofObject);
- List domChildren = getDOMChildren(parent, map);
-
- Node insertBeforeNode = findInsertBeforeNode(parent, map, mofChildren, 0, domChildren);
- DOMUtilities.insertBeforeNodeAndWhitespace(parent, adapter.getNode(), insertBeforeNode);
- boolean notificationFlag = adapter.isNotificationEnabled();
- adapter.setNotificationEnabled(false);
- try {
- indent(adapter.getNode(), map);
- } finally {
- adapter.setNotificationEnabled(notificationFlag);
- }
- adapter.updateDOM();
- }
- }
- } else {
- // The attribute value was set to null or unset. Remove any
- // existing DOM nodes.
- Node child = findDOMNode(node, map);
- if (child != null)
- removeDOMChild(child.getParentNode(), child);
- }
- }
-
- /**
- * Update a feature that is set by linking to another existing object. This method is called
- * when the MOF object is updated in order to update DOM nodes.
- */
- final protected void updateMOFLinkFeature(Translator map, Node node, EObject mofObject) {
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating MOFObject (link): " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateMOFLinkFeature(map, node, mofObject);
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator Describes the mapping from the MOF
- * attribute name to the DOM node name
- */
- final protected void updateMOFMultiFeature(Translator map, Node node, EObject mofObject) {
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating MOFObject (multi): " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- boolean notificationFlag = isNotificationEnabled();
- try {
- setNotificationEnabled(false);
- primUpdateMOFMultiFeature(map, node, mofObject);
- } finally {
- setNotificationEnabled(notificationFlag);
- }
- }
-
- /**
- * Update all the children of the target MOF object in the relationship described by
- *
- * @map. The relationship MUST BE a collection of string for this method to work.
- */
- protected void updateMOFMultiPrimitiveFeature(Translator map, Node node, EObject mofObject) {
- List nodeChildren = getDOMChildren(node, map);
-
- map.clearList(mofObject);
-
- // Go through the list of nodes and update the MOF collection
- for (int i = 0; i < nodeChildren.size(); i++) {
- Node child = (Node) nodeChildren.get(i);
- Object attributeValue = extractValue(child, map, mofObject);
- if (attributeValue != null)
- map.setMOFValue(mofObject, attributeValue, i);
-
- // Adapt the node so update will occur.
- addDOMAdapter(child);
- }
- if (map.hasDOMPath() && nodeChildren.isEmpty() && findDOMPath(node, map, false) != null)
- map.setMOFValueFromEmptyDOMPath(mofObject);
- }
-
- /**
- * Update an attribute of the target MOF object from the DOM node subtree. The
- *
- * @map specifies the name of the MOF attribute to update and the name of the DOM node.
- *
- * @param map
- * com.ibm.etools.mof2dom.AttributeTranslator
- */
- public void updateMOFFeature(Translator map, Node node, EObject mofObject) {
- if (!isNotificationEnabled())
- return;
- if (map.isMultiValued()) {
- updateMOFMultiFeature(map, node, mofObject);
- return;
- } else if (map.isComment()) {
- updateMOFCommentFeature(map, node, mofObject);
- return;
- }
-
- // TODO MDE Add a map.isComment() and updateMOFCommentFeature(map, node, mofObject);
-
- if (fDebug) {
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("Updating MOFObject: " + mofObject); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tfrom: " + node); //$NON-NLS-1$
- org.eclipse.jem.util.logger.proxy.Logger.getLogger().logError("\tmap : " + map); //$NON-NLS-1$
- }
- boolean notificationFlag = isNotificationEnabled();
- boolean hasChanged = false;
- try {
- setNotificationEnabled(false);
- hasChanged = primUpdateMOFFeature(map, node, mofObject);
- } finally {
- setNotificationEnabled(notificationFlag);
- }
-
- if (map.isTargetLinkMap() && hasChanged)
- updateMOFLinkFeature(map, node, mofObject);
- }
-
- /**
- * @param map
- * @param node
- * @param mofObject
- */
- public void updateMOFCommentFeature(Translator map, Node node, EObject mofObject) {
- Node commentNode = node;
- /* scan up the dom to find the first comment node before this node */
- while ((commentNode = commentNode.getPreviousSibling()) != null && commentNode.getNodeType() != Node.COMMENT_NODE) {
- /* no comment available */
- if (commentNode.getNodeType() == Node.ELEMENT_NODE)
- return;
- }
- if (commentNode != null)
- map.setMOFValue(mofObject, commentNode.getNodeValue());
-
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRenderer.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRenderer.java
deleted file mode 100644
index 206860d42..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRenderer.java
+++ /dev/null
@@ -1,264 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Map;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.eclipse.wst.common.internal.emf.utilities.DOMLoadOptions;
-import org.eclipse.wst.common.internal.emf.utilities.DOMUtilities;
-import org.eclipse.wst.common.internal.emf.utilities.Revisit;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-
-
-public class EMF2DOMRenderer extends AbstractRendererImpl implements Renderer {
-
- protected Map domAdapterRegistry;
- protected boolean needsToCreateDOM = true;
- protected Document document;
-
- /**
- * Constructor for DOMRendererImpl.
- */
- public EMF2DOMRenderer() {
- super();
- if (managesDOMAdapters())
- initDOMAdapterRegistry();
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#doLoad(InputStream, Map)
- */
- public void doLoad(InputStream in, Map options) throws IOException {
- if ((in != null) || !useStreamsForIO()) {
- loadDocument(in, options);
- EMF2DOMAdapter adapter = createRootDOMAdapter();
- adapter.updateMOF();
- }
- }
-
- protected void loadDocument(InputStream in, Map options) throws IOException {
- try {
- DOMLoadOptions domOpts = new DOMLoadOptions();
- domOpts.setAllowJavaEncodings(true);
- domOpts.setExpandEntityRefererences(true);
- domOpts.setValidate(isValidating());
- document = DOMUtilities.loadDocument(in, domOpts, getResource().getEntityResolver());
- needsToCreateDOM = false;
- } catch (RuntimeException t_rex) {
- throw t_rex;
- } catch (IOException iox) {
- throw iox;
- } catch (Exception ex) {
- throw new WrappedException(ex);
- }
- }
-
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#doSave(OutputStream, Map)
- */
- public void doSave(OutputStream outputStream, Map options) throws IOException {
- createDOMTreeIfNecessary();
- serializeDocument(outputStream);
- }
-
- /**
- * Subclasses should override if adapters are not cached within this renderer, e.g., they are
- * stored in notifying Nodes
- */
- protected boolean managesDOMAdapters() {
- return true;
- }
-
- protected void initDOMAdapterRegistry() {
- if (domAdapterRegistry == null)
- domAdapterRegistry = new HashMap();
- }
-
- public void registerDOMAdapter(Node node, EMF2DOMAdapter adapter) {
- domAdapterRegistry.put(node, adapter);
- }
-
- public EMF2DOMAdapter getExistingDOMAdapter(Node node) {
- return (EMF2DOMAdapter) domAdapterRegistry.get(node);
- }
-
- public void removeDOMAdapter(Node aNode, EMF2DOMAdapter anAdapter) {
- domAdapterRegistry.remove(aNode);
- }
-
- /**
- * @see com.ibm.etools.emf2xml.Renderer#prepareToAddContents()
- */
- public void prepareToAddContents() {
- // createDOMTreeIfNecessary();
- }
-
- protected Node createDOMTree() {
- createDocument();
- EMF2DOMAdapter adapter = createRootDOMAdapter();
- adapter.updateDOM();
- needsToCreateDOM = false;
- return document;
- }
-
-
- protected EMF2DOMAdapter createRootDOMAdapter() {
- EMF2DOMAdapter root = new EMF2DOMAdapterImpl(getResource(), document, this, getResource().getRootTranslator());
- registerDOMAdapter(document, root);
- return root;
- }
-
-
- protected void createDOMTreeIfNecessary() {
- if (needsToCreateDOM)
- createDOMTree();
- }
-
- /**
- * Create a new Document given
- *
- * @aResource.
- */
- protected void createDocument() {
- TranslatorResource res = getResource();
- res.setDefaults();
- try {
- document = DOMUtilities.createNewDocument(res.getDoctype(), res.getPublicId(), res.getSystemId());
- } catch (ParserConfigurationException e) {
- throw new WrappedException(e);
- } catch (SAXException e) {
- throw new WrappedException(e);
- } catch (IOException e) {
- throw new WrappedException(e);
- }
- }
-
- public void serializeDocument(OutputStream out) throws IOException {
- /*
- * OutputFormat format = createOutputFormat(); Serializer serializer =
- * SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(out, format);
- * serializer.asDOMSerializer().serialize(document);
- */
- try {
- TransformerFactory factory = TransformerFactory.newInstance();
- /*
- * try { factory.setAttribute(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA); } catch
- * (IllegalArgumentException x) { }
- */
- Transformer transformer = factory.newTransformer();
-
- transformer.setOutputProperty(OutputKeys.ENCODING, getResource().getEncoding());
- transformer.setOutputProperty(OutputKeys.VERSION, getResource().getXMLVersion());
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); //$NON-NLS-1$
- if (getResource().getPublicId() != null)
- transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, getResource().getPublicId());
- if (getResource().getSystemId() != null)
- transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, getResource().getSystemId());
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
- DOMSource source = new DOMSource(document.getDocumentElement());
- /* source.setSystemId(getResource().getSystemId()); */
- transformer.transform(source, new StreamResult(out));
- } catch (TransformerConfigurationException e) {
- Logger.getLogger().logError(e);
- } catch (TransformerFactoryConfigurationError e) {
- Logger.getLogger().logError(e);
- } catch (TransformerException e) {
- Logger.getLogger().logError(e);
- } finally {
- }
- }
-
- /*
- * protected OutputFormat createOutputFormat() { OutputFormat format = new OutputFormat();
- * format.setIndenting(true); format.setLineSeparator(DOMUtilities.NEWLINE_STRING);
- * //$NON-NLS-1$ format.setEncoding(getResource().getEncoding());
- * format.setVersion(getResource().getXMLVersion()); return format; }
- */
-
- public void replaceDocumentType(String docTypeName, String publicId, String systemId) {
- Revisit.revisit();
- Document newDoc = null;
- // Need be able to update the doctype directly on the existing document; right now can't
- // because
- // of limitations on parser neutral apis
-
- try {
- newDoc = DOMUtilities.createNewDocument(docTypeName, publicId, systemId);
- } catch (ParserConfigurationException e) {
- throw new WrappedException(e);
- } catch (SAXException e) {
- throw new WrappedException(e);
- } catch (IOException e) {
- throw new WrappedException(e);
- }
-
-
- replaceNode(document.getDocumentElement(), newDoc, newDoc);
- readapt(document, newDoc);
- document = newDoc;
- }
-
- protected void replaceNode(Node oldChild, Node newParent, Document newDoc) {
- Node newChild = newDoc.importNode(oldChild, false);
- newParent.appendChild(newChild);
- readapt(oldChild, newChild);
- NodeList children = oldChild.getChildNodes();
- int length = children.getLength();
- for (int i = 0; i < length; i++) {
- replaceNode(children.item(i), newChild, newDoc);
- }
- }
-
- public void preUnload() {
- EMF2DOMAdapter adapter = (EMF2DOMAdapter) EcoreUtil.getAdapter(resource.eAdapters(), EMF2DOMAdapter.ADAPTER_CLASS);
- if (adapter != null) {
- adapter.removeAdapters(adapter.getNode());
- }
- }
-
- protected void readapt(Node oldChild, Node newChild) {
- EMF2DOMAdapter adapter = getExistingDOMAdapter(oldChild);
- if (adapter != null) {
- registerDOMAdapter(newChild, adapter);
- // Some nodes are managed by the parent and thus the
- // node should not be set on the parent adapter
- if (adapter.getNode() == oldChild)
- adapter.setNode(newChild);
- }
- }
-
- public int getVersionID() {
- return getResource().getVersionID();
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactory.java
deleted file mode 100644
index fce560371..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactory.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-public class EMF2DOMRendererFactory extends RendererFactory {
-
- public static final EMF2DOMRendererFactory INSTANCE = new EMF2DOMRendererFactory();
-
- public EMF2DOMRendererFactory() {
- super();
- }
-
- /**
- * @see com.ibm.etools.emf2xml.RendererFactory#createRenderer()
- */
- public Renderer createRenderer() {
- EMF2DOMRenderer renderer = new EMF2DOMRenderer();
- renderer.setValidating(isValidating());
- return renderer;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactoryDefaultHandler.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactoryDefaultHandler.java
deleted file mode 100644
index 1257a061a..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2DOMRendererFactoryDefaultHandler.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Dec 1, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-/**
- * @author schacher
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public class EMF2DOMRendererFactoryDefaultHandler implements RendererFactoryDefaultHandler {
-
- public static final EMF2DOMRendererFactoryDefaultHandler INSTANCE = new EMF2DOMRendererFactoryDefaultHandler();
-
- /**
- *
- */
- protected EMF2DOMRendererFactoryDefaultHandler() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.RendererFactoryDefaultHandler#getDefaultRendererFactory()
- */
- public RendererFactory getDefaultRendererFactory() {
- return EMF2DOMRendererFactory.INSTANCE;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXDocumentHandler.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXDocumentHandler.java
deleted file mode 100644
index 1ec3dbe9e..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXDocumentHandler.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.io.IOException;
-
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.xml.sax.Attributes;
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-/**
- * The EMF2SAXDocumentHandler is utilized by the SAX parser to announce XML Events, such as
- * beginning and end of XML elements and the contents of those elements.
- *
- * @author mdelder
- */
-public class EMF2SAXDocumentHandler extends DefaultHandler {
-
- private TranslatorResource resource = null;
- private final CacheEventStack eventStack = new CacheEventStack();
- private CacheEventPool availableEventPool = new CacheEventPool();
-
- /**
- * Create an EMF2SAXDocumentHandler to populate the given resource.
- *
- */
- public EMF2SAXDocumentHandler(TranslatorResource resource) {
- this.resource = resource;
- }
-
- /**
- * @see org.xml.sax.helpers.DefaultHandler#resolveEntity(java.lang.String, java.lang.String)
- */
- public InputSource resolveEntity(String publicId, String systemId) throws SAXException {
- InputSource result = null;
- this.resource.setDoctypeValues(publicId, systemId);
-
- try {
- EntityResolver entityResolver = this.resource.getEntityResolver();
-
- if (entityResolver != null)
- result = entityResolver.resolveEntity(publicId, systemId);
- else
- result = super.resolveEntity(publicId, systemId);
- } catch (IOException ioe) {
- throw new SAXException(ioe);
- }
-
- return result;
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startDocument()
- */
- public void startDocument() throws SAXException {
- /*
- * The endDocument() method should have frozen the pool, or it may not be warmed yet. In
- * either case, this method call will do as little work as necessary
- */
- availableEventPool.warmPool();
-
- /* This line should not be necessary, but is left for safty */
- eventStack.clear();
- this.createRoot(this.resource);
-
- }
-
- /**
- * @see org.xml.sax.ContentHandler#startElement(java.lang.String, java.lang.String,
- * java.lang.String, org.xml.sax.Attributes)
- */
- public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
- addToStack(qName, attributes);
- }
-
- /**
- * @see org.xml.sax.ContentHandler#characters(char[], int, int)
- */
- public void characters(char[] data, int start, int length) throws SAXException {
-
- CacheEventNode currentRecord = getCurrentRecord();
- if (currentRecord != null) {
- currentRecord.appendToBuffer(data, start, length);
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endElement(java.lang.String, java.lang.String,
- * java.lang.String)
- */
- public void endElement(String uri, String localName, String qName) throws SAXException {
-
- CacheEventNode currentRecord = null;
-
- /*
- * This should only happen in the case where the DOMPath was ignored so the stack does not
- * quite match with the XML data structure. In this case we do nothing
- */
- if (qName.equals(this.getCurrentRecord().getNodeName())) {
- currentRecord = this.removeCurrentRecord();
- if (currentRecord != null) {
- currentRecord.commit();
- }
- }
- }
-
- /**
- * @see org.xml.sax.ContentHandler#endDocument()
- */
- public void endDocument() throws SAXException {
- CacheEventNode lastRecord = this.removeCurrentRecord();
- lastRecord.commit();
- availableEventPool.freezePool();
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#error(org.xml.sax.SAXParseException)
- */
- public void error(SAXParseException ex) throws SAXException {
- throw ex;
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#fatalError(org.xml.sax.SAXParseException)
- */
- public void fatalError(SAXParseException ex) throws SAXException {
- throw ex;
- }
-
- /**
- * @see org.xml.sax.ErrorHandler#warning(org.xml.sax.SAXParseException)
- */
- public void warning(SAXParseException ex) throws SAXException {
- Logger.getLogger().logWarning(ex);
- }
-
- /**
- * @return
- */
- public TranslatorResource getResource() {
- return resource;
- }
-
- protected void createRoot(TranslatorResource resourceArg) {
- this.eventStack.push(availableEventPool.createCacheEventNode(resourceArg));
- }
-
- protected void addToStack(String nodeName, Attributes attributes) {
- CacheEventNode parent = this.getCurrentRecord();
- if (!parent.isChildIgnorable(nodeName)) {
- this.eventStack.push(availableEventPool.createCacheEventNode(parent, nodeName, attributes));
- }
- }
-
- /**
- * Return the current CENO without removing it from the event stack.
- *
- * @return the current CENO without removing it
- */
- protected CacheEventNode getCurrentRecord() {
- CacheEventNode result = null;
- if (!this.eventStack.isEmpty()) {
- result = this.eventStack.peek();
- }
- return result;
- }
-
- /**
- * Return the current CENO and remove it from the event stack.
- *
- * @return the current CENO and remove it
- */
- protected CacheEventNode removeCurrentRecord() {
- CacheEventNode result = null;
- if (!this.eventStack.isEmpty()) {
- result = this.eventStack.pop();
- }
- return result;
- }
-
- // private final void printStack() {
- // // System.out.println("Printing stack ...");
- // // for (int i = 0; i < this.eventStack.size(); i++) {
- // // debug("stack[" + i + "]: " + eventStack.get(i));
- // // }
- // // System.out.println("... Printed stack");
- // }
- //
- // private final static void debug(Object obj) {
- // // System.out.println(obj);
- // }
- //
- // private final static void warn(Object obj) {
- // //System.err.println(obj);
- // }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRenderer.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRenderer.java
deleted file mode 100644
index 7bd2634e3..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRenderer.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.sax.SAXTransformerFactory;
-import javax.xml.transform.sax.TransformerHandler;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.emf.common.util.WrappedException;
-import org.eclipse.jem.util.logger.proxy.Logger;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXNotRecognizedException;
-import org.xml.sax.XMLReader;
-
-/**
- * @author mdelder
- */
-public class EMF2SAXRenderer extends AbstractRendererImpl {
-
- /**
- *
- */
- public EMF2SAXRenderer() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#doLoad(java.io.InputStream, java.util.Map)
- */
- public void doLoad(InputStream in, Map options) {
- try {
- SAXParserFactory factory = SAXParserFactory.newInstance();
- factory.setValidating(isValidating());
- factory.setNamespaceAware(true);
- /*
- * Causes errors in IBM JDK try { factory.setAttribute(JAXP_SCHEMA_LANGUAGE,
- * W3C_XML_SCHEMA); } catch (IllegalArgumentException x) { }
- */
- SAXParser parser = factory.newSAXParser();
- XMLReader reader = parser.getXMLReader();
- EMF2SAXDocumentHandler handler = new EMF2SAXDocumentHandler(this.getResource());
- try {
- reader.setFeature("http://xml.org/sax/features/validation", isValidating()); //$NON-NLS-1$
- } catch (SAXNotRecognizedException snre) {
- }
- try {
- reader.setFeature("http://xml.org/sax/features/namespace-prefixes", true); //$NON-NLS-1$
- } catch (SAXNotRecognizedException snre) {
- }
- try {
- reader.setFeature("http://apache.org/xml/features/validation/schema", isValidating()); //$NON-NLS-1$
- } catch (SAXNotRecognizedException e) {
- reader.setFeature("http://xml.org/sax/features/validation", false); //$NON-NLS-1$
- Logger.getLogger().log("Warning: Parser does not support \"http://apache.org/xml/features/validation/schema\". Validation will be disabled."); //$NON-NLS-1$
- }
- try {
- reader.setFeature("http://apache.org/xml/features/allow-java-encodings", true); //$NON-NLS-1$
- } catch (SAXNotRecognizedException e) {
- Logger.getLogger().log("Warning: Parser does not support \"http://apache.org/xml/features/allow-java-encodings\"."); //$NON-NLS-1$
- }
- /*
- * try { reader.setProperty("http://xml.org/sax/properties/lexical-handler", handler); }
- * catch (SAXNotRecognizedException e) { }
- */
- reader.setContentHandler(handler);
- reader.setErrorHandler(handler);
- //reader.setDTDHandler(handler);
- reader.setEntityResolver(handler);
- InputSource testsource = new InputSource(in);
- reader.parse(testsource);
- } catch (RuntimeException t_rex) {
- throw t_rex;
- } catch (Exception ex) {
- throw new WrappedException(ex);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#doSave(java.io.OutputStream, java.util.Map)
- */
- public void doSave(OutputStream outputStream, Map options) throws IOException {
-
- /*
- * try { Serializer serializer =
- * SerializerFactory.getSerializerFactory(Method.XML).makeSerializer(outputStream,
- * createOutputFormat()); serializer.setOutputByteStream(outputStream); ContentHandler
- * handler = serializer.asContentHandler();
- */
-
- TransformerHandler handler = null;
- try {
- try {
- SAXTransformerFactory factory = (SAXTransformerFactory) TransformerFactory.newInstance();
- handler = factory.newTransformerHandler();
-
- handler.setResult(new StreamResult(outputStream));
- Transformer transformer = handler.getTransformer();
- transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.ENCODING, getResource().getEncoding());
- transformer.setOutputProperty(OutputKeys.VERSION, getResource().getXMLVersion());
- transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no"); //$NON-NLS-1$
- transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (getResource().getPublicId() != null)
- transformer.setOutputProperty(OutputKeys.DOCTYPE_PUBLIC, getResource().getPublicId());
- if (getResource().getSystemId() != null)
- transformer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM, getResource().getSystemId());
-
- } catch (TransformerConfigurationException e) {
- Logger.getLogger().logError(e);
- } catch (TransformerFactoryConfigurationError e) {
- Logger.getLogger().logError(e);
- }
- if (handler == null) {
- Logger.getLogger("SAX Writer is null"); //$NON-NLS-1$
- return;
- }
- EMF2SAXWriter writer = new EMF2SAXWriter();
- writer.serialize(this.resource, handler);
- } catch (SAXException saxe) {
- throw new WrappedException(saxe);
- }
- }
-
- /*
- * protected OutputFormat createOutputFormat() { OutputFormat format = new OutputFormat();
- * format.setIndenting(true); format.setLineSeparator(DOMUtilities.NEWLINE_STRING);
- * //$NON-NLS-1$ format.setEncoding(getResource().getEncoding());
- * format.setVersion(getResource().getXMLVersion()); if (this.resource != null)
- * format.setDoctype(this.resource.getPublicId(), this.resource.getSystemId()); return format; }
- */
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#prepareToAddContents()
- */
- public void prepareToAddContents() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.Renderer#getVersionID()
- */
- public int getVersionID() {
- return getResource().getVersionID();
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRendererFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRendererFactory.java
deleted file mode 100644
index d3fd5d91b..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXRendererFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Aug 19, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-/**
- * Used to create instances of the EMF2SAXRenderer
- *
- * @author mdelder
- */
-public class EMF2SAXRendererFactory extends RendererFactory {
-
- public static final EMF2SAXRendererFactory INSTANCE = new EMF2SAXRendererFactory();
-
- protected EMF2SAXRendererFactory() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.RendererFactory#createRenderer()
- */
- public Renderer createRenderer() {
- EMF2SAXRenderer renderer = new EMF2SAXRenderer();
- renderer.setValidating(isValidating());
- return renderer;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXWriter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXWriter.java
deleted file mode 100644
index c5d08070e..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/EMF2SAXWriter.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EObject;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.AttributesImpl;
-
-/**
- * The EMF2SAXWriter handles the serialization of EMF Resources using SAX events. SAX events are
- * triggered to the content handler as the tree is being parsed. These events can then be written
- * into any stream wrapped by the ContentHandler.
- *
- * @author mdelder
- */
-public class EMF2SAXWriter {
-
- public static final String NAMESPACE = "";//"http://java.sun.com/xml/ns/j2ee"; //$NON-NLS-1$
-
- /* Used in those cases where no Attributes are necessary */
- private static final Attributes EMPTY_ATTRIBUTES = new AttributesImpl();
-
- /**
- * Serialize an EMF resource into an XML Stream using the given ContentHandler. Note that this
- * method can also be used to copy a given EMF Resource if the EMF2SAXDocumentHandler is used as
- * the given ContentHandler.
- *
- * @param resource
- * @param handler
- */
- public void serialize(TranslatorResource resource, ContentHandler handler) throws SAXException {
-
- Translator rootTranslator = resource.getRootTranslator();
- EList contents = resource.getContents();
-
- if (contents.size() != 1) {
- throw new IllegalStateException("The contents of a resource may only contain one EMF Model Object."); //$NON-NLS-1$
- }
- handler.startDocument();
- EObject element = (EObject) contents.get(0);
- serialize(handler, element, rootTranslator, new WriterHints(resource));
- handler.endDocument();
-
- }
-
- private void serialize(ContentHandler handler, EObject target, Translator translator, WriterHints hints) throws SAXException {
-
- List mofChildren = null;
- Object rawValue = null;
- EObject newTarget = null;
- Translator currentChildTranslator = null;
- Translator nextTranslator = null;
- char[] characterData = null;
- String convertedValue = null;
- Attributes attributes = null;
- String childDomName = null;
- final int version = hints.getVersion();
-
- /*
- * Processing hints are used to remember where are in the iteration of the translator's
- * children. see the TranslatorFilter for more information on how this array is used.
- */
- int[] processingHints = TranslatorFilter.createProcessingHints();
-
- String targetDomName = translator.getDOMName(target);
-
- attributes = getAttributes(translator, target, hints);
-
- handler.startElement(NAMESPACE, targetDomName, targetDomName, attributes);
-
- currentChildTranslator = TranslatorFilter.getNextObjectTranslator(translator, processingHints[TranslatorFilter.NEXT_START_HINT_INDX], processingHints, target, version);
- while (currentChildTranslator != null) {
- /* For each Child Translator of the Translator parameter passed into the method */
-
- /* Does the Translator have any MOF Children? */
- mofChildren = currentChildTranslator.getMOFChildren(target);
- openDomPathIfNecessary(handler, hints, currentChildTranslator, target, mofChildren);
-
- if (currentChildTranslator.isManagedByParent()) {
- /*
- * Translators which are managed by their parents require less processing -- just
- * convert their value to a string and write it out as the content of an XML element
- */
- childDomName = currentChildTranslator.getDOMName(target);
- if (!currentChildTranslator.isEmptyTag()) {
- /* The Translator is not an Empty tag. Its text content is significant */
-
- if (mofChildren.size() > 0) {
- for (int j = 0; j < mofChildren.size(); j++) {
-
- /* Text only translators will not have open and close XML elements */
- if (!currentChildTranslator.isDOMTextValue())
- handler.startElement(NAMESPACE, childDomName, childDomName, EMPTY_ATTRIBUTES);
-
- rawValue = mofChildren.get(j);
- /* convertValueToString should always return a non-null String */
- convertedValue = currentChildTranslator.convertValueToString(rawValue, target);
- characterData = XMLEncoderDecoder.escape(convertedValue).toCharArray();
- handler.characters(characterData, 0, characterData.length);
-
- if (!currentChildTranslator.isDOMTextValue())
- handler.endElement(NAMESPACE, childDomName, childDomName);
- }
- }
- } else {
- /*
- * The Translator is an Empty Element (its mere presence has significance) (e.g.
- * <cascade-delete/>
- */
-
- if (currentChildTranslator.isBooleanFeature()) {
- /* Boolean features may or may not be rendered */
- rawValue = mofChildren.get(0);
- if (rawValue != null && ((Boolean) rawValue).booleanValue()) {
- handler.startElement(NAMESPACE, childDomName, childDomName, EMPTY_ATTRIBUTES);
- handler.endElement(NAMESPACE, childDomName, childDomName);
- }
-
- } else {
- /* Always render any other Empty elements */
- handler.startElement(NAMESPACE, childDomName, childDomName, EMPTY_ATTRIBUTES);
- handler.endElement(NAMESPACE, childDomName, childDomName);
- }
- }
- } else {
-
- /* The Translator is a more complex feature, handle its processing recursively */
- for (int j = 0; j < mofChildren.size(); j++) {
- newTarget = (EObject) mofChildren.get(j);
- serialize(handler, newTarget, currentChildTranslator, hints);
- }
- }
-
- /* Fetch the next peer translator */
- nextTranslator = TranslatorFilter.getNextObjectTranslator(translator, processingHints[TranslatorFilter.NEXT_START_HINT_INDX], processingHints, target, version);
-
- closeDomPathIfNecessary(handler, hints, currentChildTranslator, nextTranslator, target, mofChildren);
-
- /*
- * We needed to invoke closeDomPathIfNecessary() with the peer, now we move on to
- * process that peer
- */
- currentChildTranslator = nextTranslator;
-
- }
- handler.endElement(NAMESPACE, targetDomName, targetDomName);
- }
-
- /**
- * Determines whether or not a DOM Path should be rendered. This method is particularly useful
- * for determining whether Empty XML elements are relevant and should be written to the XML
- * stream.
- *
- * @param target
- * The EMF Target of the Translation
- * @param currentChildTranslator
- * The current Translator
- * @param mofChildren
- * The mofChildren that were found for the Translator on the Target
- * @return
- */
- private boolean shouldRenderDomPath(EObject target, Translator currentChildTranslator, List mofChildren) {
- return !currentChildTranslator.isEmptyContentSignificant() || (currentChildTranslator.shouldRenderEmptyDOMPath(target) || mofChildren.size() > 0);
- }
-
- /**
- * openDomPathIfNecessary will write the current DOM Path to the serialization stream if it has
- * not been written by a previous peer translator. The processing results in the collapse of
- * Peer Translators with matching DOM Paths into a single XML parent element.
- *
- * @param handler
- * The ContentHandler which is writing the XML result
- * @param hints
- * A Global container for information specific to a single XML document
- * @param currentChildTranslator
- * The active Translator being processed
- * @param target
- * The EMF Target of the Translation
- * @throws SAXException
- */
- private void openDomPathIfNecessary(ContentHandler handler, WriterHints hints, Translator currentChildTranslator, EObject target, List mofChildren) throws SAXException {
-
- /* If the translator does not have a DOM Path, then we do nothing */
- if (currentChildTranslator.hasDOMPath() && shouldRenderDomPath(target, currentChildTranslator, mofChildren)) {
-
- String childDomPath = currentChildTranslator.getDOMPath();
-
- /*
- * IsDomPathActive() will verify whether this DOM Path has already been written to the
- * XML stream
- */
- if (!hints.isDomPathActive(childDomPath)) {
-
- /*
- * Write an open element for the DOM Path and "remember" that we have written it
- */
- handler.startElement(NAMESPACE, childDomPath, childDomPath, EMPTY_ATTRIBUTES);
- hints.pushDomPath(childDomPath);
- }
-
- }
- }
-
- /**
- * closeDomPathIfNecessary will determine whether the next peer Translator shares the active DOM
- * Path of the current Translator. If the next peer Translator has the same DOM Path, no action
- * will be taken (hence condensing the elements into a single XML parent). However, if the DOM
- * Path differs (including the Next Peer Translator has no DOM Path) then the current DOM Path
- * will be closed (a close XML element is generated.
- *
- * @param handler
- * The ContentHandler which is writing the XML result
- * @param hints
- * A Global container for information specific to a single XML document
- * @param currentChildTranslator
- * The last Translator to have completed processing
- * @param nextTranslator
- * The next peer Translator that will become active
- * @param target
- * The EMF Target of the Translation
- * @throws SAXException
- */
- private void closeDomPathIfNecessary(ContentHandler handler, WriterHints hints, Translator currentChildTranslator, Translator nextTranslator, EObject target, List mofChildren) throws SAXException {
-
- if (currentChildTranslator.hasDOMPath() && shouldRenderDomPath(target, currentChildTranslator, mofChildren)) {
- String childDomPath = currentChildTranslator.getDOMPath();
- if (nextTranslator != null) { /*
- * There are more peers after this element, we can peek
- * ahead
- */
- String nextPeerDomPath = nextTranslator.getDOMPath();
- if (nextPeerDomPath == null || !nextPeerDomPath.equals(childDomPath)) {
- handler.endElement(NAMESPACE, childDomPath, childDomPath);
- hints.popDomPath();
- }
-
- } else { /* This was the last child element, we must close the dompath */
- handler.endElement(NAMESPACE, childDomPath, childDomPath);
- hints.popDomPath();
- }
- }
- }
-
- /**
- * Aggregate the Attribute translator children from a given translator. This method will request
- * the AttributesImpl object from the WriterHints object. The WriterHints maintains this
- * reusable collection to limit the requirement for new object creation.
- *
- * @param translator
- * @param target
- * @param hints
- * @return an initialized set of Attributes for the given Translator and EMF Target
- */
- private Attributes getAttributes(Translator translator, EObject target, WriterHints hints) {
-
- AttributesImpl attributes = hints.getAttributeHolder();
- int version = hints.getVersion();
- Object rawValue = null;
- String convertedValue = null;
- String childDomName = null;
- Translator attributeTranslator = null;
- int[] processingHints = TranslatorFilter.createProcessingHints();
-
- while ((attributeTranslator = TranslatorFilter.getNextAttributeTranslator(translator, processingHints[TranslatorFilter.NEXT_START_HINT_INDX], processingHints, target, version)) != null) {
-
- List mofChildren = attributeTranslator.getMOFChildren(target);
- if (mofChildren.size() > 0) {
- for (int j = 0; j < mofChildren.size(); j++) {
-
- childDomName = attributeTranslator.getDOMName(target);
- rawValue = mofChildren.get(j);
- convertedValue = attributeTranslator.convertValueToString(rawValue, target);
- convertedValue = XMLEncoderDecoder.escape(convertedValue);
- attributes.addAttribute(NAMESPACE, childDomName, childDomName, "String", convertedValue); //$NON-NLS-1$
- }
-
- } else {
- childDomName = attributeTranslator.getDOMName(target);
- convertedValue = (String) attributeTranslator.getMOFValue(target);
- if (convertedValue != null)
- attributes.addAttribute(NAMESPACE, childDomName, childDomName, "String", convertedValue); //$NON-NLS-1$
- }
- }
- return attributes;
- }
-
- /**
- * WriterHints is used to "remember" certain pieces of information while the writer is
- * processing. Of particular interest are the version and the state of the DOM Path output.
- * Consecutive elements with consistent (identical) DOM Paths are collapsed under a single XML
- * element.
- *
- * The WriterHints provides global state between recursive invocations of serialize(). It should
- * be not be used to store local data (e.g. data that is only relevant to a single Translator in
- * a given context).
- *
- * The WriterHints also stores an AttributesImpl object that is re-used to store attributes. The
- * getAttributes() method will request the Attributes Holder.
- *
- * @author mdelder
- */
- public final class WriterHints {
- private final TranslatorResource resource;
- private final Stack domStack = new Stack();
- private final AttributesImpl attributesImpl = new AttributesImpl();
-
- public WriterHints(TranslatorResource res) {
- this.resource = res;
- }
-
- /**
- * Push a new domPath onto the stack
- *
- * @param domPath
- * a DOMPath which has been written to the XML stream
- */
- public void pushDomPath(String domPath) {
-
- if (domPath != null && domPath.length() > 0)
- domStack.push(domPath);
- }
-
- /**
- * Pop the current domPath from the Array
- */
- public void popDomPath() {
-
- if (!domStack.isEmpty())
- domStack.pop();
- }
-
- /**
- * Determines if the given DOMPath has already been written to the XML stream
- *
- * @param domPath
- * @return true if the given DOMPath has already been written to the XML stream
- */
- public boolean isDomPathActive(String domPath) {
- boolean result = false;
- if (!domStack.isEmpty()) {
-
- String currentDomPath = (String) domStack.peek();
- if (currentDomPath != null && domPath != null)
- result = currentDomPath.equals(domPath);
- else if (!(currentDomPath == null ^ domPath == null))
- result = true;
- }
-
- return result;
- }
-
- /**
- * @return the version of the EMF Resource
- */
- public int getVersion() {
- return this.resource.getVersionID();
- }
-
- /**
- * Returns an empty AttributesImpl object to store attributes. Within the context of a given
- * WriterHints object (and hence single XML document), the object returned is a singleton.
- * The same AttributesImpl object is cleared and reused for each invocation.
- *
- * @return an empty AttributesImpl object to store attributes
- */
- public AttributesImpl getAttributeHolder() {
- this.attributesImpl.clear();
- return this.attributesImpl;
- }
-
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java
deleted file mode 100644
index bdfd479a7..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/FileNameResourceFactoryRegistry.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.Resource.Factory;
-import org.eclipse.wst.common.internal.emf.utilities.DefaultOverridableResourceFactoryRegistry;
-
-
-public abstract class FileNameResourceFactoryRegistry extends DefaultOverridableResourceFactoryRegistry {
- //We are using two lists instead of a Map because we need to iterate
- //the list of simpleFileNames quite a lot.
- protected List simpleFileNames;
- protected List simpleFileNameFactories;
-
- public FileNameResourceFactoryRegistry() {
- super();
- }
-
- /**
- * Return a Resource.Factory that is registered with the last segment of the URI's file name.
- *
- * @see org.eclipse.emf.ecore.resource.impl.ResourceFactoryRegistryImpl#getFactory(URI)
- */
- protected Object getFileNameFactory(URI uri) {
- if (simpleFileNames != null) {
- String fileName = uri.lastSegment();
- if (fileName != null) {
- String key;
- for (int i = 0; i < simpleFileNames.size(); i++) {
- key = (String) simpleFileNames.get(i);
- if (fileName.equals(key))
- return simpleFileNameFactories.get(i);
- }
- }
- }
- return null;
- }
-
- public Resource.Factory getFactory(URI uri) {
- Object resourceFactory = getFileNameFactory(uri);
- if (resourceFactory == null)
- resourceFactory = super.getFactory(uri);
- return (Resource.Factory) resourceFactory;
- }
-
- /**
- * Register a file name representing the last segment of a URI with the corresponding
- * Resource.Factory.
- */
- public void registerLastFileSegment(String aSimpleFileName, Resource.Factory aFactory) {
- URI uri = URI.createURI(aSimpleFileName);
- String lastSegment = uri.lastSegment();
- int index = getFileNameIndexForAdd(lastSegment);
- setFileName(lastSegment, index);
- setFileNameFactory(aFactory, index);
- }
-
- private int getFileNameIndexForAdd(String aSimpleFileName) {
- if (simpleFileNames != null) {
- int i = simpleFileNames.indexOf(aSimpleFileName);
- if (i > -1)
- return i;
- return simpleFileNames.size();
- }
- return 0;
- }
-
- private void setFileNameFactory(Factory aFactory, int index) {
- if (simpleFileNameFactories == null)
- simpleFileNameFactories = new ArrayList();
- simpleFileNameFactories.add(index, aFactory);
- }
-
- private void setFileName(String aSimpleFileName, int index) {
- if (simpleFileNames == null)
- simpleFileNames = new ArrayList();
- simpleFileNames.add(index, aSimpleFileName);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/GenericTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/GenericTranslator.java
deleted file mode 100644
index eafe09f36..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/GenericTranslator.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Mar 20, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * Specialized translator for objects that contain simple mappings with no specialized behavior.
- */
-public class GenericTranslator extends Translator {
-
- protected Translator[] children;
-
- /**
- * @param domNameAndPath
- * @param eClass
- */
- public GenericTranslator(String domNameAndPath, EClass eClass) {
- super(domNameAndPath, eClass);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- */
- public GenericTranslator(String domNameAndPath, EStructuralFeature aFeature) {
- super(domNameAndPath, aFeature);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param path
- */
- public GenericTranslator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath path) {
- super(domNameAndPath, aFeature, path);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param paths
- */
- public GenericTranslator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath[] paths) {
- super(domNameAndPath, aFeature, paths);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param eClass
- */
- public GenericTranslator(String domNameAndPath, EStructuralFeature aFeature, EClass eClass) {
- super(domNameAndPath, aFeature, eClass);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param style
- */
- public GenericTranslator(String domNameAndPath, EStructuralFeature aFeature, int style) {
- super(domNameAndPath, aFeature, style);
- }
-
- /**
- * @return Translator[]
- */
- public Translator[] getChildren() {
- return children;
- }
-
- /**
- * Sets the children.
- *
- * @param children
- * The children to set
- */
- public void setChildren(Translator[] children) {
- this.children = children;
- }
-
-
- public static Translator appendChildren(GenericTranslator tran, Translator[] child) {
- Translator[] orgChild = tran.getChildren();
- Translator[] newChildren = (Translator[]) concat(orgChild, child);
- tran.setChildren(newChildren);
- return tran;
- }
-
- public static Translator appendChild(GenericTranslator tran, Translator child) {
- Object[] orgChild = tran.getChildren();
- Translator[] newChildren = (Translator[]) concat(orgChild, child);
- tran.setChildren(newChildren);
- return tran;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/IDTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/IDTranslator.java
deleted file mode 100644
index 15755f0e2..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/IDTranslator.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Mar 19, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.xmi.XMIResource;
-
-/**
- * @author schacher
- */
-public class IDTranslator extends Translator {
- public class NoResourceException extends RuntimeException {
-
- public NoResourceException() {
- super();
- }
-
- public NoResourceException(String s) {
- super(s);
- }
- }
-
- static final public EStructuralFeature ID_FEATURE = EcorePackage.eINSTANCE.getEClass_EIDAttribute();
- static final public IDTranslator INSTANCE = new IDTranslator();
-
- public IDTranslator() {
- super("id", ID_FEATURE, DOM_ATTRIBUTE); //$NON-NLS-1$
- }
-
- public void setMOFValue(EObject emfObject, Object value) {
- XMIResource res = (XMIResource) emfObject.eResource();
- if (res == null)
- throw new NoResourceException();
- String id = res.getID(emfObject);
- if (id == null && value == null)
- return;
- if ((id != null && !id.equals(value)) || (value != null && !value.equals(id)))
- res.setID(emfObject, (String) value);
- }
-
- public Object getMOFValue(EObject emfObject) {
- if (emfObject == null)
- throw new NoResourceException();
- XMIResource res = (XMIResource) emfObject.eResource();
- if (res == null)
- throw new NoResourceException();
- return res.getID(emfObject);
- }
-
-
- public boolean featureExists(EObject emfObject) {
- return true;
- }
-
- public boolean isIDMap() {
- return true;
- }
-
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/LinkUpdaterTarget.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/LinkUpdaterTarget.java
deleted file mode 100644
index f5cd1f99b..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/LinkUpdaterTarget.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.util.EcoreUtil;
-import org.w3c.dom.Node;
-
-
-public class LinkUpdaterTarget extends Object {
-
- public static final LinkUpdaterTarget INSTANCE = new LinkUpdaterTarget();
-
- /**
- * Constructor for LinkUpdaterMultiTarget.
- *
- * @param adapter
- */
- private LinkUpdaterTarget() {
- super();
- }
-
-
- public void updateDOM(Translator map, Node node, EObject mofObject) {
- refreshSourceObjects(map, node, mofObject, true);
- }
-
- public void updateMOF(Translator map, Node node, EObject mofObject) {
- refreshSourceObjects(map, node, mofObject, false);
- }
-
- protected void refreshSourceObjects(Translator map, Node node, EObject mofObject, boolean domUpdate) {
- TranslatorPath[] paths = map.getTranslatorPaths();
- for (int i = 0; i < paths.length; i++) {
- TranslatorPath path = paths[i];
- List allSourceObjects = path.findObjects(mofObject);
- for (Iterator iter = allSourceObjects.iterator(); iter.hasNext();) {
- EObject curObject = (EObject) iter.next();
- EMF2DOMAdapter curAdapter = (EMF2DOMAdapter) EcoreUtil.getAdapter(curObject.eAdapters(), EMF2DOMAdapter.class);
- if (curAdapter != null) {
- if (domUpdate)
- curAdapter.updateDOM();
- else
- curAdapter.updateMOF();
- }
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MappedXMIHelper.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MappedXMIHelper.java
deleted file mode 100644
index ac27864eb..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MappedXMIHelper.java
+++ /dev/null
@@ -1,295 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.URIConverter;
-import org.eclipse.emf.ecore.resource.impl.URIConverterImpl;
-import org.eclipse.emf.ecore.xmi.XMLHelper;
-import org.eclipse.emf.ecore.xmi.XMLResource;
-import org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl;
-import org.eclipse.wst.common.internal.emf.utilities.IDUtil;
-
-public class MappedXMIHelper extends XMLHelperImpl {
-
- private static final String WORKSPACE_PROTOCOL = "workspace:/"; //$NON-NLS-1$
- private static final String PLATFORM_RESOURCE_PROTOCOL = "platform:/resource/"; //$NON-NLS-1$
- private static final EStructuralFeature NULL_FEATURE = new UnsupportedFeature();
- protected boolean usingMaps = true;
- protected Map cachedRelativeURIs;
- protected Map packageURIsToPrefixes;
-
- /**
- * Constructor for MappedXMLHelper.
- *
- * @param resource
- */
- public MappedXMIHelper(XMLResource resource, Map prefixesToURIs) {
- super(resource);
- this.prefixesToURIs.putAll(prefixesToURIs);
- pushContext(); //Needed to initialize the context to zero
- Set keys = prefixesToURIs.keySet();
- for (Iterator iter = keys.iterator(); iter.hasNext();) {
- String prefix = (String) iter.next();
- String uri = (String) prefixesToURIs.get(prefix);
- namespaceSupport.declarePrefix(prefix, uri);
- }
-
- }
-
- public URI resolve(URI relative, URI base) {
- URI resolved = null;
- boolean isMapped = false;
- ResourceSet set = getResource().getResourceSet();
- if (set != null) {
- URI localresourceURI = null;
- if (relative.hasFragment())
- localresourceURI = relative.trimFragment();
- else
- localresourceURI = relative;
- isMapped = !(((URIConverterImpl.URIMap) set.getURIConverter().getURIMap()).getURI(localresourceURI).equals(localresourceURI));
- }
- if (!isMapped) {
- if (isUsingContainerRelativePaths() && set != null)
- resolved = set.getURIConverter().normalize(relative);
- } else {
- resolved = relative;
- }
- return resolved == null ? super.resolve(relative, base) : resolved;
- }
-
- /**
- * Method isUsingContainerRelativePaths.
- *
- * @return boolean
- */
- private boolean isUsingContainerRelativePaths() {
- return ((CompatibilityXMIResource) resource).getFormat() == CompatibilityXMIResource.FORMAT_MOF5 || usingMaps;
- }
-
- public void addPrefix(String prefix, String uri) {
- /*
- * problem - the incoming key value pair is ejbbnd->ejbbnd.xmi; however, the map already has
- * a key value pair of ejbbnd->http:///ejbbnd.ecore
- */
- if (uri.endsWith(".ecore")) { //$NON-NLS-1$
- usingMaps = false;
- }
- String existing = (String) prefixesToURIs.get(prefix);
- if (existing == null) {
- prefixesToURIs.put(prefix, uri);
- namespaceSupport.declarePrefix(prefix, uri);
- } else if (!existing.equals(uri)) {
- getCompatibilityResource().addOriginalPackageURI(existing, uri);
- getCompatibilityResource().setFormat(CompatibilityXMIResource.FORMAT_MOF5);
- }
- }
-
- protected CompatibilityXMIResource getCompatibilityResource() {
- return (CompatibilityXMIResource) getResource();
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl#getHREF(EObject)
- */
- public String getHREF(EObject obj) {
- if (!getCompatibilityResource().usesDefaultFormat()) {
- URIConverter conv = getURIConverter();
- if (conv != null && conv instanceof CompatibilityURIConverter) {
- String href = getCompatibliltyHREF(obj, (CompatibilityURIConverter) conv);
- return useWorkspaceProtocolIfNecessary(href);
- }
- }
- return super.getHREF(obj);
- }
-
-
- /**
- * @param href
- * @return
- */
- protected String useWorkspaceProtocolIfNecessary(String href) {
- if (href != null && href.startsWith(PLATFORM_RESOURCE_PROTOCOL))
- return WORKSPACE_PROTOCOL + href.substring(19);
- return href;
- }
-
- private String getCompatibliltyHREF(EObject obj, CompatibilityURIConverter conv) {
- //Implementation copied from super.getHREF(EObject)
- InternalEObject o = (InternalEObject) obj;
-
- URI objectURI = o.eProxyURI();
- if (objectURI == null) {
- Resource otherResource = obj.eResource();
- if (otherResource == null) {
- objectURI = handleDanglingHREF(obj);
- if (objectURI == null) {
- return null;
- }
- } else
- objectURI = otherResource.getURI().appendFragment(otherResource.getURIFragment(obj));
- }
-
- //Modified to dispatch back to URI Converter
- if (!objectURI.isRelative()) {
- objectURI = makeRelative(objectURI, conv);
- }
- return objectURI.toString();
- }
-
- protected URI makeRelative(URI objectURI, CompatibilityURIConverter conv) {
- String fragment = objectURI.fragment();
- objectURI = objectURI.trimFragment();
- URI relative = (URI) getCachedRelativeURIs().get(objectURI);
- if (relative == null) {
- relative = conv.deNormalize(objectURI);
- if (relative.isRelative())
- cachedRelativeURIs.put(objectURI, relative);
- }
- return relative.appendFragment(fragment);
- }
-
- protected URIConverter getURIConverter() {
- ResourceSet set = getResource().getResourceSet();
- if (set != null)
- return set.getURIConverter();
- return null;
- }
-
- protected Map getCachedRelativeURIs() {
- if (cachedRelativeURIs == null)
- cachedRelativeURIs = new HashMap();
- return cachedRelativeURIs;
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl#getID(EObject)
- */
- public String getID(EObject obj) {
- if (getCompatibilityResource().usesDefaultFormat())
- return super.getID(obj);
- return IDUtil.getOrAssignID(obj, resource);
- }
-
- public String[] getNSInfo(EPackage pkg) {
- String prefix = getMappedPrefix(pkg);
- if (prefix == null)
- return new String[]{pkg.getNsPrefix(), pkg.getNsURI()};
- return new String[]{prefix, prefix + ".xmi"}; //$NON-NLS-1$
- }
-
- protected String getMappedPrefix(EPackage pkg) {
- String nsURI = pkg.getNsURI();
- if (usingMaps || !getCompatibilityResource().usesDefaultFormat())
- return (String) packageURIsToPrefixes.get(nsURI);
- return null;
- }
-
- protected String getMappedPrefixOrDefault(EPackage pkg) {
- String prefix = getMappedPrefix(pkg);
- return prefix == null ? pkg.getNsPrefix() : prefix;
- }
-
-
- /**
- * Returns the packageURIsToPrefixes.
- *
- * @return Map
- */
- public Map getPackageURIsToPrefixes() {
- return packageURIsToPrefixes;
- }
-
- /**
- * Sets the packageURIsToPrefixes.
- *
- * @param packageURIsToPrefixes
- * The packageURIsToPrefixes to set
- */
- public void setPackageURIsToPrefixes(Map packageURIsToPrefixes) {
- this.packageURIsToPrefixes = packageURIsToPrefixes;
- }
-
- public String getQName(EClass c) {
- String name = getName(c);
-
- if (xmlMap != null) {
- XMLResource.XMLInfo clsInfo = xmlMap.getInfo(c);
-
- if (clsInfo != null) {
- String targetNamespace = clsInfo.getTargetNamespace();
- return getQName(targetNamespace, name);
- }
- }
-
- EPackage p = c.getEPackage();
- packages.put(p, null);
-
- if (p.getNsPrefix().equals("")) //$NON-NLS-1$
- return name;
-
- //Modified from superclass
- //return p.getNsPrefix() + ":" + name;
- return getMappedPrefixOrDefault(p) + ":" + name; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLHelperImpl#setValue(EObject, EStructuralFeature,
- * Object, int)
- */
- public void setValue(EObject object, EStructuralFeature feature, Object value, int position) {
- if (feature == NULL_FEATURE)
- return;
- if (!feature.isTransient()) {
- if (value == null && feature.getEType().getInstanceClass() != null && feature.getEType().getInstanceClass().isPrimitive())
- //For compatibility with MOF5 where types like Integer might have been set
- //and serialized as "xsi:nil"
- return;
-
- super.setValue(object, feature, value, position);
- }
- }
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.XMLHelper#getFeature(org.eclipse.emf.ecore.EClass,
- * java.lang.String, java.lang.String, boolean)
- */
- public EStructuralFeature getFeature(EClass eClass, String namespaceURI, String name, boolean isElement) {
- if (UnsupportedFeature.isUnsupported(eClass, name))
- return NULL_FEATURE;
- return super.getFeature(eClass, namespaceURI, name, isElement);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.ecore.xmi.XMLHelper#getFeatureKind(org.eclipse.emf.ecore.EStructuralFeature)
- */
- public int getFeatureKind(EStructuralFeature feature) {
- if (feature == NULL_FEATURE)
- return XMLHelper.DATATYPE_SINGLE;
- return super.getFeatureKind(feature);
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MultiObjectTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MultiObjectTranslator.java
deleted file mode 100644
index abfcc8334..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/MultiObjectTranslator.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Mar 31, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author schacher
- */
-public abstract class MultiObjectTranslator extends Translator {
- private static final Translator[] EMPTY_TRANSLATORS = new Translator[]{};
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param style
- */
- public MultiObjectTranslator(String domNameAndPath, EStructuralFeature aFeature) {
- super(domNameAndPath, aFeature);
- }
-
- public abstract Translator getDelegateFor(EObject o);
-
- public abstract Translator getDelegateFor(String domName, String readAheadName);
-
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#createEMFObject(java.lang.String,
- * java.lang.String)
- */
- public EObject createEMFObject(String nodeName, String readAheadName) {
- return getDelegateFor(nodeName, readAheadName).createEMFObject(nodeName, readAheadName);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#getChildren(java.lang.Object)
- */
- public Translator[] getChildren(Object o, int version) {
- if (o == null)
- return EMPTY_TRANSLATORS;
- return getDelegateFor((EObject) o).getChildren(o, version);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#getDOMName(java.lang.Object)
- */
- public String getDOMName(Object value) {
- return getDelegateFor((EObject) value).getDOMName(value);
- }
-
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isManagedByParent()
- */
- public boolean isManagedByParent() {
- return false;
- }
-
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/NamespaceTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/NamespaceTranslator.java
deleted file mode 100644
index b266883e3..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/NamespaceTranslator.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Aug 14, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.internal.emf.utilities.Namespace;
-import org.eclipse.wst.common.internal.emf.utilities.NamespaceAdapter;
-
-
-/**
- * @author schacher
- */
-public class NamespaceTranslator extends Translator {
-
- protected String prefix;
-
- /**
- * @param domNameAndPath
- * @param aFeature
- */
- public NamespaceTranslator(String domName) {
- super(domName, NamespaceAdapter.NOTIFICATION_FEATURE, DOM_ATTRIBUTE);
- initPrefix();
- }
-
- private void initPrefix() {
- String dName = getDOMName(null);
- prefix = dName.substring(DefaultTranslatorFactory.XMLNS.length());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#setMOFValue(org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- public void setMOFValue(EObject emfObject, Object value) {
- NamespaceAdapter.addNamespace(prefix, (String) value, emfObject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isSetMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public boolean isSetMOFValue(EObject emfObject) {
- return getMOFValue(emfObject) != null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#getMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public Object getMOFValue(EObject mofObject) {
- return NamespaceAdapter.getNamespaceURIAtThisLevel(prefix, mofObject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#unSetMOFValue(org.eclipse.emf.ecore.EObject)
- */
- public void unSetMOFValue(EObject emfObject) {
- NamespaceAdapter.removeNamespace(prefix, emfObject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#featureExists(org.eclipse.emf.ecore.EObject)
- */
- public boolean featureExists(EObject emfObject) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isDataType()
- */
- public boolean isDataType() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isMapFor(java.lang.Object, java.lang.Object,
- * java.lang.Object)
- */
- public boolean isMapFor(Object aFeature, Object oldValue, Object newValue) {
- if (aFeature == feature) {
- Namespace namespace = (Namespace) (oldValue == null ? newValue : oldValue);
- if (namespace != null)
- return prefix.equals(namespace.getPrefix());
- }
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ObjectTranslatorFilter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ObjectTranslatorFilter.java
deleted file mode 100644
index 918b9ce85..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ObjectTranslatorFilter.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-/*
- * Created on Sep 21, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-public final class ObjectTranslatorFilter extends TranslatorFilter {
-
- public ObjectTranslatorFilter() {
- super(null, -1);
- }
-
- public ObjectTranslatorFilter(Translator trans, int version) {
- super(trans, version);
- }
-
- public final int scanNextTranslator(Translator[] children, int start) {
- int found = start + 1;
- for (; found < children.length; ++found) {
- if (!children[found].isDOMAttribute())
- break;
- }
- found = (found < children.length) ? found : -1;
- return found;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReadAheadHelper.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReadAheadHelper.java
deleted file mode 100644
index a7d1a23f8..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReadAheadHelper.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 2, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-/**
- * @author schacher
- */
-public class ReadAheadHelper {
-
- protected String parentDOMName;
- protected String[] values;
- protected String childDOMName;
-
- public ReadAheadHelper(String parentDOMName, String[] values, String childDOMName) {
- super();
- this.parentDOMName = parentDOMName;
- this.values = values;
- this.childDOMName = childDOMName;
- }
-
- /**
- * @return
- */
- public String getChildDOMName() {
- return childDOMName;
- }
-
- /**
- * @return
- */
- public String getParentDOMName() {
- return parentDOMName;
- }
-
- /**
- * @return
- */
- public String[] getValues() {
- return values;
- }
-
- /**
- * @param string
- */
- public void setChildDOMName(String string) {
- childDOMName = string;
- }
-
- /**
- * @param string
- */
- public void setParentDOMName(String string) {
- parentDOMName = string;
- }
-
- /**
- * @param strings
- */
- public void setValues(String[] strings) {
- values = strings;
- }
-
-
- public boolean nodeValueIsReadAheadName(String nodeName) {
-
- return (childDOMName != null) ? childDOMName.equals(nodeName) : false;
- }
-
- public boolean nodeNameIsReadAheadName(String nodeName) {
- boolean result = false;
- for (int i = 0; i < values.length; i++) {
- if (nodeName.equals(values[i])) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedResource.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedResource.java
deleted file mode 100644
index fc8ceaf1e..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedResource.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-
-import org.eclipse.emf.ecore.resource.Resource;
-
-public interface ReferencedResource extends Resource, CompatibilityXMIResource {
- //TODO - rename packaged
-
- public static final String DELETED_ERROR_MSG = "This resource has been deleted and can no longer be used."; //$NON-NLS-1$
-
- public static final int RESOURCE_WAS_SAVED = 601;
-
- /**
- * Access this resource for read only. This call increments the use read count of this resource.
- * Clients should call this method before they use the resource. They should call
- * releaseFromRead() after they are done modifying this resource.
- */
- void accessForRead();
-
- /**
- * Access this resource for write only. This call increments the use write count of this
- * resource. Clients should call this method before they modify the resource. They should call
- * releaseFromWrite() after they are done modifying this resource.
- */
- void accessForWrite();
-
- /**
- * Return true if this resource has just been loaded and not yet accessed for read or write.
- */
- boolean isNew();
-
- /**
- * Return true if this resource does not have any write references.
- */
- boolean isReadOnly();
-
- /**
- * Return true if this resource is shared for read or write by more than one accessor.
- */
- boolean isShared();
-
- /**
- * Return true if this resource is shared for write by more than one accessor.
- */
- boolean isSharedForWrite();
-
- /**
- * Release read the access to this resource. This call decrements the use count of this resource
- * and will remove the resource from its resource set if the use count goes to 0. Clients should
- * call this method when they are done accessing the resource and only after they have called
- * accessForRead() to obtain access.
- */
- void releaseFromRead();
-
- /**
- * Release write the access to this resource. This call decrements the write count of this
- * resource and will remove the resource from its resource set if the use count goes to 0.
- * Clients should call this method when they are done accessing the resource and only after they
- * have called accessForWrite() to obtain access.
- */
- void releaseFromWrite();
-
- /**
- * Saves this resource only if the write count is equal to 1.
- */
- void saveIfNecessary() throws Exception;
-
- /**
- * Return true if this resource is dirty and is not shared for write.
- */
- boolean needsToSave();
-
-
-
- /**
- * Set whether we should allow a refresh to take place even when this resource is dirty.
- *
- * @param b
- */
- void setForceRefresh(boolean b);
-
- /**
- * Return whether we should allow a refresh to take place even when this resource is dirty.
- */
- boolean shouldForceRefresh();
-
- boolean wasReverted();
-
- /**
- * Returns the number of open read accesses on this resource
- *
- * @return
- */
- int getReadCount();
-
- /**
- * Returns the number of open write accesses on this resource
- *
- * @return
- */
- int getWriteCount();
-
- /**
- * If the resource is no longer being accessed, then remove it from the resource set.
- */
- void unloadIfNecessary();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIFactoryImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIFactoryImpl.java
deleted file mode 100644
index d891c2cda..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIFactoryImpl.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.emf.common.notify.AdapterFactory;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
-
-public class ReferencedXMIFactoryImpl extends ResourceFactoryImpl {
-
- protected static List globalAdapterFactories;
- protected List localAdapterFactories;
-
- /**
- * ReferencedXMIFactoryImpl constructor comment.
- */
- public ReferencedXMIFactoryImpl() {
- super();
- }
-
- /**
- * This is the method that subclasses can override to actually instantiate a new Resource
- *
- * @param uri
- * @return
- */
- protected Resource doCreateResource(URI uri) {
- return new ReferencedXMIResourceImpl(uri);
- }
-
- /**
- * @see org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl#createResource(URI)
- */
- public final Resource createResource(URI uri) {
- Resource res = doCreateResource(uri);
- adaptNew(res);
- return res;
- }
-
- protected void adaptNew(Resource res) {
- if (globalAdapterFactories != null) {
- for (int i = 0; i < globalAdapterFactories.size(); i++) {
- AdapterFactory factory = (AdapterFactory) globalAdapterFactories.get(i);
- factory.adaptAllNew(res);
- }
- }
- if (localAdapterFactories != null) {
- for (int i = 0; i < localAdapterFactories.size(); i++) {
- AdapterFactory factory = (AdapterFactory) localAdapterFactories.get(i);
- factory.adaptAllNew(res);
- }
- }
- }
-
- /**
- * The local adapter factory is an adapter factory that you use to only adapt the resource
- * specific to the ResourceFactory instance.
- *
- * @param factory
- */
- public void addLocalAdapterFactory(AdapterFactory factory) {
- if (localAdapterFactories == null)
- localAdapterFactories = new ArrayList(3);
- localAdapterFactories.add(factory);
- }
-
- public void removeLocalAdapterFactory(AdapterFactory factory) {
- if (localAdapterFactories != null)
- localAdapterFactories.remove(factory);
- }
-
- /**
- * A global adapter factory will be used to adapt any resource created by any ResourceFactory
- * instance.
- *
- * @param factory
- */
- public static void addGlobalAdapterFactory(AdapterFactory factory) {
- if (globalAdapterFactories == null)
- globalAdapterFactories = new ArrayList(3);
- globalAdapterFactories.add(factory);
- }
-
- public static void removeGlobalAdapterFactory(AdapterFactory factory) {
- if (globalAdapterFactories != null)
- globalAdapterFactories.remove(factory);
- }
-}
-
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIResourceImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIResourceImpl.java
deleted file mode 100644
index cd4208b47..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/ReferencedXMIResourceImpl.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.wst.common.internal.emf.utilities.IDUtil;
-
-public class ReferencedXMIResourceImpl extends CompatibilityXMIResourceImpl implements ReferencedResource {
- //TODO Add toString hook
- private static final String TO_STRING = "ReferencedXMIResource, file = "; //$NON-NLS-1$
- private static final String READ_COUNT_TO_STRING = " R= "; //$NON-NLS-1$
- private static final String WRITE_COUNT_TO_STRING = " W= "; //$NON-NLS-1$
-
- private int readReferenceCount = 1;
- private int editReferenceCount = 0;
- protected boolean isNew = true;
- protected boolean forceRefresh;
-
- /**
- * ReferencableXMIResourceImpl constructor comment.
- */
- public ReferencedXMIResourceImpl() {
- super();
- }
-
- public ReferencedXMIResourceImpl(URI uri) {
- super(uri);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emf.resource.ReferencedResource#getReadCount()
- */
- public int getReadCount() {
- return readReferenceCount;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.common.internal.emf.resource.ReferencedResource#getWriteCount()
- */
- public int getWriteCount() {
- return editReferenceCount;
- }
-
-
-
- /*
- * @see ReferencedResource#accessForRead
- */
- public void accessForRead() {
- checkDeleted();
- if (!isNew())
- readReferenceCount++;
- isNew = false;
- }
-
- /*
- * @see ReferencedResource#accessForWrite
- */
- public void accessForWrite() {
- checkDeleted();
- editReferenceCount++;
- if (isNew)
- releaseFromRead();
- isNew = false;
- if (!isTrackingModification())
- setTrackingModification(true);
- }
-
- /*
- * Check if this resource has been removed and throw an exception if it does not have a
- * ResourceSet.
- */
- protected void checkDeleted() {
- if (getResourceSet() == null)
- throw new RuntimeException(DELETED_ERROR_MSG);
- }
-
- /**
- *
- */
- public void collectContainedObjects(java.util.List collecting, EObject parentObject) {
-
- java.util.Iterator children = parentObject.eContents().iterator();
- while (children.hasNext()) {
- EObject child = (EObject) children.next();
- collecting.add(child);
- collectContainedObjects(collecting, child);
- }
- }
-
- /**
- *
- */
- public void ensureFullIDHydration() {
- List allRefObjects = new ArrayList();
- Iterator rootObjects = getContents().iterator();
- while (rootObjects.hasNext()) {
- EObject child = (EObject) rootObjects.next();
- allRefObjects.add(child);
- collectContainedObjects(allRefObjects, child);
- }
-
- Iterator iter = allRefObjects.iterator();
- while (iter.hasNext())
- IDUtil.assignID((EObject) iter.next(), this);
- }
-
- /**
- * If the resource is no longer being accessed, then remove it from the resource set.
- */
- public void unloadIfNecessary() {
- if ((getTotalReferenceCount() <= 0) || (editReferenceCount <= 0 && isModified()))
- unload();
- }
-
- /**
- * Return the number of write accesses to this resource.
- *
- * @return int The number of references.
- */
- protected int getTotalReferenceCount() {
- return editReferenceCount + readReferenceCount;
- }
-
- /*
- * @see ReferencedResource#isNew
- */
- public boolean isNew() {
- return isNew;
- }
-
- /*
- * @see ReferencedResource#isReadOnly
- */
- public boolean isReadOnly() {
- return editReferenceCount <= 0;
- }
-
- /*
- * @see ReferencedResource#isShared
- */
- public boolean isShared() {
- return getTotalReferenceCount() > 1;
- }
-
- /*
- * @see ReferencedResource#isSharedForWrite
- */
- public boolean isSharedForWrite() {
- return editReferenceCount > 1;
- }
-
- /**
- * @see ReferencedResource#preDelete
- */
- public void preDelete() {
- }
-
- /*
- * @see ReferencedResource#releaseFromRead
- */
- public void releaseFromRead() {
- readReferenceCount--;
- if (readReferenceCount < 0)
- throw new RuntimeException("Read reference count error: " + this.toString()); //$NON-NLS-1$
- unloadIfNecessary();
- }
-
- /*
- * @see ReferencedResource#releaseFromWrite
- */
- public void releaseFromWrite() {
- editReferenceCount--;
- if (editReferenceCount < 0)
- throw new RuntimeException("Write reference count error: " + this.toString()); //$NON-NLS-1$
- unloadIfNecessary();
- }
-
- /*
- * @see ReferencedResource#saveIfNecessary
- */
- public void saveIfNecessary() throws Exception {
- if (!isSharedForWrite()) // caller is the only referencer
- save(Collections.EMPTY_MAP);
- }
-
- public String toString() {
- return TO_STRING + getURI().toString() + READ_COUNT_TO_STRING + new Integer(readReferenceCount) + WRITE_COUNT_TO_STRING + new Integer(editReferenceCount);
- }
-
- /*
- * @see ReferencedResource#needsToSave()
- */
- public boolean needsToSave() {
- return isModified() && !isSharedForWrite();
- }
-
-
- /**
- * @see ReferencedResource#setForceRefresh(boolean)
- */
- public void setForceRefresh(boolean b) {
- forceRefresh = b;
- }
-
- /**
- * @see ReferencedResource#shouldForceRefresh()
- */
- public boolean shouldForceRefresh() {
- return forceRefresh;
- }
-
- protected void basicDoLoad(InputStream arg0, Map arg1) throws IOException {
- boolean isTrackingMods = isTrackingModification();
- try {
- if (isTrackingMods)
- setTrackingModification(false);
- super.basicDoLoad(arg0, arg1);
- } finally {
- if (isTrackingMods)
- setTrackingModification(true);
- }
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doUnload()
- */
- protected void doUnload() {
- if (isTrackingModification() && editReferenceCount < 1) //do not turn off modification if
- // we still have a write count
- setTrackingModification(false);
- super.doUnload();
- setForceRefresh(false);
- setModified(false); //dcb - this is required to ensure that resources without files are
- // marked as not modified.
- if (readReferenceCount == 0 && editReferenceCount == 0)
- resetAsNew();
- }
-
-
- /**
- * The resource has been unloaded, and there are no references. Treat the resource like a new
- * Resource
- */
- private void resetAsNew() {
- readReferenceCount = 1;
- isNew = true;
- }
-
- /**
- * @see Resource#save(Object)
- */
- public void save(Map options) throws IOException {
- super.save(options);
- notifySaved();
- }
-
- protected void notifySaved() {
- if (eNotificationRequired()) {
- Notification notification = new NotificationImpl(RESOURCE_WAS_SAVED, this, this) {
- public Object getNotifier() {
- return ReferencedXMIResourceImpl.this;
- }
-
- public int getFeatureID(Class expectedClass) {
- return RESOURCE_WAS_SAVED;
- }
- };
- eNotify(notification);
- }
- }
-
- /**
- * @see com.ibm.etools.emf.workbench.ReferencedResource#wasReverted()
- */
- public boolean wasReverted() {
- return false;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Renderer.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Renderer.java
deleted file mode 100644
index 6768cd178..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Renderer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Map;
-
-/**
- * Interface that defines the api for rendering an EMF object to XML and vice versa
- */
-public interface Renderer {
-
- public static final String JAXP_SCHEMA_LANGUAGE = "http://java.sun.com/xml/jaxp/properties/schemaLanguage"; //$NON-NLS-1$
-
- public static final String W3C_XML_SCHEMA = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
-
- void setResource(TranslatorResource aResource);
-
- TranslatorResource getResource();
-
- void doLoad(InputStream in, Map options) throws IOException;
-
- void doSave(OutputStream outputStream, Map options) throws IOException;
-
- boolean useStreamsForIO();
-
- void prepareToAddContents();
-
- int getVersionID();
-
- boolean isModified();
-
- void accessForWrite();
-
- void accessForRead();
-
- void releaseFromRead();
-
- void releaseFromWrite();
-
- void preDelete();
-
- void preUnload();
-
- boolean isShared();
-
- boolean isSharedForWrite();
-
- void setBatchMode(boolean isBatch);
-
- boolean isBatchMode();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactory.java
deleted file mode 100644
index 9f294d32a..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactory.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.lang.ref.WeakReference;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-
-public abstract class RendererFactory {
-
- public abstract Renderer createRenderer();
-
- private static RendererFactory defaultRendererFactory;
-
- private static RendererFactoryDefaultHandler defaultHandler;
-
- private boolean validating = true;
-
- /**
- * Interested parties can use the
- */
- public final static Notifier NotificationEngine = Notifier.INSTANCE;
-
- /**
- * @return
- */
- public static RendererFactory getDefaultRendererFactory() {
- if (defaultRendererFactory == null)
- defaultRendererFactory = getDefaultHandler().getDefaultRendererFactory();
- return defaultRendererFactory;
- }
-
- /**
- * @param factory
- */
- public static void setDefaultRendererFactory(RendererFactory factory) {
-
- //System.out.println("\n\n***Setting factory: " + factory);
- NotificationEngine.notifyListeners(factory);
- defaultRendererFactory = factory;
- }
-
- public String toString() {
- return "RendererFactory instance: " + getClass().getName(); //$NON-NLS-1$
- }
-
- public static class Notifier {
-
- private static final Notifier INSTANCE = new Notifier();
-
- private final Collection resourceFactoryListeners = new ArrayList();
-
- private Notifier() {
- }
-
- public void notifyListeners(RendererFactory rendererFactory) {
-
- final int length = resourceFactoryListeners.size();
- //System.out.println("Notifying " + length + " listeners");
-
- if (length > 0) {
- /*
- * Since the renderer factories are singletons, this reference check should always
- * work
- */
- if (rendererFactory != RendererFactory.getDefaultRendererFactory()) {
- WeakReference wref = null;
- Listener listener = null;
- synchronized (resourceFactoryListeners) {
- for (Iterator i = resourceFactoryListeners.iterator(); i.hasNext();) {
- wref = (WeakReference) i.next();
- listener = (Listener) wref.get();
- //System.out.println("Notifying Listener: " + listener);
- if (listener != null)
- listener.updateRendererFactory(rendererFactory);
- else
- i.remove();
- }
- }
- }
- }
- }
-
- public void addListener(Listener l) {
- //System.out.println("Adding listener: " + l);
- synchronized (resourceFactoryListeners) {
- resourceFactoryListeners.add(new WeakReference(l));
- }
- }
-
- public void removeListener(Listener listenerToRemove) {
- final int length = resourceFactoryListeners.size();
- if (length > 0) {
- WeakReference wref = null;
- Listener listener = null;
- synchronized (resourceFactoryListeners) {
- for (Iterator i = resourceFactoryListeners.iterator(); i.hasNext();) {
- wref = (WeakReference) i.next();
- listener = (Listener) wref.get();
- if (listener != null) {
- if (listener == listenerToRemove) {
- i.remove();
- break;
- }
- } else {
- i.remove();
- }
- }
- }
- }
- }
-
- }
-
- public interface Listener {
- void updateRendererFactory(RendererFactory newRendererFactory);
- }
-
- /**
- * @return
- */
- public boolean isValidating() {
- return validating;
- }
-
- /**
- * @param b
- */
- public void setValidating(boolean b) {
- validating = b;
- }
-
- /**
- * @return
- */
- public static RendererFactoryDefaultHandler getDefaultHandler() {
- if (defaultHandler == null)
- defaultHandler = EMF2DOMRendererFactoryDefaultHandler.INSTANCE;
- return defaultHandler;
- }
-
- /**
- * @param handler
- */
- public static void setDefaultHandler(RendererFactoryDefaultHandler handler) {
- defaultHandler = handler;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactoryDefaultHandler.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactoryDefaultHandler.java
deleted file mode 100644
index 575df4fe2..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RendererFactoryDefaultHandler.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Dec 1, 2003
- *
- * To change the template for this generated file go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-/**
- * @author schacher
- *
- * To change the template for this generated type comment go to
- * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
- */
-public interface RendererFactoryDefaultHandler {
-
- RendererFactory getDefaultRendererFactory();
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RootTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RootTranslator.java
deleted file mode 100644
index 18f8d84d6..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/RootTranslator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.resource.Resource;
-
-public class RootTranslator extends Translator {
-
- /**
- * Constructor for RootTranslator.
- *
- * @param domNameAndPath
- * @param eClass
- */
- public RootTranslator(String domNameAndPath, EClass eClass) {
- super(domNameAndPath, eClass);
- }
-
- /**
- * @see com.ibm.etools.emf2xml.impl.Translator#setMOFValue(Notifier, Object, int)
- */
- public void setMOFValue(Notifier owner, Object value, int newIndex) {
- ((Resource) owner).getContents().add(newIndex, value);
- }
-
- /**
- * @see com.ibm.etools.emf2xml.impl.Translator#removeMOFValue(Notifier, Object)
- */
- public void removeMOFValue(Notifier owner, Object value) {
- ((Resource) owner).getContents().remove(value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#setMOFValue(org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- public void setMOFValue(Resource res, Object value) {
- if (res != null && value != null)
- res.getContents().add(value);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#isMultiValued()
- */
- public boolean isMultiValued() {
- return true;
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/SourceLinkTranslator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/SourceLinkTranslator.java
deleted file mode 100644
index d5d697bb7..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/SourceLinkTranslator.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 1, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-/**
- * @author schacher
- */
-public class SourceLinkTranslator extends Translator {
-
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param path
- */
- public SourceLinkTranslator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath path) {
- super(domNameAndPath, aFeature, path);
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param path
- */
- public SourceLinkTranslator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath path, int style) {
- super(domNameAndPath, aFeature, path);
- fStyle |= style;
- }
-
- /**
- * @param domNameAndPath
- * @param aFeature
- * @param style
- */
- public SourceLinkTranslator(String domNameAndPath, EStructuralFeature aFeature, int style) {
- super(domNameAndPath, aFeature, style);
- }
-
- public Object convertStringToValue(String strValue, EObject owner) {
-
- Object value = null;
- if (strValue != null)
- // Find the object with the name that matches matchName
- value = fTranslatorPaths[0].findObject(owner, strValue.trim());
- if ((fStyle & Translator.STRING_RESULT_OK) != 0)
- return ((value != null) ? value : strValue);
- return value;
- }
-
- public String convertValueToString(Object value, EObject owner) {
- TranslatorPath path = fTranslatorPaths[0];
- Object attrValue = path.getLastMap().getMOFValue((EObject) value);
- return path.getLastMap().convertValueToString(attrValue, owner);
- }
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Translator.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Translator.java
deleted file mode 100644
index 685181c39..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/Translator.java
+++ /dev/null
@@ -1,792 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.wst.common.internal.emf.utilities.ExtendedEcoreUtil;
-import org.eclipse.wst.common.internal.emf.utilities.FeatureValueConverter;
-
-
-public class Translator {
-
- public final static int NO_STYLE = 0;
- public final static int DOM_ATTRIBUTE = 1;
- public final static int EMPTY_TAG = 1 << 1;
- public final static int CDATA_CONTENT = 1 << 2;
- /**
- * Style bit that indicates that the end tag should NOT be indented; by default it is.
- */
- public final static int END_TAG_NO_INDENT = 1 << 3;
- /**
- * Style bit that indicates that booleans should NOT be converted as "True" and "False"; default
- * is that they are
- */
- public final static int BOOLEAN_LOWERCASE = 1 << 4;
- /**
- * Style bit that indicates an enum value contains hyphens If this is true, then internally the
- * hyphens are replaced with underscores
- */
- public final static int ENUM_FEATURE_WITH_HYPHENS = 1 << 5;
-
- protected final static int OBJECT_MAP = 1 << 6;
- protected final static int BOOLEAN_FEATURE = 1 << 7;
-
- protected final static int SHARED_REFERENCE = 1 << 8;
-
- /**
- * Indicates that the feature may be significant even if it is empty
- */
- public final static int EMPTY_CONTENT_IS_SIGNIFICANT = 1 << 9;
-
- /**
- * Used to indicate that feature is associated with a comment node
- */
- protected final static int COMMENT_FEATURE = 1 << 10;
-
- /**
- * If the value is null, then an eUnset() will be invoked on the feature
- */
- public final static int UNSET_IF_NULL = 1 << 11;
-
- /**
- * Return the element contents as a String if the feature is unresolveable (Used by the
- * SourceLinkTranslator)
- */
- public final static int STRING_RESULT_OK = 1 << 12;
-
- protected String[] fDOMNames;
- protected String fDOMPath = ""; //$NON-NLS-1$
- protected Map readAheadNames;
- protected int fStyle = NO_STYLE;
- protected EStructuralFeature feature;
- protected TranslatorPath[] fTranslatorPaths;
- protected EClass emfClass;
- protected String fNameSpace = ""; //$NON-NLS-1$
- // added by MDE
- protected String domNameAndPath = null;
-
- /**
- * Indicates if any of the children of this Translator are themselves DependencyTranslators
- */
- protected Boolean isDependencyParent;
- protected EStructuralFeature dependencyFeature;
- protected static EcorePackage ECORE_PACKAGE = EcorePackage.eINSTANCE;
-
- // Use this identifier for the DOMName when the attribute
- // value is to be extracted directly from the text of the node.
- // This is rare, but occurs in the web.xml in the case of a
- // WelcomeFile.
- static final public String TEXT_ATTRIBUTE_VALUE = "$TEXT_ATTRIBUTE_VALUE"; //$NON-NLS-1$
-
- static final public EStructuralFeature CONTAINER_FEATURE = new ContainerFeature();
-
- static final public EStructuralFeature ROOT_FEATURE = new RootFeature();
-
- protected static class ContainerFeature extends EStructuralFeatureImpl {
- protected ContainerFeature() {
- super();
- }
- }
-
- protected static class RootFeature extends EStructuralFeatureImpl {
- protected RootFeature() {
- super();
- }
- }
-
- public Translator findChild(String tagName, Object target, int versionID) {
-
- Translator result = null;
- Translator[] maps = getChildren(target, versionID);
-
- if (maps != null) {
- for (int i = 0; i < maps.length; i++) {
- Translator map = maps[i];
- if (map.isMapFor(tagName)) {
- result = map;
- break;
- }
- }
- }
- if (result == null) {
- VariableTranslatorFactory factory = getVariableTranslatorFactory();
- if (factory != null && factory.accepts(tagName)) {
- result = factory.create(tagName);
- }
- }
- return result;
- }
-
- /**
- * Utility method to string together arrays of children
- */
- public static Object[] concat(Object[] array1, Object[] array2) {
- Object[] result = (Object[]) java.lang.reflect.Array.newInstance(array1.getClass().getComponentType(), array1.length + array2.length);
- System.arraycopy(array1, 0, result, 0, array1.length);
- System.arraycopy(array2, 0, result, array1.length, array2.length);
- return result;
- }
-
- public static Object[] concat(Object[] array1, Object object2) {
- Object[] newArray = new Object[]{object2};
- return concat(array1, newArray);
- }
-
- public static Translator createParentAndTextAttributeTranslator(String domName, EStructuralFeature parentFeature, EStructuralFeature childFeature) {
- GenericTranslator parent = new GenericTranslator(domName, parentFeature, END_TAG_NO_INDENT);
- parent.setChildren(new Translator[]{new Translator(TEXT_ATTRIBUTE_VALUE, childFeature)});
- return parent;
- }
-
- public Translator(String domNameAndPath, EClass eClass) {
- initializeDOMNameAndPath(domNameAndPath);
- setEMFClass(eClass);
- }
-
- public Translator(String domNameAndPath, EStructuralFeature aFeature) {
- initializeDOMNameAndPath(domNameAndPath);
- setFeature(aFeature);
- }
-
- public Translator(String domNameAndPath, EStructuralFeature aFeature, EClass eClass) {
- this(domNameAndPath, aFeature);
- setEMFClass(eClass);
- }
-
- public Translator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath path) {
- this(domNameAndPath, aFeature, new TranslatorPath[]{path});
- }
-
- public Translator(String domNameAndPath, EStructuralFeature aFeature, TranslatorPath[] paths) {
- initializeDOMNameAndPath(domNameAndPath);
- fTranslatorPaths = paths;
- setFeature(aFeature);
- }
-
- public Translator(String domNameAndPath, EStructuralFeature aFeature, int style) {
- initializeDOMNameAndPath(domNameAndPath);
- fStyle = style;
- setFeature(aFeature);
- }
-
- public static EcorePackage getEcorePackage() {
- return EcorePackage.eINSTANCE;
- }
-
- public String getDOMName(Object value) {
- return fDOMNames[0];
- }
-
- public String[] getDOMNames() {
- return fDOMNames;
- }
-
- public String getDOMPath() {
- return fDOMPath;
- }
-
- public boolean hasDOMPath() {
- return fDOMPath != null && fDOMPath.length() != 0;
- }
-
- public EStructuralFeature getFeature() {
- return feature;
- }
-
- /**
- * Parse the DOM names and path out of <domNameAndPath>and set the appropriate fields.
- */
- protected void initializeDOMNameAndPath(String domNameAndPathArg) {
- if (domNameAndPathArg == null)
- return;
- int inx = domNameAndPathArg.lastIndexOf('/');
- if (inx != -1) {
- fDOMNames = parseDOMNames(domNameAndPathArg.substring(inx + 1));
- fDOMPath = domNameAndPathArg.substring(0, inx);
- } else {
- fDOMNames = parseDOMNames(domNameAndPathArg);
- fDOMPath = ""; //$NON-NLS-1$
- }
- // added by MDE
- this.domNameAndPath = domNameAndPathArg;
-
- }
-
- /**
- * Indicates whether the node should be written as an empty tag; eg, <distributable/>
- */
- public boolean isCDATAContent() {
- return (fStyle & CDATA_CONTENT) != 0;
- }
-
- /**
- * Indicates whether the DOMName represents a sub element name or an attribute name
- *
- * @return boolean True if the DOMName is an attribute name.
- */
- public boolean isDOMAttribute() {
- return (fStyle & DOM_ATTRIBUTE) != 0;
- }
-
- /**
- * Indicates whether the node should be written as an empty tag; eg, <distributable/>
- */
- public boolean isEmptyTag() {
- return (fStyle & EMPTY_TAG) != 0;
- }
-
- public boolean isBooleanUppercase() {
- return (fStyle & BOOLEAN_FEATURE) != 0 && (fStyle & BOOLEAN_LOWERCASE) == 0;
- }
-
- public boolean isBooleanFeature() {
- return (fStyle & BOOLEAN_FEATURE) != 0;
- }
-
- public boolean shouldIndentEndTag() {
- return (fStyle & END_TAG_NO_INDENT) == 0;
- }
-
- public boolean isEmptyContentSignificant() {
- return ((fStyle & EMPTY_TAG) != 0) || ((fStyle & EMPTY_CONTENT_IS_SIGNIFICANT) != 0);
- }
-
- /**
- * Returns true if this map is to another MOF object (not a primitive)
- */
- public boolean isObjectMap() {
- return (fStyle & OBJECT_MAP) != 0;
- }
-
- /**
- * Returns true if this map is for a shared reference
- */
- public boolean isShared() {
- return (fStyle & SHARED_REFERENCE) != 0;
- }
-
- public boolean isEnumWithHyphens() {
- return (fStyle & ENUM_FEATURE_WITH_HYPHENS) != 0;
- }
-
- /**
- * Indicates whether the map represents a case where the text of the DOMNode represents the
- * objects one and only attribute value. An example of this case is a <welcome-file>file.txt
- * </welcome-file>.
- */
- public boolean isDOMTextValue() {
- return fDOMNames[0] == TEXT_ATTRIBUTE_VALUE;
- }
-
- /**
- * Indicates whether the id is the mof attribute that should be set.
- */
- public boolean isIDMap() {
- return false;
- }
-
- /**
- * Indicates whether the id is the mof attribute that should be set.
- */
- public boolean isLinkMap() {
- return fTranslatorPaths != null;
- }
-
- public boolean isTargetLinkMap() {
- return isLinkMap() && !isObjectMap();
- }
-
- /**
- * Return true if this map is the one representing a node with the name <domName>. By default
- * this method simply compares the DOM name of the map against the <domName>parameter
- *
- * @return boolean
- * @param domName
- * java.lang.String
- */
- public boolean isMapFor(String domName) {
- if (domName.equals(getDOMPath()))
- return true;
- for (int i = 0; i < fDOMNames.length; i++) {
- if (domName.equals(fDOMNames[i]))
- return true;
- }
- return false;
- }
-
- public boolean isMapFor(Object aFeature, Object oldValue, Object newValue) {
- return feature == aFeature;
- }
-
- /**
- * Indicates whether feature being mapped is a collection.
- *
- * @return boolean True if the feature is multi valued.
- */
- public boolean isMultiValued() {
- if (feature != null)
- return feature.isMany();
- return false;
- }
-
- /**
- * Parses comma separated names from <domNamesString>. Returns an array containing the names.
- *
- * @return java.lang.String[]
- * @param domNamesString
- * java.lang.String
- */
- protected String[] parseDOMNames(String domNamesString) {
- int startInx = 0;
- int inx = domNamesString.indexOf(',');
- ArrayList results = new ArrayList(1);
- while (inx != -1) {
- results.add(domNamesString.substring(startInx, inx));
- startInx = inx + 1;
- inx = domNamesString.indexOf(',', startInx);
- }
- if (startInx == 0)
- results.add(domNamesString);
- else
- results.add(domNamesString.substring(startInx));
- return (String[]) results.toArray(new String[results.size()]);
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer();
- String cn = getClass().getName();
- int i = cn.lastIndexOf('.');
- cn = cn.substring(++i, cn.length());
- sb.append(cn);
- sb.append('(');
- sb.append(fDOMNames[0]);
- for (int j = 1; j < fDOMNames.length; j++) {
- sb.append('|');
- sb.append(fDOMNames[j]);
- }
- sb.append(',');
- sb.append(hashCode());
- sb.append(')');
- return sb.toString();
- }
-
- /**
- * Gets the TranslatorPath.
- *
- * @return Returns a TranslatorPath
- */
- public TranslatorPath[] getTranslatorPaths() {
- return fTranslatorPaths;
- }
-
- /*
- * @see Object#equals(Object)
- */
- public boolean equals(Object object) {
- if (!(object instanceof Translator))
- return false;
- Translator mapInfo = (Translator) object;
- return fDOMNames.equals(mapInfo.getDOMNames()) && (feature == null && mapInfo.getFeature() == null || feature.equals(mapInfo.getFeature()));
- }
-
- /**
- * Returns the isManagedByParent.
- *
- * @return boolean
- */
- public boolean isManagedByParent() {
- return getChildren(null, -1) == null;
- }
-
- /*
- * In the 99% case there is only one node name to be concerned with, but subclasses can override
- * for the cases where multiple dom names map to one feature
- */
- public EObject createEMFObject(String nodeName, String readAheadName) {
- if (emfClass == null) {
- if (feature == null)
- return null;
- if (isObjectMap())
- return createEMFObject(feature);
- }
- return createEMFObject(emfClass);
- }
-
- public static EObject createEMFObject(EStructuralFeature aFeature) {
- if (aFeature == null)
- return null;
-
- return createEMFObject(((EReference) aFeature).getEReferenceType());
- }
-
- public static EObject createEMFObject(EClass anEClass) {
- if (anEClass == null)
- return null;
- return anEClass.getEPackage().getEFactoryInstance().create(anEClass);
- }
-
- public void setTextValueIfNecessary(String textValue, Notifier owner, int versionId) {
- Translator textTranslator = this.findChild(Translator.TEXT_ATTRIBUTE_VALUE, owner, versionId);
- if (textTranslator != null) {
- Object objectValue = textTranslator.convertStringToValue(textValue, (EObject) owner);
- textTranslator.setMOFValue(owner, objectValue);
- }
- }
-
- /**
- * Check to see if feature is valid on a particular mofObject.
- *
- * @return boolean Return true if the feature specified exists on the MOF object.
- * @param emfObject
- * org.eclipse.emf.ecore.EObject
- */
- public boolean featureExists(EObject emfObject) {
- if (feature == null)
- return false;
-
- return emfObject.eClass().getEStructuralFeature(feature.getName()) != null;
- }
-
- /**
- * Translators which do not have a feature should override this method with custom behavior.
- */
- public String extractStringValue(EObject emfObject) {
- if (isEmptyTag() && feature == null)
- return ""; //Fake it out with a value //$NON-NLS-1$
- return null;
- }
-
- public Object convertStringToValue(String nodeName, String readAheadName, String value, Notifier owner) {
- Object result = null;
- try {
-
- if (!this.isManagedByParent()) {
- result = createEMFObject(nodeName, readAheadName);
- } else {
- result = convertStringToValue(value, (EObject) owner);
- }
-
- } catch (ClassCastException cce) {
-
- }
- return result;
- }
-
- /**
- * Converts a string value to the appropriate type.
- *
- * @return java.lang.Object The converted value
- * @param strValue
- * java.lang.String The string to convert.
- */
- public Object convertStringToValue(String strValue, EObject owner) {
- if (feature == null)
- return strValue;
- if (strValue != null) {
- if (isEnumWithHyphens())
- strValue = strValue.replace('-', '_');
- if (!isCDATAContent()) {
- strValue = strValue.trim();
- }
- }
- Object value = FeatureValueConverter.DEFAULT.convertValue(strValue, feature);
- if (value == null) {
- if (isEmptyTag() && !isDOMAttribute() && !isDOMTextValue() && isBooleanFeature())
- return Boolean.TRUE;
- EObject convertToType = feature.getEType();
- if (convertToType == null)
- value = strValue;
- else if (convertToType.equals(getEcorePackage().getEString())) {
- value = ""; //$NON-NLS-1$
- }
- }
- return value;
- }
-
- /**
- * Converts a value of a specified type to a string value. Subclasses may override for special
- * cases where special conversion needs to occur based on the feature and or object type.
- *
- * @return String The converted value
- * @param value
- * java.lang.Object The object to convert.
- */
- public String convertValueToString(Object value, EObject owner) {
- if (isEmptyTag() || value == null)
- return null;
- else if (isEnumWithHyphens())
- return value.toString().replace('_', '-');
- else if (isBooleanUppercase())
- return ((Boolean) value).booleanValue() ? "True" : "False"; //$NON-NLS-1$ //$NON-NLS-2$
-
- return value.toString();
- }
-
- public Translator[] getVariableChildren(Notifier target, int version) {
- Translator[] results = null;
- VariableTranslatorFactory factory = getVariableTranslatorFactory();
- if (factory != null) {
- List variableTranslators = factory.create(target);
- if (variableTranslators != null && variableTranslators.size() > 0) {
- Object[] vtoa = variableTranslators.toArray();
-
- results = new Translator[vtoa.length];
- for (int i = 0; i < results.length; i++)
- results[i] = (Translator) vtoa[i];
- }
-
- }
- if (results == null)
- results = new Translator[0];
- return results;
- }
-
- /**
- * Returns null by default; subclasses should override to return specific children
- */
- public Translator[] getChildren(Object target, int versionID) {
- return getChildren();
- }
-
- protected Translator[] getChildren() {
- return null;
- }
-
- /**
- * Return the list of MOF children that currently exist for the values of an attribute.
- */
- public List getMOFChildren(EObject mofObject) {
- if (feature == null)
- return Collections.EMPTY_LIST;
- Object value = getMOFValue(mofObject);
- List result = Collections.EMPTY_LIST;
- if (isMultiValued())
- result = (List) value;
- else if (value != null)
- result = Collections.singletonList(value);
- return result;
- }
-
- public Object getMOFValue(EObject mofObject) {
- if (feature == null)
- return null;
- return mofObject.eGet(feature);
- }
-
- /**
- * Sets a value of a feature in a mof object.
- */
- public void setMOFValue(Notifier owner, Object value, int newIndex) {
- if (feature != null) {
- if ((fStyle & UNSET_IF_NULL) != 0 && value == null)
- ExtendedEcoreUtil.eUnsetOrRemove((EObject) owner, feature, value);
- else
- ExtendedEcoreUtil.eSetOrAdd((EObject) owner, feature, value, newIndex);
- }
- }
-
- public void setMOFValue(Notifier owner, Object value) {
- if (owner instanceof EObject) {
- setMOFValue((EObject) owner, value);
- } else if (owner instanceof Resource) {
- setMOFValue((Resource) owner, value);
- }
- }
-
- public void setMOFValue(EObject emfObject, Object value) {
- // if (feature != null)
- // emfObject.eSet(feature, value);
- setMOFValue(emfObject, value, -1);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.impl.Translator#setMOFValue(org.eclipse.emf.ecore.EObject,
- * java.lang.Object)
- */
- public void setMOFValue(Resource res, Object value) {
- if (res != null && value != null)
- res.getContents().add(value);
- }
-
- public void removeMOFValue(Notifier owner, Object value) {
- if (feature != null)
- ExtendedEcoreUtil.eUnsetOrRemove((EObject) owner, feature, value);
- }
-
- public boolean isSetMOFValue(EObject emfObject) {
- boolean isSet = feature != null && emfObject.eIsSet(feature);
- if (isEmptyTag())
- return isSet && ((Boolean) emfObject.eGet(feature)).booleanValue();
- return isSet;
- }
-
- public void unSetMOFValue(EObject emfObject) {
- if (feature != null)
- emfObject.eUnset(feature);
- }
-
- public void clearList(EObject mofObject) {
- if (feature != null)
- ((List) mofObject.eGet(feature)).clear();
- }
-
- protected void setFeature(EStructuralFeature aFeature) {
- this.feature = aFeature;
- if (feature == null)
- return;
- //This way an instance check happens only once
- if (aFeature instanceof EReference) {
- fStyle |= OBJECT_MAP;
- if (!((EReference) aFeature).isContainment())
- fStyle |= SHARED_REFERENCE;
- }
-
- if (getEcorePackage().getEBoolean() == feature.getEType())
- fStyle |= BOOLEAN_FEATURE;
- }
-
- protected void setEMFClass(EClass anEClass) {
- this.emfClass = anEClass;
- if (anEClass != null)
- fStyle |= OBJECT_MAP;
-
- }
-
- public boolean hasReadAheadNames() {
- return readAheadNames != null && !readAheadNames.isEmpty();
- }
-
- /**
- * Return the read ahead names, if they are defined, for a given parent node name. This is used
- * when creation of a specific EMF object is dependent on the value of a child node.
- */
- public ReadAheadHelper getReadAheadHelper(String parentName) {
- if (readAheadNames == null)
- return null;
- return (ReadAheadHelper) readAheadNames.get(parentName);
- }
-
- public void addReadAheadHelper(ReadAheadHelper helper) {
- if (readAheadNames == null)
- readAheadNames = new HashMap(3);
- readAheadNames.put(helper.getParentDOMName(), helper);
- }
-
- public boolean isDependencyChild() {
- return false;
- }
-
- /**
- * @return
- */
- public boolean isDependencyParent() {
- if (isDependencyParent == null) {
- isDependencyParent = Boolean.FALSE;
- Translator[] theChildren = getChildren(null, -1);
- if (theChildren != null) {
- for (int i = 0; i < theChildren.length; i++) {
- //For now we assume one
- if (theChildren[i].isDependencyChild()) {
- isDependencyParent = Boolean.TRUE;
- dependencyFeature = theChildren[i].getDependencyFeature();
- }
- }
- }
- }
- return isDependencyParent.booleanValue();
- }
-
- /**
- * @return
- */
- public EStructuralFeature getDependencyFeature() {
- return dependencyFeature;
- }
-
- public EObject basicGetDependencyObject(EObject parent) {
- return (EObject) parent.eGet(dependencyFeature);
- }
-
- /**
- * Use when the DOM path is not null, and there are no children. Default is false, but
- * subclasses may wish to override
- */
- public boolean shouldRenderEmptyDOMPath(EObject eObject) {
- return isEmptyContentSignificant();
- }
-
- /**
- * Use when the translator tolerates parent nodes that relate to the DOM path, and no children;
- * default is do nothing
- */
- public void setMOFValueFromEmptyDOMPath(EObject eObject) {
-
- }
-
- /**
- * Namespace for the attributes
- *
- * @return
- */
- public String getNameSpace() {
- return fNameSpace;
- }
-
- /**
- * Set the namespace for the dom attribute
- *
- * @param string
- */
- public void setNameSpace(String string) {
- fNameSpace = string;
- }
-
- public VariableTranslatorFactory getVariableTranslatorFactory() {
- if (isObjectMap())
- return DefaultTranslatorFactory.INSTANCE;
- return null;
- }
-
- public boolean isEnumFeature() {
- return feature != null && ECORE_PACKAGE.getEEnum().isInstance(feature.getEType());
- }
-
- public boolean isUnsettable() {
- return feature != null && feature.isUnsettable();
- }
-
- public boolean isDataType() {
- return feature != null && feature.getEType() instanceof EDataType;
- }
-
- /**
- * @return
- */
- public boolean isComment() {
- return (fStyle & COMMENT_FEATURE) != 0;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorFilter.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorFilter.java
deleted file mode 100644
index b12067d1b..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorFilter.java
+++ /dev/null
@@ -1,220 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-/*
- * Created on Sep 21, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EObject;
-
-
-/*
- * Translator filters can be used to differentiate between Object and Attribute Translators without
- * breaking them out into seperate data structures. The Filter will rely on the underlying data
- * structure used to store the children of the given Translator.
- *
- * getNextChild() will return null when no other translators of the given genre are available.
- *
- * The processing hints which are created and then passed to getNext*Translator() store information
- * that needs to be persisted between calls. The createProcessingHints() will create a properly
- * initialized array. The constants NEXT_START_HINT_INDX and MODE_HINT_INDX provide pointers into
- * the array for the NEXT_START position and the proper mode to operate in
- * (STANDARD_TRANSLATORS_MODE or
- *
- */
-public abstract class TranslatorFilter {
-
- protected final Translator translator;
- protected final int version;
-
- public static final int NEXT_START_HINT_INDX = 0;
- public static final int MODE_HINT_INDX = 1;
-
- public static final int STANDARD_TRANSLATORS_MODE = 0;
- public static final int VARIABLE_TRANSLATORS_MODE = 1;
-
- /*
- * These TranslatorFilters are used in a stateless mode. Only their scanNextTranslator() methods
- * will be invoked
- */
- private static final TranslatorFilter objectTranslatorFilter = new ObjectTranslatorFilter(null, -1);
- private static final TranslatorFilter attributeTranslatorFilter = new AttributeTranslatorFilter(null, -1);
-
-
- protected int mode = STANDARD_TRANSLATORS_MODE;
- protected int index = -1;
-
- protected Translator cachedPeekAheadTranslator = null;
-
- public TranslatorFilter(Translator trans, int version) {
- this.translator = trans;
- this.version = version;
- }
-
- /**
- * Calling peek twice will advance the current child
- */
- public Translator peekNextChild(EObject target) {
- cachedPeekAheadTranslator = getNextChild(target);
- return cachedPeekAheadTranslator;
- }
-
- /**
- * getNextChild() will return null when no other translators of the given genre are available.
- */
- public Translator getNextChild(EObject target) {
-
- Translator result = null;
- if (cachedPeekAheadTranslator != null) {
- result = cachedPeekAheadTranslator;
- cachedPeekAheadTranslator = null;
- return result;
- }
-
- int found = 0;
- Translator children[] = null;
- switch (mode) {
- case STANDARD_TRANSLATORS_MODE :
- children = this.translator.getChildren(target, this.version);
-
- /* Look for the next Attribute Translator */
- found = scanNextTranslator(children, this.index);
-
- if (found >= 0) {
- /*
- * If found, (1) update the result, (2) update the index so we can skip ahead on
- * the next invocation (3) escape the VARIABLE_TRANSLATORS processing
- */
- result = children[found];
- this.index = found;
- break;
- }
- /*
- * Reset the index. DO NOT BREAK. Allow entry into VARIABLE_TRANSLATORS case
- */
- this.index = -1;
- /*
- * update the mode to VARIABLE_TRANSLATORS so we can skip to it directly next time
- */
- this.mode = VARIABLE_TRANSLATORS_MODE;
- case VARIABLE_TRANSLATORS_MODE :
- children = this.translator.getVariableChildren(target, this.version);
- found = scanNextTranslator(children, this.index);
- if (found >= 0) {
- /*
- * If found, (1) update the result, (2) update the index so we can skip ahead on
- * the next invocation
- */
- result = children[found];
- this.index = found;
- }
-
- }
-
- return result;
- }
-
- public static final int[] createProcessingHints() {
- return new int[]{-1, STANDARD_TRANSLATORS_MODE};
- }
-
- public static final Translator getNextAttributeTranslator(Translator translator, int startHint, int[] nextHint, EObject target, int version) {
-
- return TranslatorFilter.getNextChild(translator, startHint, nextHint, target, version, attributeTranslatorFilter);
- }
-
- public static final Translator getNextObjectTranslator(Translator translator, int startHint, int[] nextHint, EObject target, int version) {
-
- return TranslatorFilter.getNextChild(translator, startHint, nextHint, target, version, objectTranslatorFilter);
- }
-
- /**
- * getNextChild() takes hints on where to begin in the children array of the given Translator.
- * When it finds the translator, it will update the hints array with the start hint for the next
- * invocation(hints[0]) and when necessary it will use update the mode (hints[1]) to either
- * STANDARD_TRANSLATORS or VARIABLE_TRANSLATORS.
- *
- * @param translator
- * @param startHint
- * @param hints
- * a two-element array: hints[0] will be updated with the next startHint and hints[1]
- * will be used to store the mode.
- * @param target
- * @param version
- * @param translatorFilter
- * @return
- */
- public static final Translator getNextChild(Translator translator, int startHint, int[] hints, EObject target, int version, TranslatorFilter translatorFilter) {
-
- Translator result = null;
-
- int index = startHint;
- Translator children[] = null;
-
- switch (hints[MODE_HINT_INDX]) {
- case STANDARD_TRANSLATORS_MODE :
- children = translator.getChildren(target, version);
- if (children != null && startHint < children.length) {
-
- /* Look for the next Attribute Translator */
- index = translatorFilter.scanNextTranslator(children, index);
-
- if (index >= 0) {
- /*
- * If found, (1) update the result, (2) update the index so we can skip
- * ahead on the next invocation (3) escape the VARIABLE_TRANSLATORS
- * processing
- */
- result = children[index];
- break;
- }
- /*
- * DO NOT BREAK we will default to VARIABLE TRANSLATORS MODE so we must reset
- * the startHint appropriately
- */
- startHint = -1;
- }
-
- case VARIABLE_TRANSLATORS_MODE :
- hints[MODE_HINT_INDX] = VARIABLE_TRANSLATORS_MODE;
- /*
- * Reset the index.
- */
- index = startHint;
- children = translator.getVariableChildren(target, version);
- if (children != null && children.length > 0 && startHint < children.length) {
- index = translatorFilter.scanNextTranslator(children, index);
- result = (index >= 0) ? children[index] : null;
- }
- }
-
- hints[NEXT_START_HINT_INDX] = (result == null && children != null) ? children.length : index;
-
- return result;
- }
-
-
- public abstract int scanNextTranslator(Translator[] children, int start);
-
- /**
- * @return
- */
- public int getIndex() {
- return index;
- }
-
- /**
- * @return
- */
- public int getMode() {
- return mode;
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorPath.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorPath.java
deleted file mode 100644
index a2d843e17..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorPath.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-
-
-public class TranslatorPath {
- protected Translator[] mapInfoPath;
-
- /**
- * Construct with an array of Translator that specifies the path to follow from an object to
- * another object
- */
- public TranslatorPath(Translator[] path) {
- mapInfoPath = path;
- }
-
- public List findObjects(EObject startObject) {
- Object cur = startObject;
- for (int i = 0; i < mapInfoPath.length; i++) {
- Translator curMap = mapInfoPath[i];
- if (cur instanceof EObject) {
- EStructuralFeature curAttr = curMap.getFeature();
- if (curAttr == Translator.CONTAINER_FEATURE) {
- curAttr = ((EObject) cur).eContainmentFeature();
- cur = ((EObject) cur).eContainer();
- } else if (curAttr == Translator.ROOT_FEATURE) {
- cur = ((TranslatorResource) startObject.eResource()).getRootObject();
- } else {
- cur = ((EObject) cur).eGet(curAttr);
- }
- if (curMap.isMultiValued()) {
- return (List) cur;
- }
- }
- }
- return null;
- }
-
- public Object findObject(EObject startObject, Object matchValue) {
- List objects = findObjects(startObject);
- if (objects == null)
- return null;
- return findObject(objects, getLastMap(), matchValue);
- }
-
- private Object findObject(List objectList, Translator map, Object matchValue) {
- for (Iterator iter = objectList.iterator(); iter.hasNext();) {
- EObject mofObject = (EObject) iter.next();
- Object curMatchValue = mofObject.eGet(map.getFeature());
- if (matchValue.equals(curMatchValue))
- return mofObject;
- }
- return null;
- }
-
- public Translator getLastMap() {
- return mapInfoPath[mapInfoPath.length - 1];
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer sb = new StringBuffer();
- String cn = getClass().getName();
- int i = cn.lastIndexOf('.');
- cn = cn.substring(++i, cn.length());
- sb.append(cn);
- sb.append('(');
- sb.append(mapInfoPath[0]);
- for (int j = 1; j < mapInfoPath.length; j++) {
- sb.append('\n');
- sb.append(mapInfoPath[j]);
- }
- sb.append(')');
- return sb.toString();
- }
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResource.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResource.java
deleted file mode 100644
index 32c9c47fd..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResource.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.impl.EStructuralFeatureImpl;
-import org.xml.sax.EntityResolver;
-
-public interface TranslatorResource extends ReferencedResource {
- /*
- * must make a subclass because the constructor for EStructuralFeature is protected
- */
- static class DocTypeFeature extends EStructuralFeatureImpl {
- protected DocTypeFeature() {
- super();
- }
- }
-
-
- EStructuralFeature DOC_TYPE_FEATURE = new DocTypeFeature();
-
- /**
- * The public id of the XML document, if specified.
- */
- String getPublicId();
-
- /**
- * Return the first element in the EList.
- */
- EObject getRootObject();
-
- /**
- * The system id of the XML document, if specified.
- */
- String getSystemId();
-
- /**
- * Sets the public id and system id of the XML document.
- */
- void setDoctypeValues(String publicId, String systemId);
-
- /**
- * Sets the default public/system ids if necessary
- */
- void setDefaults();
-
- /**
- * Returns the name that will be in the document type header of the serialized xml file
- */
- String getDoctype();
-
- /**
- * Returns the XML version of this document
- */
- String getXMLVersion();
-
- Translator getRootTranslator();
-
- /**
- * Entity resolver that can be used when using standard parsers to read the resource
- */
- EntityResolver getEntityResolver();
-
- boolean usesDTD();
-
- public int getVersionID();
-
- void setVersionID(int i);
-
- Renderer getRenderer();
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceFactory.java
deleted file mode 100644
index 20a450b36..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-
-public abstract class TranslatorResourceFactory extends ReferencedXMIFactoryImpl implements RendererFactory.Listener {
-
- protected RendererFactory rendererFactory;
- private boolean listeningForUpdates = false;
-
- /**
- * Constructor for TranslatorResourceFactory.
- */
- public TranslatorResourceFactory(RendererFactory aRendererFactory, boolean listeningForUpdates) {
- super();
- rendererFactory = aRendererFactory;
- setListeningForUpdates(listeningForUpdates);
- }
-
- /**
- * Constructor for TranslatorResourceFactory.
- */
- public TranslatorResourceFactory(RendererFactory aRendererFactory) {
- this(aRendererFactory, true);
- }
-
- public void setListeningForUpdates(boolean shouldBeListeningForUpdates) {
-
- if (this.listeningForUpdates ^ shouldBeListeningForUpdates) {
- if (!shouldBeListeningForUpdates)
- RendererFactory.NotificationEngine.removeListener(this);
- else
- RendererFactory.NotificationEngine.addListener(this);
-
- this.listeningForUpdates = shouldBeListeningForUpdates;
- }
- }
-
- public boolean isListeningForUpdates() {
- return this.listeningForUpdates;
- }
-
- public Resource doCreateResource(URI uri) {
- Renderer aRenderer = rendererFactory.createRenderer();
- return createResource(uri, aRenderer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.RendererFactory.Listener#updateRendererFactory(com.ibm.etools.emf2xml.RendererFactory)
- */
- public void updateRendererFactory(RendererFactory newRendererFactory) {
- //System.out.println("Updating renderer factory");
- rendererFactory = newRendererFactory;
- }
-
- protected abstract TranslatorResource createResource(URI uri, Renderer aRenderer);
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceImpl.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceImpl.java
deleted file mode 100644
index c65e5a974..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/TranslatorResourceImpl.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/***************************************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others. All rights reserved. This program and the
- * accompanying materials are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: IBM Corporation - initial API and implementation
- **************************************************************************************************/
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Map;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.impl.NotificationImpl;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.InternalEObject;
-import org.eclipse.emf.ecore.impl.ENotificationImpl;
-import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
-import org.eclipse.wst.common.internal.emf.utilities.StringUtil;
-import org.xml.sax.EntityResolver;
-
-public abstract class TranslatorResourceImpl extends ReferencedXMIResourceImpl implements TranslatorResource {
- static final public EStructuralFeature ID_FEATURE = EcorePackage.eINSTANCE.getEClass_EIDAttribute();
- protected static final String DEFAULT_ENCODING = "UTF-8"; //$NON-NLS-1$
- protected static final String DEFAULT_VERSION = "1.0"; //$NON-NLS-1$
- protected Renderer renderer;
- /**
- * The public Id to use at the head of the document.
- */
- protected String publicId;
- /**
- * The system Id to use at the head of the document.
- */
- protected String systemId;
- protected String xmlVersion;
- // Default the resources to J2EE 1.4
- protected int versionID;
-
- /**
- * @deprecated since 4/29/2003 - used for compatibility Subclasses should
- * be using the Renderers and translator framework
- */
- public TranslatorResourceImpl() {
- super();
- }
-
- /**
- * @deprecated since 4/29/2003 - used for compatibility Subclasses should
- * be using the Renderers and translator framework
- */
- public TranslatorResourceImpl(URI uri) {
- super(uri);
- }
-
- public TranslatorResourceImpl(URI uri, Renderer aRenderer) {
- super(uri);
- setRenderer(aRenderer);
- versionID = getDefaultVersionID();
- }
-
- public TranslatorResourceImpl(Renderer aRenderer) {
- super();
- setRenderer(aRenderer);
- }
-
- public java.lang.String getEncoding() {
- if (super.getEncoding() == null)
- setEncoding(DEFAULT_ENCODING);
- return super.getEncoding();
- }
-
- public String getPublicId() {
- return publicId;
- }
-
- /**
- * Return the first element in the EList.
- */
- public EObject getRootObject() {
- if (contents == null || contents.isEmpty())
- return null;
- return (EObject) getContents().get(0);
- }
-
- public String getSystemId() {
- return systemId;
- }
-
- public void setDoctypeValues(String aPublicId, String aSystemId) {
- boolean changed = !(StringUtil.stringsEqual(publicId, aPublicId) && StringUtil.stringsEqual(systemId, aSystemId));
- publicId = aPublicId;
- systemId = aSystemId;
- if (changed) {
- eNotify(new NotificationImpl(Notification.SET, null, null) {
- public Object getFeature() {
- return DOC_TYPE_FEATURE;
- }
-
- public Object getNotifier() {
- return TranslatorResourceImpl.this;
- }
- });
- }
- }
-
- /**
- * Returns the xmlVersion.
- *
- * @return String
- */
- public String getXMLVersion() {
- if (xmlVersion == null)
- xmlVersion = DEFAULT_VERSION;
- return xmlVersion;
- }
-
- /**
- * Sets the xmlVersion.
- *
- * @param xmlVersion
- * The xmlVersion to set
- */
- public void setXMLVersion(String xmlVersion) {
- this.xmlVersion = xmlVersion;
- }
-
- protected void basicDoLoad(InputStream inputStream, Map options) throws IOException {
- // long start = System.currentTimeMillis();
- boolean isTrackingMods = isTrackingModification();
- try {
- if (isTrackingMods)
- setTrackingModification(false);
- renderer.doLoad(inputStream, options);
- }
- finally {
- if (isTrackingMods)
- setTrackingModification(true);
- }
- // long end = System.currentTimeMillis();
- // recordTime("Load", start, end);
- }
-
- public void save(Map options) throws IOException {
- if (renderer.useStreamsForIO()) {
- super.save(options);
- }
- else {
- // we cast to OutputStream, in preparation for 3.2 code base,
- // where this doSave call is ambiguous with just "null".
- doSave((OutputStream) null, options);
- notifySaved();
- }
- }
-
- /**
- * @see com.ibm.etools.xmi.helpers.CompatibilityXMIResourceImpl#doSave(OutputStream,
- * Map)
- */
- public void doSave(OutputStream outputStream, Map options) throws IOException {
- // long start = System.currentTimeMillis();
- renderer.doSave(outputStream, options);
- setModified(false);
- // long end = System.currentTimeMillis();
- // recordTime("Save", start, end);
- }
-
- // private void recordTime(String type, long start, long end) {
- // System.out.println(renderer.getClass().getName() + "\t" + type + "\t" +
- // (end - start) +
- // "\t\t\tms" + "\t" + (( this.getVersionID()) / 10.0) + "\t" + this);
- // //$NON-NLS-1$
- // //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- // }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#doUnload()
- */
- protected void doUnload() {
- renderer.preUnload();
- super.doUnload();
- }
-
- public String toString() {
- return getClass().getName() + getURI().toString();
- }
-
- /**
- * Returns the renderer.
- *
- * @return Renderer
- */
- public Renderer getRenderer() {
- return renderer;
- }
-
- /**
- * Sets the renderer.
- *
- * @param renderer
- * The renderer to set
- */
- public void setRenderer(Renderer renderer) {
- this.renderer = renderer;
- if (renderer.getResource() != this)
- renderer.setResource(this);
- }
-
- /**
- * For compatibility of old subtype resources, returns the super
- * implementation
- *
- * @return
- */
- protected EList primGetContents() {
- return super.getContents();
- }
-
- public EList getContents() {
- if (contents == null) {
- initializeContents();
- }
- return contents;
- }
-
- protected void initializeContents() {
- contents = new ResourceImpl.ContentsEList() {
- public boolean add(Object object) {
- renderer.prepareToAddContents();
- return super.add(object);
- }
-
- public boolean addAll(Collection collection) {
- renderer.prepareToAddContents();
- return super.addAll(collection);
- }
- };
- }
-
- public void setDefaults() {
- if (systemId != null && publicId != null)
- return;
- String pubId = publicId == null ? getDefaultPublicId() : publicId;
- String sysId = systemId == null ? getDefaultSystemId() : systemId;
- setDoctypeValues(pubId, sysId);
- }
-
- /**
- * @see org.eclipse.emf.ecore.xmi.impl.XMLResourceImpl#init()
- */
- protected void init() {
- super.init();
- setEncoding(DEFAULT_ENCODING);
- }
-
- /**
- * Returns null by default; subclasses can override
- *
- * @see com.ibm.etools.emf2xml.TranslatorResource#createEntityResolver()
- */
- public EntityResolver getEntityResolver() {
- return null;
- }
-
- protected abstract String getDefaultPublicId();
-
- protected abstract String getDefaultSystemId();
-
- protected abstract int getDefaultVersionID();
-
- /**
- * @return
- */
- public int getVersionID() {
- return versionID;
- }
-
- /**
- * @param i
- */
- public void setVersionID(int i) {
- versionID = i;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf2xml.TranslatorResource#usesDTD()
- */
- public boolean usesDTD() {
- return getPublicId() != null && getSystemId() != null;
- }
-
- /**
- * Overridden to notify when the ID gets set; need this to push it into
- * the resource
- *
- * @see org.eclipse.emf.ecore.xmi.XMLResource#setID(EObject, String)
- */
- public void setID(EObject eObject, String id) {
- String oldId = getID(eObject);
- super.setID(eObject, id);
- eObject.eNotify(new ENotificationImpl((InternalEObject) eObject, Notification.SET, ID_FEATURE, oldId, id));
- }
-
- /**
- * This method indicates whether or not the extent associated with the
- * resource has been modified since the last time it was loaded or saved.
- *
- * @return boolean
- */
- public boolean isModified() {
- return super.isModified() || renderer.isModified();
- }
-
- /*
- * Overriden to give the renderer a hook
- *
- * @see org.eclipse.wst.common.internal.emf.resource.ReferencedResource#accessForWrite()
- */
- public void accessForWrite() {
- renderer.accessForWrite();
- super.accessForWrite();
- }
-
- /*
- * Overriden to give the renderer a hook
- *
- * @see org.eclipse.wst.common.internal.emf.resource.ReferencedResource#accessForRead()
- */
- public void accessForRead() {
- renderer.accessForRead();
- super.accessForRead();
- }
-
- public void releaseFromRead() {
- renderer.releaseFromRead();
- super.releaseFromRead();
- }
-
- public void releaseFromWrite() {
- renderer.releaseFromWrite();
- super.releaseFromWrite();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see com.ibm.etools.emf.workbench.ReferencedXMIResourceImpl#preDelete()
- */
- public void preDelete() {
- super.preDelete();
- renderer.preDelete();
- }
-
- public boolean isShared() {
- return super.isShared() || renderer.isShared();
- }
-
- public boolean isSharedForWrite() {
- return super.isSharedForWrite() || renderer.isSharedForWrite();
- }
-
- public boolean isLoaded() {
- synchronized (this) {
- return super.isLoaded();
- }
- }
-
- public void load(Map options) throws IOException {
- synchronized (this) {
- if (isLoaded)
- return;
- // System.out.println(Thread.currentThread() + "
- // TranslatorResource.load(): " + this);
- if (renderer.useStreamsForIO()) {
- super.load(options);
- }
- else if (!isLoaded) {
- load((InputStream) null, options);
- }
- }
-
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/UnsupportedFeature.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/UnsupportedFeature.java
deleted file mode 100644
index 43c5864ab..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/UnsupportedFeature.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Apr 13, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.impl.EAttributeImpl;
-
-/**
- * @author cbridgha
- *
- * TODO To change the template for this generated type comment go to Window - Preferences - Java -
- * Code Generation - Code and Comments
- */
-public class UnsupportedFeature extends EAttributeImpl {
- /**
- * This is used to capture features that are no longer supported
- */
- public static boolean isUnsupported(EClass anEClass, String featureName) {
-
- if (featureName.equals("isZeroParams") && anEClass.getName().equals("MethodElement")) //$NON-NLS-1$ //$NON-NLS-2$
- return true;
- return false;
- }
-
- public UnsupportedFeature() {
- super();
- // TODO Auto-generated constructor stub
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/VariableTranslatorFactory.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/VariableTranslatorFactory.java
deleted file mode 100644
index 1a4eef991..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/VariableTranslatorFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Aug 20, 2003
- *
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-import java.util.List;
-
-import org.eclipse.emf.common.notify.Notification;
-import org.eclipse.emf.common.notify.Notifier;
-
-
-/**
- * @author schacher
- */
-public interface VariableTranslatorFactory {
- /** Returns whether a Translator should be created for the given DOM name */
- boolean accepts(String domName);
-
- /** Returns whether a Translator should be created for the given feature */
- boolean accepts(Notification notif);
-
- Translator create(Notification notif);
-
- /** Creates a new Translator for the DOM name */
- Translator create(String domName);
-
- /** Creates variable translators for an EMF object to be rendered */
- List create(Notifier target);
-
-
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/XMLEncoderDecoder.java b/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/XMLEncoderDecoder.java
deleted file mode 100644
index 9f469622d..000000000
--- a/plugins/org.eclipse.wst.common.emf/wtpemf/org/eclipse/wst/common/internal/emf/resource/XMLEncoderDecoder.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2003, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on May 20, 2004
- *
- * TODO To change the template for this generated file go to
- * Window - Preferences - Java - Code Generation - Code and Comments
- */
-package org.eclipse.wst.common.internal.emf.resource;
-
-/**
- * @author mdelder
- *
- */
-public class XMLEncoderDecoder {
-
- /**
- *
- */
- public XMLEncoderDecoder() {
- super();
- }
-
- /**
- * Identifies the last printable character in the Unicode range that is supported by the
- * encoding used with this serializer. For 8-bit encodings this will be either 0x7E or 0xFF. For
- * 16-bit encodings this will be 0xFFFF. Characters that are not printable will be escaped using
- * character references.
- */
- private int _lastPrintable = 0x7E;
-
- protected static XMLEncoderDecoder _singleton;
-
-
- /**
- * Returns a decoded version of the value.
- */
- public String decode(String value) {
- // NOT_IMPLEMENTED
- return value;
- }
-
-
- /**
- * Escapes a string so it may be printed as text content or attribute value. Non printable
- * characters are escaped using character references. Where the format specifies a deault entity
- * reference, that reference is used (e.g. <tt>&amp;lt;</tt>).
- *
- * @param source
- * The string to escape
- */
- public char[] encode(char[] value) {
- boolean unmodified = true;
- StringBuffer sbuf = new StringBuffer(value.length);
- String charRef = null;
- char ch;
- for (int i = 0; i < value.length; ++i) {
- ch = value[i];
- // If there is a suitable entity reference for this
- // character, print it. The list of available entity
- // references is almost but not identical between
- // XML and HTML.
- charRef = getEntityRef(ch);
- if (charRef != null) {
- sbuf.append('&');
- sbuf.append(charRef);
- sbuf.append(';');
- unmodified = false;
- } else if ((ch >= ' ' && ch <= _lastPrintable && ch != 0xF7) || ch == '\n' || ch == '\r' || ch == '\t') {
- // If the character is not printable, print as character
- // reference.
- // Non printables are below ASCII space but not tab or line
- // terminator, ASCII delete, or above a certain Unicode
- // threshold.
- sbuf.append(ch);
- } else {
- sbuf.append("&#");//$NON-NLS-1$
- sbuf.append(Integer.toString(ch));
- sbuf.append(';');
- unmodified = false;
- }
- }
- if (unmodified)
- return value;
- char[] result = new char[sbuf.length()];
- sbuf.getChars(0, sbuf.length(), result, 0);
- return result;
- }
-
- /**
- * Escapes a string so it may be printed as text content or attribute value. Non printable
- * characters are escaped using character references. Where the format specifies a deault entity
- * reference, that reference is used (e.g. <tt>&amp;lt;</tt>).
- *
- * @param source
- * The string to escape
- */
- public String encode(String value) {
- StringBuffer sbuf = new StringBuffer(value.length());
- String charRef = null;
- char ch;
- for (int i = 0; i < value.length(); ++i) {
- ch = value.charAt(i);
- // If there is a suitable entity reference for this
- // character, print it. The list of available entity
- // references is almost but not identical between
- // XML and HTML.
- charRef = getEntityRef(ch);
- if (charRef != null) {
- sbuf.append('&');
- sbuf.append(charRef);
- sbuf.append(';');
- } else if ((ch >= ' ' && ch <= _lastPrintable && ch != 0xF7) || ch == '\n' || ch == '\r' || ch == '\t') {
- // If the character is not printable, print as character
- // reference.
- // Non printables are below ASCII space but not tab or line
- // terminator, ASCII delete, or above a certain Unicode
- // threshold.
- sbuf.append(ch);
- } else {
- sbuf.append("&#");//$NON-NLS-1$
- sbuf.append(Integer.toString(ch));
- sbuf.append(';');
- }
- }
- return sbuf.toString();
- }
-
- public static String escape(String value) {
- if (_singleton == null) {
- _singleton = new XMLEncoderDecoder();
- }
- return _singleton.encode(value);
- }
-
- /**
- * Returns the suitable entity reference for this character value, or null if no such entity
- * exists. Calling this method with <tt>'&amp;'</tt> will return <tt>"&amp;amp;"</tt>.
- *
- * @param ch
- * Character value
- * @return Character entity name, or null
- */
- protected String getEntityRef(char ch) {
- // Encode special XML characters into the equivalent character
- // references.
- // These five are defined by default for all XML documents.
- switch (ch) {
- case '<' :
- return "lt";//$NON-NLS-1$
- case '>' :
- return "gt";//$NON-NLS-1$
- case '"' :
- return "quot";//$NON-NLS-1$
- case '\'' :
- return "apos";//$NON-NLS-1$
- case '&' :
- return "amp";//$NON-NLS-1$
- }
- return null;
- }
-} \ No newline at end of file

Back to the top