Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util')
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDAdapterFactory.java440
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDMetrics.java125
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDModelBuilder.java1844
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDObjectFinder.java173
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPathnameUtil.java352
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPrinter.java525
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceFactoryImpl.java79
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceImpl.java166
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDSwitch.java489
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUniqueNameHelper.java174
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUtil.java1217
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDVisitor.java315
-rw-r--r--bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/ExternalDTDModel.java85
13 files changed, 0 insertions, 5984 deletions
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDAdapterFactory.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDAdapterFactory.java
deleted file mode 100644
index fa06cdfce8..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDAdapterFactory.java
+++ /dev/null
@@ -1,440 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import org.eclipse.emf.common.notify.Adapter;
-import org.eclipse.emf.common.notify.Notifier;
-import org.eclipse.emf.common.notify.impl.AdapterFactoryImpl;
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDBasicType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDExternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDInternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPackage;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDRepeatableContent;
-
-
-
-public class DTDAdapterFactory extends AdapterFactoryImpl {
- /**
- * @generated This field/method will be replaced during code generation.
- */
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- protected static DTDPackage modelPackage;
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public DTDAdapterFactory() {
- if (modelPackage == null) {
- modelPackage = DTDPackage.eINSTANCE;
- }
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public boolean isFactoryForType(Object object) {
- if (object == modelPackage) {
- return true;
- }
- if (object instanceof EObject) {
- return ((EObject) object).eClass().getEPackage() == modelPackage;
- }
- return false;
- }
-
- /**
- * The switch the delegates to the <code>createXXX</code> methods. <!--
- * begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected DTDSwitch modelSwitch = new DTDSwitch() {
- public Object caseDTDElementContent(DTDElementContent object) {
- return createDTDElementContentAdapter();
- }
-
- public Object caseDTDGroupContent(DTDGroupContent object) {
- return createDTDGroupContentAdapter();
- }
-
- public Object caseDTDAttribute(DTDAttribute object) {
- return createDTDAttributeAdapter();
- }
-
- public Object caseDTDElement(DTDElement object) {
- return createDTDElementAdapter();
- }
-
- public Object caseDTDEmptyContent(DTDEmptyContent object) {
- return createDTDEmptyContentAdapter();
- }
-
- public Object caseDTDAnyContent(DTDAnyContent object) {
- return createDTDAnyContentAdapter();
- }
-
- public Object caseDTDPCDataContent(DTDPCDataContent object) {
- return createDTDPCDataContentAdapter();
- }
-
- public Object caseDTDElementReferenceContent(DTDElementReferenceContent object) {
- return createDTDElementReferenceContentAdapter();
- }
-
- public Object caseDTDRepeatableContent(DTDRepeatableContent object) {
- return createDTDRepeatableContentAdapter();
- }
-
- public Object caseDTDFile(DTDFile object) {
- return createDTDFileAdapter();
- }
-
- public Object caseDTDBasicType(DTDBasicType object) {
- return createDTDBasicTypeAdapter();
- }
-
- public Object caseDTDEnumerationType(DTDEnumerationType object) {
- return createDTDEnumerationTypeAdapter();
- }
-
- public Object caseDTDNotation(DTDNotation object) {
- return createDTDNotationAdapter();
- }
-
- public Object caseDTDEntity(DTDEntity object) {
- return createDTDEntityAdapter();
- }
-
- public Object caseDTDEntityContent(DTDEntityContent object) {
- return createDTDEntityContentAdapter();
- }
-
- public Object caseDTDExternalEntity(DTDExternalEntity object) {
- return createDTDExternalEntityAdapter();
- }
-
- public Object caseDTDInternalEntity(DTDInternalEntity object) {
- return createDTDInternalEntityAdapter();
- }
-
- public Object caseDTDParameterEntityReference(DTDParameterEntityReference object) {
- return createDTDParameterEntityReferenceAdapter();
- }
-
- public Object caseDTDEntityReferenceContent(DTDEntityReferenceContent object) {
- return createDTDEntityReferenceContentAdapter();
- }
-
- public Object caseDTDContent(DTDContent object) {
- return createDTDContentAdapter();
- }
-
- public Object caseEModelElement(EModelElement object) {
- return createEModelElementAdapter();
- }
-
- public Object caseENamedElement(ENamedElement object) {
- return createENamedElementAdapter();
- }
-
- public Object caseETypedElement(ETypedElement object) {
- return createETypedElementAdapter();
- }
-
- public Object caseEStructuralFeature(EStructuralFeature object) {
- return createEStructuralFeatureAdapter();
- }
-
- public Object caseEAttribute(EAttribute object) {
- return createEAttributeAdapter();
- }
-
- public Object caseEClassifier(EClassifier object) {
- return createEClassifierAdapter();
- }
-
- public Object caseEClass(EClass object) {
- return createEClassAdapter();
- }
-
- public Object caseEDataType(EDataType object) {
- return createEDataTypeAdapter();
- }
-
- public Object caseEEnum(EEnum object) {
- return createEEnumAdapter();
- }
-
- public Object defaultCase(EObject object) {
- return createEObjectAdapter();
- }
- };
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createAdapter(Notifier target) {
- return (Adapter) modelSwitch.doSwitch((EObject) target);
- }
-
-
- /**
- * By default create methods return null so that we can easily ignore
- * cases. It's useful to ignore a case when inheritance will catch all the
- * cases anyway.
- */
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDFileAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDNotationAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDEntityAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDEntityContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDExternalEntityAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDInternalEntityAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDParameterEntityReferenceAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDEntityReferenceContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDRepeatableContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDElementReferenceContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDElementAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDElementContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDEmptyContentAdapter() {
- return null;
- }
-
- /**
- * By default create methods return null so that we can easily ignore
- * cases. It's useful to ignore a case when inheritance will catch all the
- * cases anyway.
- */
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDAnyContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDPCDataContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDGroupContentAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDAttributeAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDEnumerationTypeAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createDTDBasicTypeAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEClassAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEAttributeAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEEnumAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEModelElementAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createENamedElementAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEStructuralFeatureAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEDataTypeAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEObjectAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createETypedElementAdapter() {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Adapter createEClassifierAdapter() {
- return null;
- }
-
-} // DTDAdapterFactory
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDMetrics.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDMetrics.java
deleted file mode 100644
index 32c06e3f88..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDMetrics.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Vector;
-
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-
-
-public class DTDMetrics {
- protected DTDFile dtdFile;
- protected Hashtable elementReferenceMap;
-
- public DTDMetrics(DTDFile dtdFile) {
- this.dtdFile = dtdFile;
- }
-
- public Hashtable getElementReferences() {
- if (elementReferenceMap == null) {
- elementReferenceMap = new Hashtable();
- new DTDVisitor() {
-
- public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
- DTDElement dtdElement = elementReferenceContent.getReferencedElement();
- Object visitation = elementReferenceMap.get(dtdElement);
- if (visitation == null) {
- elementReferenceMap.put(dtdElement, visitation = new Vector());
- }
- ((Vector) visitation).addElement(elementReferenceContent);
- }
- }.visitDTDFile(dtdFile);
- }
-
- return elementReferenceMap;
- }
-
- public int getElementReferenceCount(DTDElement dtdElement) {
- Object elementReferences = getElementReferences().get(dtdElement);
- return elementReferences == null ? 0 : ((Vector) elementReferences).size();
- }
-
- public DTDElement getLeastReferencedElement() {
- DTDElement result = null;
- int lowestReferenceCount = Integer.MAX_VALUE;
-
- Collection elements = dtdFile.listDTDElement();
- for (Iterator i = elements.iterator(); i.hasNext();) {
- DTDElement element = (DTDElement) i.next();
- int count = getElementReferenceCount(element);
- if (count < lowestReferenceCount) {
- result = element;
- lowestReferenceCount = count;
- }
- }
-
- return result;
- }
-
- /**
- * @generated
- */
- protected Hashtable getElementReferencesGen() {
-
- if (elementReferenceMap == null) {
- elementReferenceMap = new Hashtable();
- new DTDVisitor() {
-
- public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
- DTDElement dtdElement = elementReferenceContent.getReferencedElement();
- Object visitation = elementReferenceMap.get(dtdElement);
- if (visitation == null) {
- elementReferenceMap.put(dtdElement, visitation = new Vector());
- }
- ((Vector) visitation).addElement(elementReferenceContent);
- }
- }.visitDTDFile(dtdFile);
- }
-
- return elementReferenceMap;
- }
-
- /**
- * @generated
- */
- protected int getElementReferenceCountGen(DTDElement dtdElement) {
-
- Object elementReferences = getElementReferences().get(dtdElement);
- return elementReferences == null ? 0 : ((Vector) elementReferences).size();
- }
-
- /**
- * @generated
- */
- protected DTDElement getLeastReferencedElementGen() {
-
- DTDElement result = null;
- int lowestReferenceCount = Integer.MAX_VALUE;
-
- Collection elements = dtdFile.listDTDElement();
- for (Iterator i = elements.iterator(); i.hasNext();) {
- DTDElement element = (DTDElement) i.next();
- int count = getElementReferenceCount(element);
- if (count < lowestReferenceCount) {
- result = element;
- lowestReferenceCount = count;
- }
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDModelBuilder.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDModelBuilder.java
deleted file mode 100644
index d3dc76a33d..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDModelBuilder.java
+++ /dev/null
@@ -1,1844 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.Enumeration;
-import java.util.Iterator;
-
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EcorePackage;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.dtd.core.internal.DTDCoreMessages;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDBasicType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDBasicTypeKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDDefaultKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEnumGroupKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDExternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFactory;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDInternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDType;
-import org.eclipse.wst.dtd.core.internal.emf.impl.DTDFactoryImpl;
-import org.eclipse.wst.dtd.core.internal.saxparser.AttNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.Attlist;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMBasicNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMGroupNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMNodeType;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMReferenceNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.CMRepeatableNode;
-import org.eclipse.wst.dtd.core.internal.saxparser.DTD;
-import org.eclipse.wst.dtd.core.internal.saxparser.DTDSaxArtifactVisitor;
-import org.eclipse.wst.dtd.core.internal.saxparser.ElementDecl;
-import org.eclipse.wst.dtd.core.internal.saxparser.EntityDecl;
-import org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage;
-import org.eclipse.wst.dtd.core.internal.saxparser.NotationDecl;
-
-public class DTDModelBuilder extends DTDSaxArtifactVisitor {
- DTD dtd;
- DTDUtil dtdUtil;
- DTDFile dtdFile;
- ResourceSet resources;
-
- public DTDModelBuilder(ResourceSet resources, DTDUtil dtdUtil, DTD dtd, DTDFile dtdFile) {
- this.resources = resources;
- this.dtdUtil = dtdUtil;
- this.dtd = dtd;
- this.dtdFile = dtdFile;
- }
-
- public DTDFactoryImpl getFactory() {
- return (DTDFactoryImpl) dtdUtil.getFactory();
- }
-
- public DTDFile getDTDFile() {
- return dtdFile;
- }
-
- public void visitDTD(DTD dtd) {
- super.visitDTD(dtd);
-
- // - 2nd pass -
- // do final processing for Attlists and adding contentModel
- addAttlistAndContentModel(dtd, dtdFile);
- }
-
- public void visitElementDecl(ElementDecl element) {
- // Element might have been added earlier because it is referenced
- String declName = element.getNodeName();
- // System.out.println("process ElementDecl:" + declName );
- DTDElement dtdelement = (DTDElement) dtdUtil.getElementPool().get(declName);
- if (dtdelement == null) {
- // System.out.println("process ElementDecl - not found - create"
- // );
- dtdelement = getFactory().createDTDElement();
- dtdelement.setName(declName);
- dtdFile.getDTDObject().add(dtdelement);
- dtdUtil.getElementPool().put(declName, dtdelement);
- }
-
- super.visitElementDecl(element);
- }
-
- public void visitNotationDecl(NotationDecl notation) {
- // Notation might have been added earlier because it is referenced
- // by an entity
- DTDNotation dtdnot = dtdFile.findNotation(notation.getNodeName());
- if (dtdnot == null) {
- dtdnot = getFactory().createDTDNotation();
- dtdFile.getDTDObject().add(dtdnot);
- }
- dtdnot.setName(notation.getNodeName());
-
- if (notation.getSystemId() != null)
- dtdnot.setSystemID(notation.getSystemId());
- if (notation.getPublicId() != null)
- dtdnot.setPublicID(notation.getPublicId());
-
- if (notation.getComment() != null)
- dtdnot.setComment(notation.getComment());
- if (notation.getErrorMessage() != null) {
- addErrorMessage(notation.getErrorMessage(), dtdnot);
- }
-
- super.visitNotationDecl(notation);
- }
-
- public void visitParameterEntityReferenceDecl(EntityDecl entity) {
- // This is a parameter entity reference.
- // Add the link to the real entity that it references
- DTDParameterEntityReference parmEntRef = getFactory().createDTDParameterEntityReference();
- dtdFile.getDTDObject().add(parmEntRef);
-
- String entityName = entity.getNodeName();
-
- // Add the reference to the DTDEntity
- DTDEntity dtdentity = getDTDFile().findEntity(entityName);
- if (dtdentity != null) {
- parmEntRef.setEntity(dtdentity);
- }
- if (entity.getErrorMessage() != null) {
- addErrorMessage(entity.getErrorMessage(), dtdentity);
- }
- // System.out.println("adding PE reference: " + declName);
-
- super.visitParameterEntityReferenceDecl(entity);
- }
-
- public void visitExternalEntityDecl(EntityDecl entity) {
- DTDEntity dtdEntity = createDTDEntity(entity);
- // System.out.println("adding entity: " + declName);
- DTDExternalEntity extEntity = getFactory().createDTDExternalEntity();
- dtdEntity.setContent(extEntity);
-
- finishExternalEntity(extEntity, entity);
- // System.out.println(" ext entity toMof: " );
- if (dtdEntity.isParameterEntity()) {
-
- dtdUtil.getPEPool().put("%" + entity.getNodeName() + ";", dtdEntity); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- super.visitExternalEntityDecl(entity);
- }
-
- public void visitInternalEntityDecl(EntityDecl entity) {
- DTDEntity dtdEntity = createDTDEntity(entity);
-
- DTDInternalEntity intEntity = getFactory().createDTDInternalEntity();
- dtdEntity.setContent(intEntity);
- intEntity.setValue(entity.getValue());
- // System.out.println(" int entity toMof: " );
- if (dtdEntity.isParameterEntity()) {
- dtdUtil.getPEPool().put("%" + entity.getNodeName() + ";", dtdEntity); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- super.visitInternalEntityDecl(entity);
- }
-
- private void addAttlistAndContentModel(DTD dtd, DTDFile dFile) {
- // System.out.println("addAttListAndCotentModel - dtd:" +
- // dtd.getName());
- Enumeration en = dtd.externalElements();
- while (en.hasMoreElements()) {
- Object e = en.nextElement();
- if (e instanceof ElementDecl) {
- DTDElement dtdelement = (DTDElement) dtdUtil.getElementPool().get(((ElementDecl) e).getNodeName());
- if (dtdelement == null) {
- dtdelement = getFactory().createDTDElement();
- dtdFile.getDTDObject().add(dtdelement);
- }
- finishElementDecl(dtdelement, (ElementDecl) e);
- }
- else if (e instanceof Attlist) {
- processAttList((Attlist) e);
- }
- }
- }
-
-
- private void processAttList(Attlist attList) {
- DTDElement e = (DTDElement) dtdUtil.getElementPool().get(attList.getNodeName());
- if (e != null) {
- // Element has been added. Add the attributes
- // System.out.println(" processAttlist - adding Attlist:" +
- // attList.getNodeName());
- createAttributes(e, attList);
- }
- else {
- // System.out.println("!!!!!!!!! element is null ");
- }
- }
-
- // /////////////////////////////////////////////////////////////
- //
- // Methods for finishing the import of a DTDExternalEntity
- //
- // /////////////////////////////////////////////////////////////
- void finishExternalEntity(DTDExternalEntity extEntity, EntityDecl entityDecl) {
- updateSystemID(extEntity, entityDecl);
- extEntity.setPublicID(entityDecl.getPublicId());
-
- String notationName = entityDecl.getNotationName();
- if (notationName != null) {
- DTDNotation dtdNotation = createOrFindNotation(extEntity, notationName, true);
- extEntity.setNotation(dtdNotation);
- }
- }
-
- public DTDNotation createOrFindNotation(DTDExternalEntity extEntity, String name, boolean create) {
- DTDNotation aNotation = extEntity.getDTDEntity().getDTDFile().findNotation(name);
- if (aNotation != null) {
- return aNotation;
- }
-
- //
- // Create a notation for the reference
- //
- if (create) {
- aNotation = getFactory().createDTDNotation();
- dtdFile.getDTDObject().add(aNotation);
- aNotation.setName(name);
- }
- return aNotation;
- }
-
- /**
- * The SystemID attribute is set to whatever the user enters e.g.
- * com/ibm/b2b/xmimodels/xxx.dtd.xmi
- *
- * In the unparse() method, parse out the DTD file name from the classpath
- * name. e.g. returns xxx.dtd
- */
- private void updateSystemID(DTDExternalEntity extEntity, EntityDecl entityDecl) {
- String systemId = entityDecl.getSystemId();
- String publicId = entityDecl.getPublicId();
- if (systemId != null) {
- URIResolver idResolver = URIResolverPlugin.createResolver();
- String uri = idResolver.resolve(dtd.getName(), publicId, systemId);
- ExternalDTDModel ed = dtdUtil.getExternalDTDModel(resources, uri);
- if (ed != null) {
- DTDFile referenceDtdFile = ed.getExternalDTDFile();
- extEntity.setEntityReferencedFromAnotherFile(referenceDtdFile);
- extEntity.setSystemID(systemId);
- }
- else {
- if (entityDecl.getErrorMessage() == null) {
- ErrorMessage dtdError = new ErrorMessage();
- dtdError.setErrorMessage(DTDCoreMessages._ERROR_INCL_FILE_LOAD_FAILURE + " '" + systemId + "'"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- addErrorMessage(dtdError, extEntity.getDTDEntity());
- }
-
- if (systemId != null) {
- extEntity.setSystemID(systemId);
- }
- else {
- extEntity.setSystemID(""); //$NON-NLS-1$
- }
- }
- } // end of if ()
- else {
- // set the system id to be ""
- extEntity.setSystemID(""); //$NON-NLS-1$
- }
- }
-
- public DTDEntity createDTDEntity(EntityDecl entity) {
- // create and do what we can to fill in some basic things
- DTDEntity dtdEntity = getFactory().createDTDEntity();
- dtdFile.getDTDObject().add(dtdEntity);
-
- dtdEntity.setName(entity.getNodeName());
- dtdEntity.setParameterEntity(entity.isParameter());
- if (entity.getComment() != null) {
- dtdEntity.setComment(entity.getComment());
- }
- if (entity.getErrorMessage() != null) {
- addErrorMessage(entity.getErrorMessage(), dtdEntity);
- }
-
- return dtdEntity;
- }
-
-
- // /////////////////////////////////////////////////////////////
- //
- // Methods for finishing the import of a DTDElement
- //
- // /////////////////////////////////////////////////////////////
- public void finishElementDecl(DTDElement dtdElement, ElementDecl ed) {
- dtdElement.setName(ed.getNodeName());
-
- CMNode cmNode = ed.getContentModelNode();
-
- if (ed.getComment() != null) {
- dtdElement.setComment(ed.getComment());
- }
- if (ed.getErrorMessage() != null) {
- addErrorMessage(ed.getErrorMessage(), dtdElement);
- }
-
- if (cmNode instanceof CMBasicNode) {
- CMBasicNode bn = (CMBasicNode) cmNode;
- switch (bn.getType()) {
- case CMNodeType.EMPTY :
- DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- dtdElement.setContent(emptyContent);
- break;
-
- case CMNodeType.ANY :
- DTDAnyContent anyContent = getFactory().createDTDAnyContent();
- dtdElement.setContent(anyContent);
- break;
-
- case CMNodeType.PCDATA :
- DTDPCDataContent pcData = getFactory().createDTDPCDataContent();
- dtdElement.setContent(pcData);
- }
-
- }
- else if (cmNode instanceof CMReferenceNode) {
- CMReferenceNode rn = (CMReferenceNode) cmNode;
- if (rn.getType() == CMNodeType.ENTITY_REFERENCE) {
- String entityName = rn.getName().trim();
-
- DTDEntity anEntity = (DTDEntity) dtdUtil.getPEPool().get(entityName);
- if (anEntity != null) {
- //
- // Create an DTDEntityReference and set its referenced
- // element
- //
- DTDEntityReferenceContent enRef = getFactory().createDTDEntityReferenceContent();
- enRef.setElementReferencedEntity(anEntity);
-
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(rn));
- enRef.setOccurrence(occurrenceType);
-
- dtdElement.setContent(enRef);
- }
- else { // create default content
- DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- dtdElement.setContent(emptyContent);
- }
- }
- else {
- //
- // Find the real element for this element references
- // If the real element does not yet exist, create it
- //
- DTDElement anElement = createOrFindElement(rn.getName(), dtdElement);
-
- //
- // Create an DTDElementReference and set its referenced
- // element
- //
- DTDElementReferenceContent elemRef = getFactory().createDTDElementReferenceContent();
- elemRef.setReferencedElement(anElement);
-
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(rn));
- elemRef.setOccurrence(occurrenceType);
-
- // setContent to DTDElementReference
- dtdElement.setContent(elemRef);
-
- }
- }
- else if (cmNode instanceof CMGroupNode) {
- CMGroupNode grpNode = (CMGroupNode) cmNode;
- DTDGroupContent groupContent = getFactory().createDTDGroupContent();
- DTDGroupKind groupKind = DTDGroupKind.get(computeMofGroupKind(grpNode.getGroupKind()));
- groupContent.setGroupKind(groupKind);
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(grpNode));
- groupContent.setOccurrence(occurrenceType);
-
- // just use the locator for the element as the closest guess
- processGroupContent(groupContent, grpNode);
- dtdElement.setContent(groupContent);
- }
- else if (cmNode == null) {
- // bad thing happened here, just create a pcdata
- DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- dtdElement.setContent(emptyContent);
- }
-
-
- }
-
-
- /**
- * Add a new group to the current group
- *
- * @param parent -
- * the parent node for this group element
- * @param op1Node -
- * the group e.g. (a,b)
- * @param op2Node -
- * set only if called by processCM1op e.g. (a,b)+
- */
- void processGroupContent(DTDGroupContent parent, CMGroupNode grpNode) {
- Enumeration children = grpNode.getChildren().elements();
- DTDFactory factory = getFactory();
- while (children.hasMoreElements()) {
- CMNode cnode = (CMNode) children.nextElement();
-
- if (cnode instanceof CMGroupNode) {
- CMGroupNode gNode = (CMGroupNode) cnode;
- DTDGroupContent groupContent = factory.createDTDGroupContent();
- DTDGroupKind groupKind = DTDGroupKind.get(computeMofGroupKind(gNode.getGroupKind()));
- groupContent.setGroupKind(groupKind);
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(gNode));
- groupContent.setOccurrence(occurrenceType);
-
- parent.getContent().add(groupContent);
- processGroupContent(groupContent, gNode);
- }
- else if (cnode instanceof CMBasicNode) {
- CMBasicNode n = (CMBasicNode) cnode;
- if (n.getType() == CMNodeType.PCDATA) {
- // Create a DTDPCDataContent for a leaf PCData node
- //
- DTDPCDataContent pcData = factory.createDTDPCDataContent();
- // Add #PCDATA to the Group, i.e Mixed content model
- parent.getContent().add(pcData);
- }
- }
- else if (cnode instanceof CMReferenceNode) {
- CMReferenceNode rn = (CMReferenceNode) cnode;
- if (rn.getType() == CMNodeType.ELEMENT_REFERENCE) {
- // System.out.println("CM Element Ref name: " +
- // rn.getName());
- //
- // Create an DTDElementReference and set its referenced
- // element
- //
- DTDElementReferenceContent elemRef = factory.createDTDElementReferenceContent();
-
- //
- // Find the real element for this element references
- // If the real element does not yet exist, create it
- //
- DTDElement anElement = createOrFindElement(rn.getName(), elemRef);
-
- elemRef.setReferencedElement(anElement);
-
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(rn));
- elemRef.setOccurrence(occurrenceType);
-
- // Add DTDElementReference to the Group
- parent.getContent().add(elemRef);
- }
- else // PE Reference
- {
- String entityName = rn.getName().trim();
-
- // System.out.println("CM PE Ref name: " + entityName);
- DTDEntity anEntity = (DTDEntity) dtdUtil.getPEPool().get(entityName);
- if (anEntity != null) {
- //
- // Create an DTDEntityReference and set its referenced
- // element
- //
- DTDEntityReferenceContent enRef = factory.createDTDEntityReferenceContent();
- enRef.setElementReferencedEntity(anEntity);
-
- DTDOccurrenceType occurrenceType = DTDOccurrenceType.get(computeMofOccurrence(rn));
- enRef.setOccurrence(occurrenceType);
-
- // Add DTDEntityReference to the Group
- parent.getContent().add(enRef);
-
- }
- }
- }
- }
- }
-
- /**
- * Find the real element that is referenced by the current element
- */
- private DTDElement createOrFindElement(String name, Object obj) {
- // DTDElement aElement = getDTDFile().findElement(name);
-
- DTDElement aElement = (DTDElement) dtdUtil.getElementPool().get(name);
-
- if (aElement != null) {
- return aElement;
- }
-
- String errorMsg = DTDCoreMessages._ERROR_UNDECLARED_ELEMENT_1; //$NON-NLS-1$
- errorMsg += "\"" + name + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- errorMsg += DTDCoreMessages._UI_ERRORPART_UNDECLARED_ELEMENT_2; //$NON-NLS-1$
-
- ErrorMessage dtdError = new ErrorMessage();
-
- dtdError.setErrorMessage(errorMsg);
- addErrorMessage(dtdError, obj);
- // System.out.println(errorMsg);
- // setDTDErrorMessage(errorMsg);
- getDTDFile().setParseError(true);
-
- //
- // Create an empty element for the reference to make it valid
- //
-
- DTDFactory factory = getFactory();
- DTDElement dtdelement = factory.createDTDElement();
- dtdelement.setName(name);
-
- DTDEmptyContent emptyContent = factory.createDTDEmptyContent();
- dtdelement.setContent(emptyContent);
-
- getDTDFile().getDTDObject().add(dtdelement);
- dtdUtil.getElementPool().put(name, dtdelement);
- return dtdelement;
- }
-
-
- /**
- * Compute the MOF occurrence from the xml4j occurrence
- */
- private int computeMofOccurrence(CMRepeatableNode rnode) {
- int occurrence = rnode.getOccurrence();
- int mofoccur = DTDOccurrenceType.ONE;
-
- if (occurrence == CMNodeType.ZERO_OR_MORE) {
- mofoccur = DTDOccurrenceType.ZERO_OR_MORE;
- }
- else if (occurrence == CMNodeType.ONE_OR_MORE) {
- mofoccur = DTDOccurrenceType.ONE_OR_MORE;
- }
- else if (occurrence == CMNodeType.OPTIONAL) {
- mofoccur = DTDOccurrenceType.OPTIONAL;
- }
- return mofoccur;
- }
-
- /**
- * Compute the MOF model group from the xml4j model group
- */
- private int computeMofGroupKind(int type) {
- if (type == CMNodeType.GROUP_CHOICE) {
- return DTDGroupKind.CHOICE;
- }
- else {
- return DTDGroupKind.SEQUENCE;
- }
- }
-
-
- // /////////////////////////////////////////////////////////////
- //
- // Methods for creating the attributes of a DTDElement
- //
- // /////////////////////////////////////////////////////////////
- public void createAttributes(DTDElement element, Attlist attList) {
- if (attList.getErrorMessage() != null) {
- addErrorMessage(attList.getErrorMessage(), element);
- }
-
- for (int i = 0; i < attList.size(); i++) {
- AttNode ad = attList.elementAt(i);
- // DTDAttributeElement dtdAtt=
- // getDTDAttributeElement(a.getName());
-
- // only add the AttDef if it is not added yet
- // ignore the dup AttDef as documented in the XML 1.0 specs
- // if( dtdAtt==null)
- addAttribute(element, ad);
- }
-
- }
-
- /**
- * Create a DTDAttribute from the xml4j attribute
- */
- public void addAttribute(DTDElement dtdelement, AttNode ad) {
- DTDAttribute dtdattr = getFactory().createDTDAttribute();
- dtdelement.getDTDAttribute().add(dtdattr);
- finishAttribute(dtdattr, ad);
- }
-
- // Stuff for populating attribute
- public void finishAttribute(DTDAttribute dtdattr, AttNode attdef) {
- boolean parseError = false;
-
- if (attdef.name.startsWith("%")) { //$NON-NLS-1$
- String peName = attdef.name.trim();
- DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
- if (en != null) {
- dtdattr.setAttributeNameReferencedEntity(en);
- }
- }
-
- dtdattr.setName(attdef.name);
-
- int attrType = attdef.getDeclaredType();
-
- if (attrType == AttNode.PEREFERENCE && attdef.type != null) {
- String peName = attdef.type.trim();
- DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
- if (en != null) {
- dtdattr.setAttributeTypeReferencedEntity(en);
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA()); // hack,
- // so
- // we
- // can
- // get
- // back
- // the
- // default
- // value
- }
- else
- // set default type
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
-
- }
- else {
- switch (attrType) {
- case AttNode.CDATA :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
- break;
-
- case AttNode.ENTITIES :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITIES());
- break;
-
- case AttNode.ENTITY :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITY());
- break;
-
- case AttNode.ID :
- // check for duplicate ID attribute
- if (hasIDAttribute(dtdattr)) {
- String errMsg = DTDCoreMessages._ERROR_DUP_ID_ATTRIBUTE_1; //$NON-NLS-1$
- errMsg += attdef.name + DTDCoreMessages._UI_ERRORPART_DUP_ID_ATTRIBUTE_2; //$NON-NLS-1$
- // dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
- // dtdattr.getDTDElement().getDTDFile().setParseError(true);
- parseError = true;
- }
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ID());
- break;
-
- case AttNode.IDREF :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREF());
- break;
-
- case AttNode.IDREFS :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREFS());
- break;
-
- case AttNode.ENUMERATION :
- setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NAME_TOKEN_GROUP));
- break;
-
- case AttNode.NOTATION :
- setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef, DTDEnumGroupKind.NOTATION_GROUP));
- break;
-
- case AttNode.NMTOKEN :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKEN());
- break;
-
- case AttNode.NMTOKENS :
- setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKENS());
- break;
-
- default :
- // System.out.println("DTDATTR '" +attdef.name + "'Unknown
- // type..." + attrType);
- }
- }
-
- int attrDefault = attdef.getDefaultType();
- int defaultKind = DTDDefaultKind.IMPLIED;
- switch (attrDefault) {
- case AttNode.FIXED :
- defaultKind = DTDDefaultKind.FIXED;
- break;
-
- case AttNode.IMPLIED :
- defaultKind = DTDDefaultKind.IMPLIED;
- break;
-
- case AttNode.REQUIRED :
- defaultKind = DTDDefaultKind.REQUIRED;
- break;
-
- case AttNode.NOFIXED :
- defaultKind = DTDDefaultKind.NOFIXED;
- break;
-
- default :
- // System.out.println("DTDATTR '" +attdef.name + "' Unknown default
- // type... " + attrDefault);
- }
-
- DTDDefaultKind defaultKindObj = DTDDefaultKind.get(defaultKind);
- dtdattr.setDefaultKind(defaultKindObj);
-
- if (parseError) {
- return;
- }
-
- String defaultValue = attdef.defaultValue;
- if (defaultValue != null) {
- if (attrType == AttNode.ENUMERATION || attrType == AttNode.NOTATION) {
- if (!isDefaultEnumValueValid(attdef, defaultValue)) {
- String typeString = (attrType == AttNode.ENUMERATION ? "enumeration" : "notation"); //$NON-NLS-1$ //$NON-NLS-2$
- String errMsg = DTDCoreMessages._ERROR_INVALID_DEFAULT_ATTR_VALUE_1; //$NON-NLS-1$
- errMsg += typeString + DTDCoreMessages._UI_ERRORPART_INVALID_DEFAULT_ATTR_VALUE_2; //$NON-NLS-1$
- errMsg += attdef.name + "'"; //$NON-NLS-1$
-
- // dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
- // dtdattr.getDTDElement().getDTDFile().setParseError(true);
- return;
- }
- }
- dtdattr.setDefaultValueString(defaultValue);
- }
- // System.out.println("DTDAttr - toMof getDefaultValueString " +
- // getDefaultValueString());
- // System.out.println("DTDAttr - toMof getDefaultValue: " +
- // getDefaultValue());
- }
-
- public boolean hasIDAttribute(DTDAttribute dtdattr) {
- boolean hasID = false;
-
- DTDElement element = dtdattr.getDTDElement();
- EList attrs = element.getDTDAttribute();
-
- Iterator i = attrs.iterator();
- while (i.hasNext()) {
- DTDAttribute attr = (DTDAttribute) i.next();
- DTDType dType = attr.getDTDType();
- if (dType instanceof DTDBasicType) {
- if (((DTDBasicType) dType).getKind().getValue() == DTDBasicTypeKind.ID) {
- hasID = true;
- break;
- }
- }
- }
- return hasID;
- }
-
- public DTDEnumerationType createDTDEnumeration(DTDAttribute dtdattr, String[] enumValues, int enumKind) {
- DTDEnumerationType enumeration = getFactory().createDTDEnumerationType();
- DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
- enumeration.setKind(groupKind);
- // Enumeration values
- if (enumValues != null) {
- for (int i = 0; i < enumValues.length; i++) {
- EEnumLiteral enumLiteral = createEEnumLiteral();
- // enumVal.setXMIDocument(dtdattr.getXMIDocument());
- // MOF2EMF Port
- // enumLiteral.refSetLiteral(enumValues[i]);
- enumLiteral.setName(enumValues[i]);
-
- // enumLiteral.setNumber(i);
- enumeration.getEnumLiterals().add(enumLiteral);
- }
- }
- dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enumeration);
- return enumeration;
- }
-
- private EEnumLiteral createEEnumLiteral() {
- EcorePackage ePackage = (EcorePackage) EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);
- // MOF2EMF Port
- // return ((EcoreFactory)ePackage.getFactory()).createEEnumLiteral();
- return ePackage.getEcoreFactory().createEEnumLiteral();
- }
-
- private DTDEnumerationType createDTDEnumeration(DTDAttribute dtdattr, AttNode attdef, int enumKind) {
- DTDEnumerationType enumeration = getFactory().createDTDEnumerationType();
- DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
- enumeration.setKind(groupKind);
- dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enumeration);
-
- // Enumeration values
- Enumeration tokenIter = attdef.elements();
- if (tokenIter != null) {
- while (tokenIter.hasMoreElements()) {
- String val = (String) tokenIter.nextElement();
- EEnumLiteral enumLiteral = createEEnumLiteral();
- // enumLiteral.setXMIDocument(dtdattr.getXMIDocument());
- // MOF2EMF Port
- // enumLiteral.refSetLiteral(val);
- enumLiteral.setName(val);
-
-
- // enumLiteral.setNumber(i++);
- enumeration.getEnumLiterals().add(enumLiteral);
- }
- }
-
- return enumeration;
- }
-
- private boolean isDefaultEnumValueValid(AttNode attdef, String defaultValue) {
- boolean valid = false;
- boolean containsPercent = false;
-
- // Enumeration values
- Enumeration enumValues = attdef.elements();
- while (enumValues.hasMoreElements()) {
- String val = (String) enumValues.nextElement();
- if (val.equals(defaultValue)) {
- valid = true;
- break;
- }
- if (val.indexOf('%') >= 0) {
- containsPercent = true;
- }
- }
- return valid || containsPercent;
- }
-
- public void setAttrDTDType(DTDAttribute dtdattr, DTDType type) {
- dtdattr.setDTDType(type);
- }
-
- protected void addErrorMessage(ErrorMessage errMsg, Object obj) {
- errMsg.setObject(obj);
- dtdUtil.addErrorMessage(errMsg);
- }
-
- // /**
- // * @generated
- // */
- // protected DTDFactoryImpl getFactoryGen() {
- //
- // return (DTDFactoryImpl)dtdUtil.getFactory();
- // }
- // /**
- // * @generated
- // */
- // protected DTDFile getDTDFileGen() {
- //
- // return dtdFile;
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDGen(DTD dtd) {
- //
- // super.visitDTD(dtd);
- //
- //
- // // - 2nd pass -
- // // do final processing for Attlists and adding contentModel
- // addAttlistAndContentModel(dtd,dtdFile);
- // }
- // /**
- // * @generated
- // */
- // protected void visitElementDeclGen(ElementDecl element) {
- //
- // // Element might have been added earlier because it is referenced
- // String declName = element.getNodeName() ;
- // // System.out.println("process ElementDecl:" + declName );
- // DTDElement dtdelement = (DTDElement)
- // dtdUtil.getElementPool().get(declName);
- // if (dtdelement == null)
- // {
- // // System.out.println("process ElementDecl - not found - create" );
- // dtdelement = getFactory().createDTDElement();
- // dtdelement.setName(declName);
- // dtdFile.getDTDObject().add(dtdelement);
- // dtdUtil.getElementPool().put(declName,dtdelement);
- // }
- //
- //
- // super.visitElementDecl(element);
- // }
- // /**
- // * @generated
- // */
- // protected void visitNotationDeclGen(NotationDecl notation) {
- //
- // // Notation might have been added earlier because it is referenced
- // // by an entity
- // DTDNotation dtdnot = dtdFile.findNotation( notation.getNodeName() );
- // if (dtdnot == null)
- // {
- // dtdnot = getFactory().createDTDNotation();
- // dtdFile.getDTDObject().add(dtdnot);
- // }
- // dtdnot.setName(notation.getNodeName());
- //
- //
- // if (notation.getSystemId()!= null )
- // dtdnot.setSystemID(notation.getSystemId());
- // if (notation.getPublicId()!= null )
- // dtdnot.setPublicID(notation.getPublicId());
- //
- //
- // if (notation.getComment()!=null)
- // dtdnot.setComment(notation.getComment());
- // if (notation.getErrorMessage()!=null)
- // {
- // addErrorMessage(notation.getErrorMessage(), dtdnot);
- // }
- //
- //
- // super.visitNotationDecl(notation);
- // }
- // /**
- // * @generated
- // */
- // protected void visitParameterEntityReferenceDeclGen(EntityDecl entity)
- // {
- //
- // // This is a parameter entity reference.
- // // Add the link to the real entity that it references
- // DTDParameterEntityReference parmEntRef =
- // getFactory().createDTDParameterEntityReference();
- // dtdFile.getDTDObject().add(parmEntRef);
- //
- //
- // String entityName = entity.getNodeName();
- //
- //
- // // Add the reference to the DTDEntity
- // DTDEntity dtdentity = getDTDFile().findEntity(entityName);
- // if (dtdentity != null)
- // {
- // parmEntRef.setEntity(dtdentity);
- // }
- // if (entity.getErrorMessage()!=null)
- // {
- // addErrorMessage(entity.getErrorMessage(), dtdentity);
- // }
- // // System.out.println("adding PE reference: " + declName);
- //
- //
- // super.visitParameterEntityReferenceDecl(entity);
- // }
- // /**
- // * @generated
- // */
- // protected void visitExternalEntityDeclGen(EntityDecl entity) {
- //
- // DTDEntity dtdEntity = createDTDEntity(entity);
- // // System.out.println("adding entity: " + declName);
- // DTDExternalEntity extEntity = getFactory().createDTDExternalEntity();
- // dtdEntity.setContent(extEntity);
- //
- //
- // finishExternalEntity(extEntity, entity);
- // // System.out.println(" ext entity toMof: " );
- // if (dtdEntity.isParameterEntity())
- // {
- //
- //
- // dtdUtil.getPEPool().put("%"+entity.getNodeName()+";", dtdEntity);
- // }
- //
- //
- // super.visitExternalEntityDecl(entity);
- // }
- // /**
- // * @generated
- // */
- // protected void visitInternalEntityDeclGen(EntityDecl entity) {
- //
- // DTDEntity dtdEntity = createDTDEntity(entity);
- //
- //
- // DTDInternalEntity intEntity = getFactory().createDTDInternalEntity();
- // dtdEntity.setContent(intEntity);
- // intEntity.setValue(entity.getValue());
- // // System.out.println(" int entity toMof: " );
- // if (dtdEntity.isParameterEntity())
- // {
- // dtdUtil.getPEPool().put("%"+entity.getNodeName()+";", dtdEntity);
- // }
- //
- //
- // super.visitInternalEntityDecl(entity);
- // }
- // /**
- // * @generated
- // */
- // protected void addAttlistAndContentModelGen(DTD dtd, DTDFile dFile) {
- //
- // //System.out.println("addAttListAndCotentModel - dtd:" +
- // dtd.getName());
- // Enumeration en = dtd.externalElements();
- // while (en.hasMoreElements())
- // {
- // Object e = en.nextElement();
- // if ( e instanceof ElementDecl )
- // {
- // DTDElement dtdelement = (DTDElement) dtdUtil.getElementPool().get(
- // ((ElementDecl)e).getNodeName() );
- // if (dtdelement == null)
- // {
- // dtdelement = getFactory().createDTDElement();
- // dtdFile.getDTDObject().add(dtdelement);
- // }
- // finishElementDecl(dtdelement, (ElementDecl) e);
- // }
- // else if ( e instanceof Attlist )
- // {
- // processAttList((Attlist) e);
- // }
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void processAttListGen(Attlist attList) {
- //
- // DTDElement e = (DTDElement)
- // dtdUtil.getElementPool().get(attList.getNodeName());
- // if ( e != null )
- // {
- // // Element has been added. Add the attributes
- // //System.out.println(" processAttlist - adding Attlist:" +
- // attList.getNodeName());
- // createAttributes(e, attList);
- // }
- // else
- // {
- // //System.out.println("!!!!!!!!! element is null ");
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void finishExternalEntityGen(DTDExternalEntity extEntity,
- // EntityDecl entityDecl) {
- //
- // updateSystemID(extEntity, entityDecl);
- // extEntity.setPublicID(entityDecl.getPublicId());
- //
- //
- // String notationName = entityDecl.getNotationName();
- // if (notationName != null)
- // {
- // DTDNotation dtdNotation = createOrFindNotation(extEntity,
- // notationName,true);
- // extEntity.setNotation(dtdNotation);
- // }
- // }
- // /**
- // * @generated
- // */
- // protected DTDNotation createOrFindNotationGen(DTDExternalEntity
- // extEntity, String name, boolean create) {
- //
- // DTDNotation aNotation =
- // extEntity.getDTDEntity().getDTDFile().findNotation(name);
- // if (aNotation != null)
- // {
- // return aNotation;
- // }
- //
- //
- // //
- // // Create a notation for the reference
- // //
- // if (create)
- // {
- // aNotation = getFactory().createDTDNotation();
- // dtdFile.getDTDObject().add(aNotation);
- // aNotation.setName(name);
- // }
- // return aNotation;
- // }
- // /**
- // * The SystemID attribute is set to whatever the user enters
- // * e.g. com/ibm/b2b/xmimodels/xxx.dtd.xmi
- // *
- // * In the unparse() method, parse out the DTD file name from
- // * the classpath name.
- // * e.g. returns xxx.dtd
- // */
- // protected void updateSystemIDGen(DTDExternalEntity extEntity,
- // EntityDecl entityDecl) {
- //
- // String systemId = entityDecl.getSystemId();
- // String publicId = entityDecl.getPublicId();
- // if (systemId != null)
- // {
- // IdResolver idResolver = new IdResolverImpl(dtd.getName());
- // String uri = idResolver.resolveId(publicId, systemId);
- // ExternalDTDModel ed = dtdUtil.getExternalDTDModel(resources, uri);
- // if (ed != null)
- // {
- // DTDFile referenceDtdFile = ed.getExternalDTDFile();
- // extEntity.setEntityReferencedFromAnotherFile(referenceDtdFile);
- // extEntity.setSystemID(systemId);
- // }
- // else
- // {
- // if (entityDecl.getErrorMessage() == null)
- // {
- // ErrorMessage dtdError = new ErrorMessage();
- // dtdError.setErrorMessage(DTDCoreMessages.getString("_ERROR_INCL_FILE_LOAD_FAILURE")
- // + " '" + systemId + "'");
- // addErrorMessage(dtdError, extEntity.getDTDEntity());
- // }
- //
- // if (systemId != null)
- // {
- // extEntity.setSystemID(systemId);
- // }
- // else
- // {
- // extEntity.setSystemID("");
- // }
- // }
- // } // end of if ()
- // else
- // {
- // // set the system id to be ""
- // extEntity.setSystemID("");
- // }
- // }
- // /**
- // * @generated
- // */
- // protected DTDEntity createDTDEntityGen(EntityDecl entity) {
- //
- // // create and do what we can to fill in some basic things
- // DTDEntity dtdEntity = getFactory().createDTDEntity();
- // dtdFile.getDTDObject().add(dtdEntity);
- //
- //
- // dtdEntity.setName(entity.getNodeName());
- // dtdEntity.setParameterEntity(entity.isParameter());
- // if (entity.getComment()!=null)
- // {
- // dtdEntity.setComment(entity.getComment());
- // }
- // if (entity.getErrorMessage()!=null)
- // {
- // addErrorMessage(entity.getErrorMessage(), dtdEntity);
- // }
- //
- //
- // return dtdEntity;
- // }
- // /**
- // * @generated
- // */
- // protected void finishElementDeclGen(DTDElement dtdElement, ElementDecl
- // ed) {
- //
- // dtdElement.setName(ed.getNodeName());
- //
- //
- // CMNode cmNode = ed.getContentModelNode();
- //
- //
- // if (ed.getComment()!=null)
- // {
- // dtdElement.setComment(ed.getComment());
- // }
- // if (ed.getErrorMessage()!=null)
- // {
- // addErrorMessage(ed.getErrorMessage(), dtdElement);
- // }
- //
- //
- // if (cmNode instanceof CMBasicNode)
- // {
- // CMBasicNode bn = (CMBasicNode)cmNode;
- // switch (bn.getType())
- // {
- // case CMNodeType.EMPTY :
- // DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- // dtdElement.setContent(emptyContent);
- // break;
- //
- //
- // case CMNodeType.ANY :
- // DTDAnyContent anyContent = getFactory().createDTDAnyContent();
- // dtdElement.setContent(anyContent);
- // break;
- //
- //
- // case CMNodeType.PCDATA:
- // DTDPCDataContent pcData = getFactory().createDTDPCDataContent();
- // dtdElement.setContent(pcData);
- // }
- //
- //
- // }
- // else if (cmNode instanceof CMReferenceNode)
- // {
- // CMReferenceNode rn = (CMReferenceNode) cmNode;
- // if (rn.getType() == CMNodeType.ENTITY_REFERENCE)
- // {
- // String entityName = rn.getName().trim();
- //
- //
- // DTDEntity anEntity = (DTDEntity) dtdUtil.getPEPool().get(entityName);
- // if (anEntity!=null)
- // {
- // //
- // // Create an DTDEntityReference and set its referenced element
- // //
- // DTDEntityReferenceContent enRef =
- // getFactory().createDTDEntityReferenceContent();
- // enRef.setElementReferencedEntity(anEntity);
- //
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(rn));
- // enRef.setOccurrence(occurrenceType);
- //
- // dtdElement.setContent(enRef);
- // }
- // else
- // { // create default content
- // DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- // dtdElement.setContent(emptyContent);
- // }
- // }
- // else
- // {
- // //
- // // Find the real element for this element references
- // // If the real element does not yet exist, create it
- // //
- // DTDElement anElement = createOrFindElement(rn.getName(), dtdElement);
- //
- //
- // //
- // // Create an DTDElementReference and set its referenced element
- // //
- // DTDElementReferenceContent elemRef =
- // getFactory().createDTDElementReferenceContent();
- // elemRef.setReferencedElement(anElement);
- //
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(rn));
- // elemRef.setOccurrence(occurrenceType);
- //
- // // setContent to DTDElementReference
- // dtdElement.setContent(elemRef);
- //
- //
- // }
- // }
- // else if (cmNode instanceof CMGroupNode)
- // {
- // CMGroupNode grpNode = (CMGroupNode)cmNode;
- // DTDGroupContent groupContent = getFactory().createDTDGroupContent();
- // DTDGroupKind groupKind =
- // DTDGroupKind.get(computeMofGroupKind(grpNode.getGroupKind()));
- // groupContent.setGroupKind(groupKind);
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(grpNode));
- // groupContent.setOccurrence(occurrenceType);
- //
- // // just use the locator for the element as the closest guess
- // processGroupContent(groupContent, grpNode);
- // dtdElement.setContent(groupContent);
- // }
- // else if (cmNode == null)
- // {
- // // bad thing happened here, just create a pcdata
- // DTDEmptyContent emptyContent = getFactory().createDTDEmptyContent();
- // dtdElement.setContent(emptyContent);
- // }
- // }
- // /**
- // * Add a new group to the current group
- // * @param parent - the parent node for this group element
- // * @param op1Node - the group
- // * e.g. (a,b)
- // * @param op2Node - set only if called by processCM1op
- // * e.g. (a,b)+
- // */
- // protected void processGroupContentGen(DTDGroupContent parent,
- // CMGroupNode grpNode) {
- //
- // Enumeration children = grpNode.getChildren().elements();
- // DTDFactory factory = getFactory();
- // while (children.hasMoreElements())
- // {
- // CMNode cnode = (CMNode) children.nextElement();
- //
- //
- // if (cnode instanceof CMGroupNode)
- // {
- // CMGroupNode gNode = (CMGroupNode)cnode;
- // DTDGroupContent groupContent = factory.createDTDGroupContent();
- // DTDGroupKind groupKind =
- // DTDGroupKind.get(computeMofGroupKind(gNode.getGroupKind()));
- // groupContent.setGroupKind(groupKind);
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(gNode));
- // groupContent.setOccurrence(occurrenceType);
- //
- // parent.getContent().add(groupContent);
- // processGroupContent(groupContent,gNode);
- // }
- // else if (cnode instanceof CMBasicNode)
- // {
- // CMBasicNode n = (CMBasicNode)cnode;
- // if (n.getType() == CMNodeType.PCDATA)
- // {
- // // Create a DTDPCDataContent for a leaf PCData node
- // //
- // DTDPCDataContent pcData = factory.createDTDPCDataContent();
- // // Add #PCDATA to the Group, i.e Mixed content model
- // parent.getContent().add(pcData);
- // }
- // }
- // else if (cnode instanceof CMReferenceNode)
- // {
- // CMReferenceNode rn = (CMReferenceNode)cnode;
- // if (rn.getType()==CMNodeType.ELEMENT_REFERENCE)
- // {
- // // System.out.println("CM Element Ref name: " + rn.getName());
- // //
- // // Create an DTDElementReference and set its referenced element
- // //
- // DTDElementReferenceContent elemRef =
- // factory.createDTDElementReferenceContent();
- //
- //
- // //
- // // Find the real element for this element references
- // // If the real element does not yet exist, create it
- // //
- // DTDElement anElement = createOrFindElement(rn.getName(), elemRef);
- //
- //
- // elemRef.setReferencedElement(anElement);
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(rn));
- // elemRef.setOccurrence(occurrenceType);
- //
- // // Add DTDElementReference to the Group
- // parent.getContent().add(elemRef);
- // }
- // else // PE Reference
- // {
- // String entityName = rn.getName().trim();
- //
- //
- // // System.out.println("CM PE Ref name: " + entityName);
- // DTDEntity anEntity = (DTDEntity) dtdUtil.getPEPool().get(entityName);
- // if (anEntity!=null)
- // {
- // //
- // // Create an DTDEntityReference and set its referenced element
- // //
- // DTDEntityReferenceContent enRef =
- // factory.createDTDEntityReferenceContent();
- // enRef.setElementReferencedEntity(anEntity);
- //
- // DTDOccurrenceType occurrenceType =
- // DTDOccurrenceType.get(computeMofOccurrence(rn));
- // enRef.setOccurrence(occurrenceType);
- //
- //
- // // Add DTDEntityReference to the Group
- // parent.getContent().add(enRef);
- //
- //
- // }
- // }
- // }
- // }
- // }
- // /**
- // * Find the real element that is referenced by the current element
- // */
- // protected DTDElement createOrFindElementGen(String name, Object obj) {
- //
- // // DTDElement aElement = getDTDFile().findElement(name);
- //
- //
- // DTDElement aElement = (DTDElement) dtdUtil.getElementPool().get(name);
- //
- //
- // if (aElement != null)
- // {
- // return aElement;
- // }
- //
- //
- // String errorMsg =
- // DTDCoreMessages.getString("_ERROR_UNDECLARED_ELEMENT_1");
- // errorMsg += "\"" + name + "\"";
- // errorMsg +=
- // DTDCoreMessages.getString("_UI_ERRORPART_UNDECLARED_ELEMENT_2");
- //
- //
- // ErrorMessage dtdError = new ErrorMessage();
- //
- // dtdError.setErrorMessage(errorMsg);
- // addErrorMessage(dtdError, obj);
- // // System.out.println(errorMsg);
- // // setDTDErrorMessage(errorMsg);
- // getDTDFile().setParseError(true);
- //
- //
- // //
- // // Create an empty element for the reference to make it valid
- // //
- //
- //
- // DTDFactory factory = getFactory();
- // DTDElement dtdelement = factory.createDTDElement();
- // dtdelement.setName(name);
- //
- //
- // DTDEmptyContent emptyContent = factory.createDTDEmptyContent();
- // dtdelement.setContent(emptyContent);
- //
- //
- // getDTDFile().getDTDObject().add(dtdelement);
- // dtdUtil.getElementPool().put(name,dtdelement);
- // return dtdelement;
- // }
- // /**
- // * Compute the MOF occurrence from the xml4j occurrence
- // */
- // protected int computeMofOccurrenceGen(CMRepeatableNode rnode) {
- //
- // int occurrence = rnode.getOccurrence();
- // int mofoccur = DTDOccurrenceType.ONE;
- //
- //
- // if (occurrence == CMNodeType.ZERO_OR_MORE)
- // {
- // mofoccur = DTDOccurrenceType.ZERO_OR_MORE;
- // }
- // else if (occurrence == CMNodeType.ONE_OR_MORE)
- // {
- // mofoccur = DTDOccurrenceType.ONE_OR_MORE;
- // }
- // else if (occurrence == CMNodeType.OPTIONAL)
- // {
- // mofoccur = DTDOccurrenceType.OPTIONAL;
- // }
- // return mofoccur;
- // }
- // /**
- // * Compute the MOF model group from the xml4j model group
- // */
- // protected int computeMofGroupKindGen(int type) {
- //
- // if (type == CMNodeType.GROUP_CHOICE)
- // {
- // return DTDGroupKind.CHOICE;
- // }
- // else
- // {
- // return DTDGroupKind.SEQUENCE;
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void createAttributesGen(DTDElement element, Attlist attList)
- // {
- //
- // if (attList.getErrorMessage()!=null)
- // {
- // addErrorMessage(attList.getErrorMessage(), element);
- // }
- //
- //
- // for (int i=0;i<attList.size();i++)
- // {
- // AttNode ad = (AttNode) attList.elementAt(i);
- // // DTDAttributeElement dtdAtt= getDTDAttributeElement(a.getName());
- //
- //
- // // only add the AttDef if it is not added yet
- // // ignore the dup AttDef as documented in the XML 1.0 specs
- // //if( dtdAtt==null)
- // addAttribute(element, ad);
- // }
- // }
- // /**
- // * Create a DTDAttribute from the xml4j attribute
- // */
- // protected void addAttributeGen(DTDElement dtdelement, AttNode ad) {
- //
- // DTDAttribute dtdattr = getFactory().createDTDAttribute();
- // dtdelement.getDTDAttribute().add(dtdattr);
- // finishAttribute(dtdattr, ad);
- // }
- // /**
- // * @generated
- // */
- // protected void finishAttributeGen(DTDAttribute dtdattr, AttNode attdef)
- // {
- //
- // boolean parseError = false;
- //
- //
- // if (attdef.name.startsWith("%"))
- // {
- // String peName = attdef.name.trim();
- // DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
- // if (en!=null)
- // {
- // dtdattr.setAttributeNameReferencedEntity(en);
- // }
- // }
- //
- //
- // dtdattr.setName(attdef.name);
- //
- //
- // int attrType = attdef.getDeclaredType();
- //
- //
- // if (attrType==AttNode.PEREFERENCE && attdef.type!=null)
- // {
- // String peName = attdef.type.trim();
- // DTDEntity en = (DTDEntity) dtdUtil.getPEPool().get(peName);
- // if (en!=null)
- // {
- // dtdattr.setAttributeTypeReferencedEntity(en);
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA()); // hack,
- // so we can get back the default value
- // }
- // else //set default type
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
- //
- //
- // }
- // else
- // {
- // switch (attrType)
- // {
- // case AttNode.CDATA:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_CDATA());
- // break;
- //
- //
- // case AttNode.ENTITIES:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITIES());
- // break;
- //
- //
- // case AttNode.ENTITY:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ENTITY());
- // break;
- //
- //
- // case AttNode.ID:
- // // check for duplicate ID attribute
- // if (hasIDAttribute(dtdattr))
- // {
- // String errMsg = DTDCoreMessages.getString("_ERROR_DUP_ID_ATTRIBUTE_1");
- // errMsg += attdef.name +
- // DTDCoreMessages.getString("_UI_ERRORPART_DUP_ID_ATTRIBUTE_2");
- // // dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
- // // dtdattr.getDTDElement().getDTDFile().setParseError(true);
- // parseError = true;
- // }
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_ID());
- // break;
- //
- //
- // case AttNode.IDREF:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREF());
- // break;
- //
- //
- // case AttNode.IDREFS:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_IDREFS());
- // break;
- //
- //
- // case AttNode.ENUMERATION:
- // setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef,
- // DTDEnumGroupKind.NAME_TOKEN_GROUP));
- // break;
- //
- //
- // case AttNode.NOTATION:
- // setAttrDTDType(dtdattr, createDTDEnumeration(dtdattr, attdef,
- // DTDEnumGroupKind.NOTATION_GROUP));
- // break;
- //
- //
- // case AttNode.NMTOKEN:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKEN());
- // break;
- //
- //
- // case AttNode.NMTOKENS:
- // setAttrDTDType(dtdattr, getFactory().getDTDBasicType_NMTOKENS());
- // break;
- //
- //
- // default:
- // // System.out.println("DTDATTR '" +attdef.name + "'Unknown type..." +
- // attrType);
- // }
- // }
- //
- //
- // int attrDefault = attdef.getDefaultType();
- // int defaultKind = DTDDefaultKind.IMPLIED;
- // switch (attrDefault)
- // {
- // case AttNode.FIXED:
- // defaultKind = DTDDefaultKind.FIXED;
- // break;
- //
- //
- // case AttNode.IMPLIED:
- // defaultKind = DTDDefaultKind.IMPLIED;
- // break;
- //
- //
- // case AttNode.REQUIRED:
- // defaultKind = DTDDefaultKind.REQUIRED;
- // break;
- //
- //
- // case AttNode.NOFIXED:
- // defaultKind = DTDDefaultKind.NOFIXED;
- // break;
- //
- //
- // default:
- // // System.out.println("DTDATTR '" +attdef.name + "' Unknown default
- // type... " + attrDefault);
- // }
- //
- // DTDDefaultKind defaultKindObj = DTDDefaultKind.get(defaultKind);
- // dtdattr.setDefaultKind(defaultKindObj);
- //
- // if (parseError)
- // {
- // return;
- // }
- //
- //
- // String defaultValue = attdef.defaultValue;
- // if (defaultValue != null)
- // {
- // if (attrType == AttNode.ENUMERATION || attrType == AttNode.NOTATION)
- // {
- // if (! isDefaultEnumValueValid(attdef,defaultValue))
- // {
- // String typeString =
- // (attrType==AttNode.ENUMERATION?"enumeration":"notation");
- // String errMsg =
- // DTDCoreMessages.getString("_ERROR_INVALID_DEFAULT_ATTR_VALUE_1");
- // errMsg += typeString +
- // DTDCoreMessages.getString("_UI_ERRORPART_INVALID_DEFAULT_ATTR_VALUE_2");
- // errMsg += attdef.name + "'";
- //
- //
- // // dtdattr.getDTDElement().getIElement().setDTDErrorMessage(errMsg);
- // // dtdattr.getDTDElement().getDTDFile().setParseError(true);
- // return;
- // }
- // }
- // dtdattr.setDefaultValueString(defaultValue);
- // }
- // // System.out.println("DTDAttr - toMof getDefaultValueString " +
- // getDefaultValueString());
- // // System.out.println("DTDAttr - toMof getDefaultValue: " +
- // getDefaultValue());
- // }
- // /**
- // * @generated
- // */
- // protected boolean hasIDAttributeGen(DTDAttribute dtdattr) {
- //
- // boolean hasID = false;
- //
- //
- // DTDElement element = dtdattr.getDTDElement();
- // EList attrs = element.getDTDAttribute();
- //
- //
- // Iterator i = attrs.iterator();
- // while (i.hasNext())
- // {
- // DTDAttribute attr = (DTDAttribute) i.next();
- // DTDType dType = attr.getDTDType();
- // if (dType instanceof DTDBasicType)
- // {
- // if ( ((DTDBasicType)dType).getKind().getValue() == DTDBasicTypeKind.ID)
- // {
- // hasID = true;
- // break;
- // }
- // }
- // }
- // return hasID;
- // }
- // /**
- // * @generated
- // */
- // protected DTDEnumerationType createDTDEnumerationGen(DTDAttribute
- // dtdattr, String[] enumValues, int enumKind) {
- //
- // DTDEnumerationType enum = getFactory().createDTDEnumerationType();
- // // This is gross, but this is what was done before.
- // DTDAttributeImpl dtdattrimpl = (DTDAttributeImpl) dtdattr;
- // // enum.setID("Enum_" +
- // ((DTDElement)dtdattrimpl.getMOFDomain()).getName() + "_" +
- // dtdattr.getName());
- // DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
- // enum.setKind(groupKind);
- // // Enumeration values
- // if (enumValues!=null)
- // {
- // for(int i=0;i<enumValues.length;i++)
- // {
- // EEnumLiteral enumLiteral = createEEnumLiteral();
- // // enumVal.setXMIDocument(dtdattr.getXMIDocument());
- // enumLiteral.refSetLiteral(enumValues[i]);
- // // enumLiteral.setNumber(i);
- // enum.getEnumLiterals().add(enumLiteral);
- // }
- // }
- // dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enum);
- // return enum;
- // }
- // /**
- // * @generated
- // */
- // protected EEnumLiteral createEEnumLiteralGen() {
- //
- // EcorePackage ePackage =
- // (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);
- // return ((EcoreFactory)ePackage.getFactory()).createEEnumLiteral();
- // }
- // /**
- // * @generated
- // */
- // protected DTDEnumerationType createDTDEnumerationGen(DTDAttribute
- // dtdattr, AttNode attdef, int enumKind) {
- //
- // DTDEnumerationType enum = getFactory().createDTDEnumerationType();
- // // This is gross, but this is what was done before.
- // DTDAttributeImpl dtdattrimpl = (DTDAttributeImpl) dtdattr;
- // // enum.setID("Enum_" +
- // ((DTDElement)dtdattrimpl.getMOFDomain()).getName() + "_" +
- // dtdattr.getName());
- // DTDEnumGroupKind groupKind = DTDEnumGroupKind.get(enumKind);
- // enum.setKind(groupKind);
- // dtdattr.getDTDElement().getDTDFile().getDTDEnumerationType().add(enum);
- //
- //
- // // Enumeration values
- // Enumeration tokenIter = attdef.elements();
- // if (tokenIter != null) {
- // int i=0;
- // while (tokenIter.hasMoreElements())
- // {
- // String val = (String)tokenIter.nextElement();
- // EEnumLiteral enumLiteral = createEEnumLiteral();
- // // enumLiteral.setXMIDocument(dtdattr.getXMIDocument());
- //
- //
- // enumLiteral.refSetLiteral(val);
- // // enumLiteral.setNumber(i++);
- // enum.getEnumLiterals().add(enumLiteral);
- // }
- // }
- //
- //
- // return enum;
- // }
- // /**
- // * @generated
- // */
- // protected boolean isDefaultEnumValueValidGen(AttNode attdef, String
- // defaultValue) {
- //
- // boolean valid = false;
- // boolean containsPercent = false;
- //
- //
- // // Enumeration values
- // Enumeration enumValues = attdef.elements();
- // while (enumValues.hasMoreElements())
- // {
- // String val = (String)enumValues.nextElement();
- // if (val.equals(defaultValue))
- // {
- // valid = true;
- // break;
- // }
- // if (val.indexOf('%') >= 0)
- // {
- // containsPercent = true;
- // }
- // }
- // return valid || containsPercent;
- // }
- // /**
- // * @generated
- // */
- // protected void setAttrDTDTypeGen(DTDAttribute dtdattr, DTDType type) {
- //
- // dtdattr.setDTDType(type);
- // }
- // /**
- // * @generated
- // */
- // protected void addErrorMessageGen(ErrorMessage errMsg, Object obj) {
- //
- // errMsg.setObject(obj);
- // dtdUtil.addErrorMessage(errMsg);
- // }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDObjectFinder.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDObjectFinder.java
deleted file mode 100644
index f7b36b88c2..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDObjectFinder.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDObject;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDSourceOffset;
-
-public class DTDObjectFinder extends DTDVisitor {
- public class SourceOffset {
- // Convenience class to find containment of object
- private int start, end;
-
- public SourceOffset(int start, int end) {
- this.start = start;
- this.end = end;
- }
-
- public boolean contains(SourceOffset other) {
- if (this.start <= other.start && other.start <= this.end) {
- return true;
- } // end of if ()
- return false;
- }
-
- }
-
- SourceOffset searchLocation;
-
- private SourceOffset offsetObjectFor(DTDSourceOffset s) {
- return new SourceOffset(s.getStartOffset(), s.getEndOffset());
- }
-
- private void checkContainment(DTDObject o) {
- if (offsetObjectFor((DTDSourceOffset) o).contains(searchLocation)) {
- closestObject = o;
- } // end of if ()
- }
-
- public DTDObjectFinder(int startOffset, int endOffset) {
- searchLocation = new SourceOffset(startOffset, endOffset);
- }
-
- public void visitDTDNotation(DTDNotation notation) {
- checkContainment(notation);
- super.visitDTDNotation(notation);
- }
-
- public void visitDTDEntity(DTDEntity entity) {
- checkContainment(entity);
- super.visitDTDEntity(entity);
- }
-
- public void visitDTDElement(DTDElement element) {
- checkContainment(element);
- super.visitDTDElement(element);
- }
-
- public void visitDTDAttribute(DTDAttribute attribute) {
- checkContainment(attribute);
- super.visitDTDAttribute(attribute);
- }
-
- public void visitDTDParameterEntityReference(DTDParameterEntityReference parmEntity) {
- checkContainment(parmEntity);
- super.visitDTDParameterEntityReference(parmEntity);
- }
-
- public void visitDTDElementContent(DTDElementContent content) {
- checkContainment(content);
- super.visitDTDElementContent(content);
- }
-
- private DTDObject closestObject = null;
-
- public DTDObject getClosestObject() {
- return closestObject;
- }
-
- /**
- * @generated
- */
- protected SourceOffset offsetObjectForGen(DTDSourceOffset s) {
-
- return new SourceOffset(s.getStartOffset(), s.getEndOffset());
- }
-
- /**
- * @generated
- */
- protected void checkContainmentGen(DTDObject o) {
-
- if (offsetObjectFor((DTDSourceOffset) o).contains(searchLocation)) {
- closestObject = o;
- } // end of if ()
- }
-
- /**
- * @generated
- */
- protected void visitDTDNotationGen(DTDNotation notation) {
-
- checkContainment(notation);
- super.visitDTDNotation(notation);
- }
-
- /**
- * @generated
- */
- protected void visitDTDEntityGen(DTDEntity entity) {
-
- checkContainment(entity);
- super.visitDTDEntity(entity);
- }
-
- /**
- * @generated
- */
- protected void visitDTDElementGen(DTDElement element) {
-
- checkContainment(element);
- super.visitDTDElement(element);
- }
-
- /**
- * @generated
- */
- protected void visitDTDAttributeGen(DTDAttribute attribute) {
-
- checkContainment(attribute);
- super.visitDTDAttribute(attribute);
- }
-
- /**
- * @generated
- */
- protected void visitDTDParameterEntityReferenceGen(DTDParameterEntityReference parmEntity) {
-
- checkContainment(parmEntity);
- super.visitDTDParameterEntityReference(parmEntity);
- }
-
- /**
- * @generated
- */
- protected void visitDTDElementContentGen(DTDElementContent content) {
-
- checkContainment(content);
- super.visitDTDElementContent(content);
- }
-
- /**
- * @generated
- */
- protected DTDObject getClosestObjectGen() {
-
- return closestObject;
- }
-}// DTDObjectFinder
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPathnameUtil.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPathnameUtil.java
deleted file mode 100644
index 05abd2d8df..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPathnameUtil.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-
-
-public class DTDPathnameUtil {
- static public String makePath(String parentPath, String type, String name, int cnt) {
- String pn = null;
- name = encode(name);
- if ((name == null) && (cnt <= 0)) {
- pn = type;
- }
- else if (cnt <= 0) {
- pn = type + ":" + ((name == null) ? "" : name); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- pn = type + ":" + ((name == null) ? "" : name) + ":" + cnt; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- if (parentPath != null) {
- return parentPath + "." + pn; //$NON-NLS-1$
- }
- else {
- return pn;
- }
- }
-
- static public Object[] parsePathComponent(String path) {
- /*
- * This routine parse the first component of the path and returns the
- * result in an arrray of Strings. result[0] = type (String) result[1] =
- * name (String) result[2] = count (Integer) result[3] = the rest of
- * the path (String)
- *
- * E.g. PathComponent result[0] result[1] result[2] result[3]
- * ------------------------------------------------------------- type
- * type <null> <null> <null> type.rest type <null> <null> rest
- * type:name type name <null> <null> type:name.rest type name <null>
- * rest type::n type <null> n <null> type::n.rest type <null> n rest
- * type:name:n type name n <null> type:name:n.rest type name n rest
- */
-
- Object[] result = new Object[4];
- if (path == null)
- return result;
-
- int i = path.indexOf('.');
- int length = path.length();
-
- if (i < 0) {
- i = length;
- }
-
- String type = null;
- String name = null;
- Integer n = null;
- String rest = null;
-
- // get the type
- int j = path.indexOf(':');
- if (j > i)
- j = -1;
- if (j < 0) {
- type = path.substring(0, i);
- }
- else {
- type = path.substring(0, j);
-
- // get the name
- int k = path.indexOf(':', j + 1);
- if (k > i)
- k = -1;
- if (k < 0) {
- name = path.substring(j + 1, i);
- }
- else {
- name = path.substring(j + 1, k);
-
- // get the count
- try {
- n = new Integer(path.substring(k + 1, i));
- }
- catch (Exception exc) {
- }
- if ((n != null) && (n.intValue() < 0)) {
- n = null;
- }
- }
- }
-
- if ((name != null) && (name.length() == 0)) {
- name = null;
- }
-
- if (i < length) {
- rest = path.substring(i + 1);
- }
-
- result[0] = type;
- result[1] = decode(name);
- result[2] = n;
- result[3] = rest;
- return result;
- }
-
- static private String encode(String s) {
- if (s == null)
- return null;
- StringBuffer o = new StringBuffer(s.length());
- int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (Character.isLetterOrDigit(c) || (c == '-')) {
- o.append(c);
- }
- else { // if ((c == '.') || (c == ':') || (c == '_') || ...)
- // convert the character to a 4 digit hex code prefixed by "_"
- String hex = Integer.toHexString(c);
- int l = hex.length();
- if (l == 1) {
- o.append("_000"); //$NON-NLS-1$
- o.append(hex);
- }
- else if (l == 2) {
- o.append("_00"); //$NON-NLS-1$
- o.append(hex);
- }
- else if (l == 3) {
- o.append("_0"); //$NON-NLS-1$
- o.append(hex);
- }
- else {
- o.append('_');
- o.append(hex);
- }
- }
- } // for
- return o.toString();
- }
-
- static private String decode(String s) {
- if (s == null)
- return null;
- StringBuffer o = new StringBuffer(s.length());
- int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c != '_') {
- o.append(c);
- }
- else { // next 4 characters are the hex code
- String hex;
- if (len > i + 4) {
- hex = s.substring(i + 1, i + 5);
- i += 4;
- }
- else {
- hex = s.substring(i + 1);
- i = len - 1;
- }
- o.append((char) Integer.parseInt(hex, 16));
- }
- } // for
- return o.toString();
- }
-
- /**
- * @generated
- */
- protected static String makePathGen(String parentPath, String type, String name, int cnt) {
-
- String pn = null;
- name = encode(name);
- if ((name == null) && (cnt <= 0)) {
- pn = type;
- }
- else if (cnt <= 0) {
- pn = type + ":" + ((name == null) ? "" : name); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- pn = type + ":" + ((name == null) ? "" : name) + ":" + cnt; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- if (parentPath != null) {
- return parentPath + "." + pn; //$NON-NLS-1$
- }
- else {
- return pn;
- }
- }
-
- /**
- * @generated
- */
- protected static Object[] parsePathComponentGen(String path) {
-
- /*
- * This routine parse the first component of the path and returns the
- * result in an arrray of Strings. result[0] = type (String) result[1] =
- * name (String) result[2] = count (Integer) result[3] = the rest of
- * the path (String)
- *
- * E.g. PathComponent result[0] result[1] result[2] result[3]
- * ------------------------------------------------------------- type
- * type <null> <null> <null> type.rest type <null> <null> rest
- * type:name type name <null> <null> type:name.rest type name <null>
- * rest type::n type <null> n <null> type::n.rest type <null> n rest
- * type:name:n type name n <null> type:name:n.rest type name n rest
- */
-
- Object[] result = new Object[4];
- if (path == null)
- return result;
-
- int i = path.indexOf('.');
- int length = path.length();
-
- if (i < 0) {
- i = length;
- }
-
- String type = null;
- String name = null;
- Integer n = null;
- String rest = null;
-
- // get the type
- int j = path.indexOf(':');
- if (j > i)
- j = -1;
- if (j < 0) {
- type = path.substring(0, i);
- }
- else {
- type = path.substring(0, j);
-
- // get the name
- int k = path.indexOf(':', j + 1);
- if (k > i)
- k = -1;
- if (k < 0) {
- name = path.substring(j + 1, i);
- }
- else {
- name = path.substring(j + 1, k);
-
- // get the count
- try {
- n = new Integer(path.substring(k + 1, i));
- }
- catch (Exception exc) {
- }
- if ((n != null) && (n.intValue() < 0)) {
- n = null;
- }
- }
- }
-
- if ((name != null) && (name.length() == 0)) {
- name = null;
- }
-
- if (i < length) {
- rest = path.substring(i + 1);
- }
-
- result[0] = type;
- result[1] = decode(name);
- result[2] = n;
- result[3] = rest;
- return result;
- }
-
- /**
- * @generated
- */
- protected static String encodeGen(String s) {
-
- if (s == null)
- return null;
- StringBuffer o = new StringBuffer(s.length());
- int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (Character.isLetterOrDigit(c) || (c == '-')) {
- o.append(c);
- }
- else { // if ((c == '.') || (c == ':') || (c == '_') || ...)
- // convert the character to a 4 digit hex code prefixed by "_"
- String hex = Integer.toHexString(c);
- int l = hex.length();
- if (l == 1) {
- o.append("_000"); //$NON-NLS-1$
- o.append(hex);
- }
- else if (l == 2) {
- o.append("_00"); //$NON-NLS-1$
- o.append(hex);
- }
- else if (l == 3) {
- o.append("_0"); //$NON-NLS-1$
- o.append(hex);
- }
- else {
- o.append('_');
- o.append(hex);
- }
- }
- } // for
- return o.toString();
- }
-
- /**
- * @generated
- */
- protected static String decodeGen(String s) {
-
- if (s == null)
- return null;
- StringBuffer o = new StringBuffer(s.length());
- int len = s.length();
- for (int i = 0; i < len; i++) {
- char c = s.charAt(i);
- if (c != '_') {
- o.append(c);
- }
- else { // next 4 characters are the hex code
- String hex;
- if (len > i + 4) {
- hex = s.substring(i + 1, i + 5);
- i += 4;
- }
- else {
- hex = s.substring(i + 1);
- i = len - 1;
- }
- o.append((char) Integer.parseInt(hex, 16));
- }
- } // for
- return o.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPrinter.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPrinter.java
deleted file mode 100644
index 16f4fa6a3c..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDPrinter.java
+++ /dev/null
@@ -1,525 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDObject;
-import org.eclipse.wst.dtd.core.internal.emf.DTDOccurrenceType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDRepeatableContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDSourceOffset;
-
-
-public class DTDPrinter extends DTDVisitor {
- StringBuffer sb = new StringBuffer();
- boolean updateOffset = true;
-
- public DTDPrinter(boolean updateOffset) {
- this.updateOffset = updateOffset;
- }
-
- public StringBuffer getBuffer() {
- return sb;
- }
-
- public void visitDTDFile(DTDFile file) {
- super.visitDTDFile(file);
- }
-
- public void visitDTDNotation(DTDNotation notation) {
- generateComment(notation);
- updateStartOffset(notation, sb.length());
- sb.append("<!NOTATION "); //$NON-NLS-1$
- sb.append(notation.getName()).append(" "); //$NON-NLS-1$
-
- String publicID = notation.getPublicID();
- String systemID = notation.getSystemID();
- if (publicID == null || publicID.equals("")) { //$NON-NLS-1$
- sb.append("SYSTEM "); //$NON-NLS-1$
- }
- else {
- sb.append("PUBLIC \"").append(publicID).append("\" "); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- if (systemID == null) {
- sb.append("\"\""); //$NON-NLS-1$
- }
- else {
- sb.append("\"").append(systemID).append("\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
- endTag();
- updateEndOffset(notation, sb.length() - 1); // -1 for the newline char
- super.visitDTDNotation(notation);
- }
-
- public void visitDTDEntity(DTDEntity entity) {
- generateComment(entity);
- updateStartOffset(entity, sb.length());
- sb.append("<!ENTITY "); //$NON-NLS-1$
-
- if (entity.isParameterEntity())
- sb.append("% "); //$NON-NLS-1$
-
- sb.append(entity.getName()).append(" "); //$NON-NLS-1$
- sb.append(entity.getContent().unparse());
-
- endTag();
- updateEndOffset(entity, sb.length() - 1); // -1 for the newline char
- super.visitDTDEntity(entity);
- }
-
- public void visitDTDElement(DTDElement element) {
- generateComment(element);
- updateStartOffset(element, sb.length());
- sb.append("<!ELEMENT " + element.getName()); //$NON-NLS-1$
- DTDElementContent content = element.getContent();
- if (content instanceof DTDPCDataContent || content instanceof DTDElementReferenceContent) {
- sb.append(" ("); //$NON-NLS-1$
- super.visitDTDElement(element);
- sb.append(")"); //$NON-NLS-1$
- } // end of if ()
- else {
- sb.append(" "); //$NON-NLS-1$
- super.visitDTDElement(element);
- } // end of else
- endTag();
- updateEndOffset(element, sb.length() - 1); // -1 for the newline char
- visitAttributes(element);
- }
-
- public void visitDTDParameterEntityReference(DTDParameterEntityReference parmEntity) {
- generateComment(parmEntity);
- updateStartOffset(parmEntity, sb.length());
- sb.append("%" + parmEntity.getName() + ";\n"); //$NON-NLS-1$ //$NON-NLS-2$
- updateEndOffset(parmEntity, sb.length() - 1); // -1 for the newline
- // char
- }
-
- public void visitDTDElementContent(DTDElementContent content) {
- updateStartOffset(content, sb.length());
- String trailingChars = ""; //$NON-NLS-1$
- if (content instanceof DTDRepeatableContent) {
- DTDRepeatableContent repeatContent = (DTDRepeatableContent) content;
- DTDOccurrenceType occurrenceType = repeatContent.getOccurrence();
- // Integer occurrence = repeatContent.getOccurrence();
- if (occurrenceType != null) {
- int occurType = occurrenceType.getValue();
- if (occurType != DTDOccurrenceType.ONE) {
- if (repeatContent instanceof DTDEntityReferenceContent) {
- sb.append("("); //$NON-NLS-1$
- trailingChars = ")"; //$NON-NLS-1$
- }
- trailingChars += (char) occurType;
- }
- } // end of if ()
- } // end of if ()
-
- if (content instanceof DTDGroupContent) {
- super.visitDTDElementContent(content);
- } // end of if ()
- else if (content instanceof DTDElementReferenceContent || content instanceof DTDEntityReferenceContent) {
- sb.append(((DTDRepeatableContent) content).unparseRepeatableContent());
- } // end of if ()
- else {
- // handle DTDPCDataContent, DTDAnyContent and DTDEmptyContent here
- sb.append(content.getContentName());
- } // end of else
- sb.append(trailingChars);
- updateEndOffset(content, sb.length());
- }
-
- public void visitDTDGroupContent(DTDGroupContent group) {
- sb.append("("); //$NON-NLS-1$
- DTDGroupKind kind = group.getGroupKind();
- // MOF2EMF Port
- // Integer groupKind = group.getGroupKind();
- if (kind == null) {
- group.setGroupKind(DTDGroupKind.get(DTDGroupKind.SEQUENCE));
- } // end of if ()
-
- String con = group.getGroupKind().getValue() == DTDGroupKind.CHOICE ? " | " : ", "; //$NON-NLS-1$ //$NON-NLS-2$
-
- // Loop thru the children of the current group
- Collection content = group.getContent();
- if (content != null) {
- boolean firstContent = true;
- for (Iterator i = content.iterator(); i.hasNext();) {
- if (!firstContent) {
- sb.append(con);
- } // end of if ()
- else {
- firstContent = false;
- } // end of else
- visitDTDElementContent((DTDElementContent) i.next());
- }
- }
-
- sb.append(")"); //$NON-NLS-1$
- }
-
- private void visitAttributes(DTDElement elem) {
- Collection attrs = elem.getDTDAttribute();
- Iterator i = attrs.iterator();
- if (attrs != null && i.hasNext()) {
- DTDAttribute attrib = (DTDAttribute) i.next();
- String comment = attrib.getComment();
- if (comment != null && comment.length() > 0)
- sb.append("<!--\n ").append(comment).append("\n-->\n"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append("<!ATTLIST " + elem.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append(" "); //$NON-NLS-1$
- updateStartOffset(attrib, sb.length());
- sb.append(attrib.unparse());
- updateEndOffset(attrib, sb.length());
- sb.append("\n"); //$NON-NLS-1$
- for (; i.hasNext();) {
- attrib = (DTDAttribute) i.next();
- comment = attrib.getComment();
- if (comment != null && comment.length() > 0) {
- sb.append(">\n"); //$NON-NLS-1$
- if (comment != null && comment.length() > 0)
- sb.append("<!--\n ").append(comment).append("\n-->\n"); //$NON-NLS-1$ //$NON-NLS-2$
- sb.append("<!ATTLIST " + elem.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- sb.append(" "); //$NON-NLS-1$
- updateStartOffset(attrib, sb.length());
- sb.append(attrib.unparse());
- updateEndOffset(attrib, sb.length());
- sb.append("\n"); //$NON-NLS-1$
- }
- sb.append(">\n"); //$NON-NLS-1$
- }
- }
-
- private void endTag() {
- sb.append(">\n"); //$NON-NLS-1$
- }
-
- private void updateStartOffset(DTDSourceOffset o, int offset) {
- if (updateOffset) {
- o.setStartOffset(offset);
- } // end of if ()
- }
-
- private void updateEndOffset(DTDSourceOffset o, int offset) {
- if (updateOffset) {
- o.setEndOffset(offset);
- } // end of if ()
- }
-
- private void generateComment(DTDObject dtdObject) {
- String commentString = null;
-
- if (dtdObject instanceof DTDElement)
- commentString = ((DTDElement) dtdObject).getComment();
- else if (dtdObject instanceof DTDEntity)
- commentString = ((DTDEntity) dtdObject).getComment();
- else if (dtdObject instanceof DTDNotation)
- commentString = ((DTDNotation) dtdObject).getComment();
-
- if (commentString != null && commentString.length() > 0) {
- sb.append("<!--").append(commentString).append("-->\n"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
-
- // /**
- // * @generated
- // */
- // protected StringBuffer getBufferGen() {
- //
- // return sb;
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDFileGen(DTDFile file) {
- //
- // super.visitDTDFile(file);
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDNotationGen(DTDNotation notation) {
- //
- // generateComment(notation);
- // updateStartOffset(notation, sb.length());
- // sb.append("<!NOTATION ");
- // sb.append(notation.getName()).append(" ");
- //
- //
- // String publicID = notation.getPublicID();
- // String systemID = notation.getSystemID();
- // if (publicID == null || publicID.equals(""))
- // {
- // sb.append("SYSTEM ");
- // }
- // else
- // {
- // sb.append("PUBLIC \"").append(publicID).append("\" ");
- // }
- //
- //
- // if (systemID==null)
- // {
- // sb.append("\"\"");
- // }
- // else
- // {
- // sb.append("\"").append(systemID).append("\"");
- // }
- // endTag();
- // updateEndOffset(notation, sb.length() - 1); // -1 for the newline char
- // super.visitDTDNotation(notation);
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDEntityGen(DTDEntity entity) {
- //
- // generateComment(entity);
- // updateStartOffset(entity, sb.length());
- // sb.append("<!ENTITY ");
- //
- //
- // if (entity.isParameterEntity())
- // sb.append("% ");
- //
- //
- // sb.append(entity.getName()).append(" ");
- // sb.append(entity.getContent().unparse());
- //
- //
- // endTag();
- // updateEndOffset(entity, sb.length() - 1); // -1 for the newline char
- // super.visitDTDEntity(entity);
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDElementGen(DTDElement element) {
- //
- // generateComment(element);
- // updateStartOffset(element, sb.length());
- // sb.append("<!ELEMENT " + element.getName());
- // DTDElementContent content = element.getContent();
- // if (content instanceof DTDPCDataContent ||
- // content instanceof DTDElementReferenceContent)
- // {
- // sb.append(" (");
- // super.visitDTDElement(element);
- // sb.append(")");
- // } // end of if ()
- // else
- // {
- // sb.append(" ");
- // super.visitDTDElement(element);
- // } // end of else
- // endTag();
- // updateEndOffset(element, sb.length() - 1); // -1 for the newline char
- // visitAttributes(element);
- // }
- // /**
- // * @generated
- // */
- // protected void
- // visitDTDParameterEntityReferenceGen(DTDParameterEntityReference
- // parmEntity) {
- //
- // generateComment(parmEntity);
- // updateStartOffset(parmEntity, sb.length());
- // sb.append("%" + parmEntity.getName() + ";\n");
- // updateEndOffset(parmEntity, sb.length() - 1); // -1 for the newline
- // char
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDElementContentGen(DTDElementContent content) {
- //
- // updateStartOffset(content, sb.length());
- // String trailingChars = "";
- // if (content instanceof DTDRepeatableContent )
- // {
- // DTDRepeatableContent repeatContent = (DTDRepeatableContent) content;
- // Integer occurrence = repeatContent.getOccurrence();
- // if (occurrence != null)
- // {
- // int occurType = occurrence.intValue();
- // if (occurType != DTDOccurrenceType.ONE)
- // {
- // if (repeatContent instanceof DTDEntityReferenceContent)
- // {
- // sb.append("(");
- // trailingChars = ")";
- // }
- // trailingChars += (char) occurType;
- // }
- // } // end of if ()
- // } // end of if ()
- //
- // if (content instanceof DTDGroupContent)
- // {
- // super.visitDTDElementContent(content);
- // } // end of if ()
- // else if (content instanceof DTDElementReferenceContent ||
- // content instanceof DTDEntityReferenceContent)
- // {
- // sb.append(((DTDRepeatableContent)content).unparseRepeatableContent());
- // } // end of if ()
- // else
- // {
- // // handle DTDPCDataContent, DTDAnyContent and DTDEmptyContent here
- // sb.append(content.getContentName());
- // } // end of else
- // sb.append(trailingChars);
- // updateEndOffset(content, sb.length());
- // }
- // /**
- // * @generated
- // */
- // protected void visitDTDGroupContentGen(DTDGroupContent group) {
- //
- // sb.append("(");
- //
- // Integer groupKind = group.getGroupKind();
- // if (groupKind == null)
- // {
- // group.setGroupKind(DTDGroupKind.SEQUENCE);
- // } // end of if ()
- //
- // String con = group.getGroupKind().intValue() == DTDGroupKind.CHOICE ? "
- // | " : ", ";
- //
- //
- // // Loop thru the children of the current group
- // Collection content = group.getContent();
- // if (content != null)
- // {
- // boolean firstContent = true;
- // for (Iterator i = content.iterator(); i.hasNext(); )
- // {
- // if (!firstContent)
- // {
- // sb.append(con);
- // } // end of if ()
- // else
- // {
- // firstContent = false;
- // } // end of else
- // visitDTDElementContent((DTDElementContent) i.next());
- // }
- // }
- //
- //
- // sb.append(")");
- // }
- // /**
- // * @generated
- // */
- // protected void visitAttributesGen(DTDElement elem) {
- //
- // Collection attrs = elem.getDTDAttribute();
- // Iterator i = attrs.iterator();
- // if (attrs != null && i.hasNext())
- // {
- // DTDAttribute attrib = (DTDAttribute) i.next();
- // String comment = attrib.getComment();
- // if (comment!=null && comment.length()>0)
- // sb.append("<!--\n ").append(comment).append("\n-->\n");
- // sb.append("<!ATTLIST " + elem.getName() + "\n");
- // sb.append(" ");
- // updateStartOffset(attrib, sb.length());
- // sb.append(attrib.unparse());
- // updateEndOffset(attrib, sb.length());
- // sb.append("\n");
- // for (; i.hasNext(); )
- // {
- // attrib = (DTDAttribute) i.next();
- // comment = attrib.getComment();
- // if (comment!=null && comment.length()>0)
- // {
- // sb.append(">\n");
- // if (comment!=null && comment.length()>0)
- // sb.append("<!--\n ").append(comment).append("\n-->\n");
- // sb.append("<!ATTLIST " + elem.getName() + "\n");
- // }
- // sb.append(" ");
- // updateStartOffset(attrib, sb.length());
- // sb.append(attrib.unparse());
- // updateEndOffset(attrib, sb.length());
- // sb.append("\n");
- // }
- // sb.append(">\n");
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void endTagGen() {
- //
- // sb.append(">\n");
- // }
- // /**
- // * @generated
- // */
- // protected void updateStartOffsetGen(DTDSourceOffset o, int offset) {
- //
- // if (updateOffset)
- // {
- // o.setStartOffset(offset);
- // } // end of if ()
- // }
- // /**
- // * @generated
- // */
- // protected void updateEndOffsetGen(DTDSourceOffset o, int offset) {
- //
- // if (updateOffset)
- // {
- // o.setEndOffset(offset);
- // } // end of if ()
- // }
- // /**
- // * @generated
- // */
- // protected void generateCommentGen(DTDObject dtdObject) {
- //
- // String commentString = null;
- //
- //
- // if (dtdObject instanceof DTDElement)
- // commentString = ((DTDElement)dtdObject).getComment();
- // else if (dtdObject instanceof DTDEntity)
- // commentString = ((DTDEntity)dtdObject).getComment();
- // else if (dtdObject instanceof DTDNotation)
- // commentString = ((DTDNotation)dtdObject).getComment();
- //
- //
- // if ( commentString!=null && commentString.length()>0)
- // {
- // sb.append("<!--").append(commentString).append("-->\n");
- // }
- // }
-}// DTDPrinter
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceFactoryImpl.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceFactoryImpl.java
deleted file mode 100644
index 21e2aa76fc..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceFactoryImpl.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceFactoryImpl;
-
-
-public class DTDResourceFactoryImpl extends ResourceFactoryImpl {
- public DTDResourceFactoryImpl() {
- super();
- }
-
- public Resource createResource(String filename) {
- return new DTDResourceImpl(filename);
- }
-
- public Resource createResource(URI uri) {
- return new DTDResourceImpl(uri);
- }
-
- public Resource createResource(ResourceSet resources, URI uri) {
- Resource resource = new DTDResourceImpl(uri);
- resources.getResources().add(resource);
- return resource;
- }
-
- public Resource createResource(ResourceSet resources, String uri) {
- Resource resource = new DTDResourceImpl(uri);
- resources.getResources().add(resource);
- return resource;
- }
-
- public Resource load(String uri) throws Exception {
- Resource resource = createResource(uri);
- resource.load(new HashMap());
- return resource;
- }
-
- public Resource load(URI uri) throws Exception {
- Resource resource = createResource(uri);
- resource.load(new HashMap());
- return resource;
- }
-
- public Resource load(ResourceSet resources, String uri) throws Exception {
- return load(resources, uri, new HashMap());
- }
-
- public Resource load(ResourceSet resources, URI uri) throws Exception {
- return load(resources, uri, new HashMap());
- }
-
- public Resource load(ResourceSet resources, String uri, Map options) throws Exception {
- Resource resource = createResource(resources, uri);
- resource.load(options);
- return resource;
- }
-
- public Resource load(ResourceSet resources, URI uri, Map options) throws Exception {
- Resource resource = createResource(resources, uri);
- resource.load(options);
- return resource;
- }
-} // DTDResourceFactoryImpl
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceImpl.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceImpl.java
deleted file mode 100644
index 879da4435b..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDResourceImpl.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.io.OutputStream;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.zip.ZipOutputStream;
-
-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.resource.impl.ResourceImpl;
-import org.eclipse.wst.dtd.core.internal.DTDCoreMessages;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDObject;
-
-
-public class DTDResourceImpl extends ResourceImpl {
-
- public DTDResourceImpl() {
- super();
- }
-
- public DTDResourceImpl(String filename) {
- super(URI.createURI(filename));
- // System.out.println(">>>> DTDResourceImpl ctor 1");
- }
-
- public DTDResourceImpl(URI uri) {
- super(uri);
- // System.out.println(">>>> DTDResourceImpl ctor 2");
- }
-
- /**
- * Returns the resolved object for the given URI
- * {@link URI#fragment fragment}.
- * <p>
- * The fragment encoding will typically be that produced by
- * {@link #getURIFragment getURIFragment}.
- * </p>
- *
- * @param uriFragment
- * the fragment to resolve.
- * @return the resolved object for the given fragment.
- * @see #getURIFragment(EObject)
- * @see org.eclipse.emf.ecore.resource.ResourceSet#getEObject(URI, boolean)
- * @see org.eclipse.emf.ecore.util.EcoreUtil#resolve(EObject, org.eclipse.emf.ecore.resource.ResourceSet)
- * @see org.eclipse.emf.ecore.InternalEObject#eObjectForURIFragmentSegment(String)
- * @throws org.eclipse.emf.common.util.WrappedException
- * if a problem occurs navigating the fragment.
- */
- public EObject getEObject(java.lang.String uriFragment) {
- EList contents = getContents();
- if (contents != null) {
- Iterator i = contents.iterator();
- while (i.hasNext()) {
- Object obj = i.next();
- if (obj instanceof DTDFile) {
- // there should only be one DTDFile in a DTD extent
- EObject result = ((DTDFile) obj).findObject(uriFragment);
- return result;
- }
- }
- }
- System.out.println(">>> DTDKey Error: cannot find object " + uriFragment); //$NON-NLS-1$
- return super.getEObject(uriFragment);
- }
-
- /**
- * Returns the URI {@link URI#fragment fragment} that, when passed to
- * {@link #getEObject getEObject} will return the given object.
- * <p>
- * In other words, the following is <code>true</code> for any object
- * contained by a resource:
- *
- * <pre>
- *
- * Resource resource = eObject.eResource();
- * eObject == resource.getEObject(resource.getURIFragment(eObject))
- *
- * </pre>
- *
- * An implementation may choose to use IDs or to use structured URI
- * fragments, as supported by
- * {@link org.eclipse.emf.ecore.InternalEObject#eURIFragmentSegment eURIFragmentSegment}.
- * </p>
- *
- * @param eObject
- * the object to identify.
- * @return the URI {@link URI#fragment fragment} for the object.
- * @see #getEObject(String)
- * @see org.eclipse.emf.ecore.InternalEObject#eURIFragmentSegment(org.eclipse.emf.core.EStructuralFeature,
- * EObject)
- */
- public java.lang.String getURIFragment(EObject eObject) {
- if (eObject instanceof DTDObject) {
- return ((DTDObject) eObject).getPathname();
- }
- return super.getURIFragment(eObject);
- }
-
- private DTDUtil dtdUtil;
-
- public DTDUtil getDTDUtil() {
- return dtdUtil;
- }
-
- public void setDTDUtil(DTDUtil dtdUtil) {
- this.dtdUtil = dtdUtil;
- }
-
- public void load(Map options) {
-
- String uriString = getURI().toString();
- try {
- DTDUtil dtdUtil = new DTDUtil();
- dtdUtil.parse(getResourceSet(), uriString);
- dtdUtil.setResource(this);
- setDTDUtil(dtdUtil);
- getContents().add(dtdUtil.getDTDFile());
-
- // Reset the dirty flag after the resource is loaded
- setModified(false);
- }
- catch (Exception exc) {
- exc.printStackTrace();
- }
- }
-
- public void save(OutputStream os, Object options) throws Exception {
- if (contents != null) {
- Iterator i = contents.iterator();
- while (i.hasNext()) {
- Object obj = i.next();
- if (obj instanceof DTDFile) {
- try {
- DTDPrinter printer = new DTDPrinter(true);
- printer.visitDTDFile((DTDFile) obj);
-
- String s = printer.getBuffer().toString();
- os.write(s.getBytes());
- // Reset the dirty flag after the resource is saved
- setModified(false);
- }
- catch (Exception e) {
- }
- break;
- }
- }
- }
- }
-
- public void save(ZipOutputStream zos, String entry, String metaModelName) throws Exception {
- throw new Exception(DTDCoreMessages._EXC_OPERATION_NOT_SUPPORTED); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDSwitch.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDSwitch.java
deleted file mode 100644
index e77b1256f8..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDSwitch.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EDataType;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EModelElement;
-import org.eclipse.emf.ecore.ENamedElement;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.ecore.ETypedElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDBasicType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEnumerationType;
-import org.eclipse.wst.dtd.core.internal.emf.DTDExternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDInternalEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPackage;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDRepeatableContent;
-
-
-
-public class DTDSwitch {
- /**
- * The cached model package <!-- begin-user-doc --> <!-- end-user-doc -->
- *
- * @generated
- */
- protected static DTDPackage modelPackage;
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public DTDSwitch() {
- if (modelPackage == null) {
- modelPackage = DTDPackage.eINSTANCE;
- }
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object doSwitch(EObject theEObject) {
- EClass theEClass = theEObject.eClass();
- if (theEClass.eContainer() == modelPackage) {
- switch (theEClass.getClassifierID()) {
- case DTDPackage.DTD_GROUP_CONTENT : {
- DTDGroupContent dtdGroupContent = (DTDGroupContent) theEObject;
- Object result = caseDTDGroupContent(dtdGroupContent);
- if (result == null)
- result = caseDTDRepeatableContent(dtdGroupContent);
- if (result == null)
- result = caseDTDElementContent(dtdGroupContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ATTRIBUTE : {
- DTDAttribute dtdAttribute = (DTDAttribute) theEObject;
- Object result = caseDTDAttribute(dtdAttribute);
- if (result == null)
- result = caseEAttribute(dtdAttribute);
- if (result == null)
- result = caseEStructuralFeature(dtdAttribute);
- if (result == null)
- result = caseETypedElement(dtdAttribute);
- if (result == null)
- result = caseENamedElement(dtdAttribute);
- if (result == null)
- result = caseEModelElement(dtdAttribute);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ELEMENT : {
- DTDElement dtdElement = (DTDElement) theEObject;
- Object result = caseDTDElement(dtdElement);
- if (result == null)
- result = caseEClass(dtdElement);
- if (result == null)
- result = caseDTDContent(dtdElement);
- if (result == null)
- result = caseEClassifier(dtdElement);
- if (result == null)
- result = caseENamedElement(dtdElement);
- if (result == null)
- result = caseEModelElement(dtdElement);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_EMPTY_CONTENT : {
- DTDEmptyContent dtdEmptyContent = (DTDEmptyContent) theEObject;
- Object result = caseDTDEmptyContent(dtdEmptyContent);
- if (result == null)
- result = caseDTDElementContent(dtdEmptyContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ANY_CONTENT : {
- DTDAnyContent dtdAnyContent = (DTDAnyContent) theEObject;
- Object result = caseDTDAnyContent(dtdAnyContent);
- if (result == null)
- result = caseDTDElementContent(dtdAnyContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_PC_DATA_CONTENT : {
- DTDPCDataContent dtdpcDataContent = (DTDPCDataContent) theEObject;
- Object result = caseDTDPCDataContent(dtdpcDataContent);
- if (result == null)
- result = caseDTDElementContent(dtdpcDataContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ELEMENT_REFERENCE_CONTENT : {
- DTDElementReferenceContent dtdElementReferenceContent = (DTDElementReferenceContent) theEObject;
- Object result = caseDTDElementReferenceContent(dtdElementReferenceContent);
- if (result == null)
- result = caseDTDRepeatableContent(dtdElementReferenceContent);
- if (result == null)
- result = caseDTDElementContent(dtdElementReferenceContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_FILE : {
- DTDFile dtdFile = (DTDFile) theEObject;
- Object result = caseDTDFile(dtdFile);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_BASIC_TYPE : {
- DTDBasicType dtdBasicType = (DTDBasicType) theEObject;
- Object result = caseDTDBasicType(dtdBasicType);
- if (result == null)
- result = caseEClass(dtdBasicType);
- if (result == null)
- result = caseEClassifier(dtdBasicType);
- if (result == null)
- result = caseENamedElement(dtdBasicType);
- if (result == null)
- result = caseEModelElement(dtdBasicType);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ENUMERATION_TYPE : {
- DTDEnumerationType dtdEnumerationType = (DTDEnumerationType) theEObject;
- Object result = caseDTDEnumerationType(dtdEnumerationType);
- if (result == null)
- result = caseEEnum(dtdEnumerationType);
- if (result == null)
- result = caseEDataType(dtdEnumerationType);
- if (result == null)
- result = caseEClassifier(dtdEnumerationType);
- if (result == null)
- result = caseENamedElement(dtdEnumerationType);
- if (result == null)
- result = caseEModelElement(dtdEnumerationType);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_NOTATION : {
- DTDNotation dtdNotation = (DTDNotation) theEObject;
- Object result = caseDTDNotation(dtdNotation);
- if (result == null)
- result = caseDTDContent(dtdNotation);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ENTITY : {
- DTDEntity dtdEntity = (DTDEntity) theEObject;
- Object result = caseDTDEntity(dtdEntity);
- if (result == null)
- result = caseDTDContent(dtdEntity);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_EXTERNAL_ENTITY : {
- DTDExternalEntity dtdExternalEntity = (DTDExternalEntity) theEObject;
- Object result = caseDTDExternalEntity(dtdExternalEntity);
- if (result == null)
- result = caseDTDEntityContent(dtdExternalEntity);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_INTERNAL_ENTITY : {
- DTDInternalEntity dtdInternalEntity = (DTDInternalEntity) theEObject;
- Object result = caseDTDInternalEntity(dtdInternalEntity);
- if (result == null)
- result = caseDTDEntityContent(dtdInternalEntity);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_PARAMETER_ENTITY_REFERENCE : {
- DTDParameterEntityReference dtdParameterEntityReference = (DTDParameterEntityReference) theEObject;
- Object result = caseDTDParameterEntityReference(dtdParameterEntityReference);
- if (result == null)
- result = caseDTDContent(dtdParameterEntityReference);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- case DTDPackage.DTD_ENTITY_REFERENCE_CONTENT : {
- DTDEntityReferenceContent dtdEntityReferenceContent = (DTDEntityReferenceContent) theEObject;
- Object result = caseDTDEntityReferenceContent(dtdEntityReferenceContent);
- if (result == null)
- result = caseDTDRepeatableContent(dtdEntityReferenceContent);
- if (result == null)
- result = caseDTDElementContent(dtdEntityReferenceContent);
- if (result == null)
- result = defaultCase(theEObject);
- return result;
- }
- default :
- return defaultCase(theEObject);
- }
- }
- return defaultCase(theEObject);
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDFile(DTDFile object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDNotation(DTDNotation object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDContent(DTDContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDEntity(DTDEntity object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDEntityContent(DTDEntityContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDExternalEntity(DTDExternalEntity object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDInternalEntity(DTDInternalEntity object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDParameterEntityReference(DTDParameterEntityReference object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDEntityReferenceContent(DTDEntityReferenceContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDRepeatableContent(DTDRepeatableContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDElementReferenceContent(DTDElementReferenceContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDElement(DTDElement object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDElementContent(DTDElementContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDEmptyContent(DTDEmptyContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDAnyContent(DTDAnyContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDPCDataContent(DTDPCDataContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDGroupContent(DTDGroupContent object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDAttribute(DTDAttribute object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDEnumerationType(DTDEnumerationType object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseDTDBasicType(DTDBasicType object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- // +++++++++++++++++++GENERICRULES.JSED+++++++++++++++++++
- //
- // +++++++++++++++++++GENERICRULES.JSED+++++++++++++++++++
- // // public Object caseENamespace(ENamespace object) {
- // -------------------GENERICRULES.JSED-------------------
- // return null;
- // }
- // -------------------GENERICRULES.JSED-------------------
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEClass(EClass object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEAttribute(EAttribute object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEEnum(EEnum object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEModelElement(EModelElement object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseENamedElement(ENamedElement object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEStructuralFeature(EStructuralFeature object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEDataType(EDataType object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseETypedElement(ETypedElement object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object caseEClassifier(EClassifier object) {
- return null;
- }
-
- /**
- * @generated This field/method will be replaced during code generation.
- */
- // +++++++++++++++++++GENERICRULES.JSED+++++++++++++++++++
- //
- // +++++++++++++++++++GENERICRULES.JSED+++++++++++++++++++
- // // public Object caseInternalEClassifier(InternalEClassifier object) {
- // -------------------GENERICRULES.JSED-------------------
- // return null;
- // }
- // -------------------GENERICRULES.JSED-------------------
- /**
- * @generated This field/method will be replaced during code generation.
- */
- public Object defaultCase(EObject object) {
- return null;
- }
-
-} // DTDSwitch
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUniqueNameHelper.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUniqueNameHelper.java
deleted file mode 100644
index e12f6b3a71..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUniqueNameHelper.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-
-
-
-public class DTDUniqueNameHelper {
- public DTDUniqueNameHelper() {
-
- }
-
- static public String getUniqueElementName(DTDFile dtdFile) {
- List elements = dtdFile.listDTDElement();
- return getUniqueName(elements, "NewElement"); //$NON-NLS-1$
- }
-
- static public String getUniqueEntityName(DTDFile dtdFile) {
- List entities = dtdFile.listDTDEntity();
- return getUniqueName(entities, "NewEntity"); //$NON-NLS-1$
- }
-
- static public String getUniqueNotationName(DTDFile dtdFile) {
- List notations = dtdFile.listDTDNotation();
- return getUniqueName(notations, "NewNotation"); //$NON-NLS-1$
- }
-
- static public String getUniqueAttributeName(DTDElement element) {
- List attrs = element.getDTDAttribute();
- return getUniqueName(attrs, "NewAttribute"); //$NON-NLS-1$
- }
-
- static public String getUniqueName(List objs, String token) {
- int counter = 1;
-
- boolean uniqueName = false;
- while (!uniqueName) {
- String newName = token + new Integer(counter++);
- uniqueName = true;
- Iterator iter = objs.iterator();
- while (iter.hasNext()) {
- Object obj = iter.next();
- String objName = getName(obj);
- if (objName.equals(newName)) {
- uniqueName = false;
- break;
- }
- }
- if (uniqueName) {
- return newName;
- }
- }
- // we shouldn't get here
- return "No Name found"; //$NON-NLS-1$
- }
-
- static public String getName(Object obj) {
- if (obj instanceof DTDElement) {
- return ((DTDElement) obj).getName();
- }
- else if (obj instanceof DTDEntity) {
- return ((DTDEntity) obj).getName();
- }
- else if (obj instanceof DTDNotation) {
- return ((DTDNotation) obj).getName();
- }
- else if (obj instanceof DTDAttribute) {
- return ((DTDAttribute) obj).getName();
- }
- return ""; //$NON-NLS-1$
- }
-
-
- /**
- * @generated
- */
- protected static String getUniqueElementNameGen(DTDFile dtdFile) {
-
- List elements = dtdFile.listDTDElement();
- return getUniqueName(elements, "NewElement"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected static String getUniqueEntityNameGen(DTDFile dtdFile) {
-
- List entities = dtdFile.listDTDEntity();
- return getUniqueName(entities, "NewEntity"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected static String getUniqueNotationNameGen(DTDFile dtdFile) {
-
- List notations = dtdFile.listDTDNotation();
- return getUniqueName(notations, "NewNotation"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected static String getUniqueAttributeNameGen(DTDElement element) {
-
- List attrs = element.getDTDAttribute();
- return getUniqueName(attrs, "NewAttribute"); //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected static String getUniqueNameGen(List objs, String token) {
-
- int counter = 1;
-
- boolean uniqueName = false;
- while (!uniqueName) {
- String newName = token + new Integer(counter++);
- uniqueName = true;
- Iterator iter = objs.iterator();
- while (iter.hasNext()) {
- Object obj = iter.next();
- String objName = getName(obj);
- if (objName.equals(newName)) {
- uniqueName = false;
- break;
- }
- }
- if (uniqueName) {
- return newName;
- }
- }
- // we shouldn't get here
- return "No Name found"; //$NON-NLS-1$
- }
-
- /**
- * @generated
- */
- protected static String getNameGen(Object obj) {
-
- if (obj instanceof DTDElement) {
- return ((DTDElement) obj).getName();
- }
- else if (obj instanceof DTDEntity) {
- return ((DTDEntity) obj).getName();
- }
- else if (obj instanceof DTDNotation) {
- return ((DTDNotation) obj).getName();
- }
- else if (obj instanceof DTDAttribute) {
- return ((DTDAttribute) obj).getName();
- }
- return ""; //$NON-NLS-1$
- }
-}// DTDUniqueNameHelper
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUtil.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUtil.java
deleted file mode 100644
index cc0ab3889d..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDUtil.java
+++ /dev/null
@@ -1,1217 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.emf.common.util.BasicEList;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.wst.dtd.core.internal.emf.DTDConstants;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFactory;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDObject;
-import org.eclipse.wst.dtd.core.internal.emf.impl.DTDFactoryImpl;
-import org.eclipse.wst.dtd.core.internal.saxparser.DTD;
-import org.eclipse.wst.dtd.core.internal.saxparser.DTDParser;
-import org.eclipse.wst.dtd.core.internal.saxparser.ErrorMessage;
-
-/**
- * Create MOF objects from the parsed DTD If no DTD file is specifed, create
- * the root MOF object
- */
-public class DTDUtil {
- DTDFactory factory;
- EList extent;
- Resource resource;
- DTDFile dtdFile;
- String dtdModelFile;
- boolean expandEntityReferences;
-
- private Hashtable externalDTDModels = new Hashtable();
- private Hashtable pePool = new Hashtable();
- private Hashtable elementPool = new Hashtable();
-
- private DTDParser parser;
-
- private Vector errorMsgs = new Vector();
-
- private static Hashtable utilCache = new Hashtable();
-
- static public DTDUtil getDTDUtilFor(String filename) {
- DTDUtil util = (DTDUtil) utilCache.get(filename);
- if (util == null) {
- util = new DTDUtil();
- utilCache.put(filename, util);
- }
-
- return util;
- }
-
-
- public void parse(String uri) {
- parse(new ResourceSetImpl(), uri);
- }
-
- /**
- * Invoke parse to parse a .dtd file into a MOF object model This is
- * invoked by the RegisteredDTDParser that registers this parser for MOF
- * to use against the .dtd type
- *
- * @param filename -
- * the fully qualifed name of a .dtd file
- */
- public void parse(ResourceSet resources, String filename) {
- // Get the dtd name from the file name
- Path path = new Path(filename);
- IPath iPath = path.removeFileExtension();
- String dtdName = iPath.toFile().getName();
-
- try {
- parser = new DTDParser(false);
- if (expandEntityReferences) {
- parser.setExpandEntityReferences(expandEntityReferences);
- }
- parser.parse(filename);
- }
- catch (IOException ex) {
- ex.printStackTrace(System.err);
- }
-
- dtdModelFile = filename;
-
- factory = DTDFactoryImpl.instance();
-
- extent = new BasicEList();
-
- dtdFile = factory.createDTDFile();
- extent.add(dtdFile);
-
- dtdFile.setName(dtdName);
-
- populateDTD(resources, expandEntityReferences);
- }
-
- public DTDFactory getFactory() {
- return factory;
- }
-
- public DTDFile getDTDFile() {
- return dtdFile;
- }
-
- public Hashtable getPEPool() {
- return pePool;
- }
-
- public Hashtable getElementPool() {
- return elementPool;
- }
-
- public EList getContents() {
- return extent;
- }
-
- public void setResource(Resource resource) {
- this.resource = resource;
- }
-
- public Resource getResource(Resource resource) {
- return resource;
- }
-
- public void setexpandEntityReferences(boolean expandEntityReferences) {
- this.expandEntityReferences = expandEntityReferences;
- }
-
- public boolean getExpandEntityReferences() {
- return expandEntityReferences;
- }
-
- /**
- * Return true if the model has been modified
- */
- public boolean isModelDirty() {
- if (resource != null) {
- return resource.isModified();
- }
- return false;
- }
-
- /**
- * Save the .dtd file
- */
- public boolean save() {
- try {
- Map options = new HashMap();
- resource.save(options);
- return true;
- }
- catch (Exception ex) {
- System.out.println("Save model exception " + ex); //$NON-NLS-1$
- ex.printStackTrace();
- return false;
- }
- }
-
- public boolean saveAs(String newFilename) {
- resource.setURI(URI.createURI(newFilename));
- boolean ok = save();
-
- if (ok) {
- Path path = new Path(newFilename);
- IPath iPath = path.removeFileExtension();
- String dtdName = iPath.toFile().getName();
-
- dtdFile.setName(dtdName);
- }
- return ok;
- }
-
- public boolean saveDTDFile(String filename) {
- boolean result = true;
- try {
- PrintWriter pw = new PrintWriter(new FileWriter(filename), true);
- DTDPrinter printer = new DTDPrinter(true);
- printer.visitDTDFile(dtdFile);
-
- String s = printer.getBuffer().toString();
- pw.println(s);
- pw.close();
- }
-
- catch (Exception e) {
- result = false;
- }
- return result;
- }
-
- public String getDTDSource(boolean includeError) {
- return dtdFile.unparse(includeError); // true = include error lines
- }
-
- /**
- * Create MOF objects from DTD
- */
- private void populateDTD(ResourceSet resources, boolean expandEntityReferences) {
- Vector dtdList = parser.getDTDList();
-
- // create XMIModel for the included DTDs
- if (dtdList.size() > 0) {
- if (!expandEntityReferences) {
- for (int i = dtdList.size() - 1; i > 0; i--) {
- DTD dtd = (DTD) dtdList.elementAt(i);
- loadIncludedDTD(resources, dtd);
- }
-
- DTD dtd = (DTD) dtdList.elementAt(0);
- populateDTD(resources, dtd, dtdFile); // populate the main
- // DTD
- // validateWithModel(dtd);
- }
- else {
- for (int i = dtdList.size() - 1; i >= 0; i--) {
- DTD dtd = (DTD) dtdList.elementAt(i);
- populateDTD(resources, dtd, dtdFile);
- // validateWithModel(dtd);
- }
- }
- }
- }
-
- // return the instance unique to this DTDUtil file that represents an
- // externally loaded dtd (will create if one doesn't exist yet)
- public ExternalDTDModel getExternalDTDModel(ResourceSet resources, String uri) {
- if (expandEntityReferences) {
- return null;
- }
-
- // DefaultMsgLogger.write("External DTD name: " + uri);
-
- if (externalDTDModels.containsKey(uri)) {
- return (ExternalDTDModel) externalDTDModels.get(uri);
- }
- else {
- ExternalDTDModel extModel = new ExternalDTDModel();
- if (extModel.loadModel(resources, uri)) {
- externalDTDModels.put(uri, extModel);
- return extModel;
- }
- }
- return null;
- }
-
- // load xmiModels for included DTDs
- private void loadIncludedDTD(ResourceSet resources, DTD dtd) {
- ExternalDTDModel extModel = getExternalDTDModel(resources, dtd.getName());
- if (extModel != null) {
- // now fill our hash tables for elements and parameter entities
- // so that we know what can be referenced by our main dtd
- DTDFile file = extModel.getExternalDTDFile();
- Collection elementList = file.listDTDElement();
- Collection entityList = file.listDTDEntity();
-
- Iterator i = elementList.iterator();
- while (i.hasNext()) {
- DTDObject object = (DTDObject) i.next();
- elementPool.put(getBaseName(object), object);
- }
-
- i = entityList.iterator();
- while (i.hasNext()) {
- DTDEntity entity = (DTDEntity) i.next();
- if (entity.isParameterEntity()) {
- pePool.put(getBaseName(entity), entity);
- }
- }
- }
- }
-
- /**
- * Create MOF objects from DTD
- *
- * 1) will create the corresponding DTD Mof object for EntityDecl,
- * NotationDecl and ElementDecl declarations during the 1st pass 2) During
- * the 2nd pass, it will add the contentModel and Attlist to all
- * ElementDecl.
- *
- */
- private void populateDTD(ResourceSet resources, DTD dtd, DTDFile dFile) {
- DTDModelBuilder modelBuilder = new DTDModelBuilder(resources, this, dtd, dFile);
-
- modelBuilder.visitDTD(dtd);
- }
-
-
- public void emptyErrorMessages() {
- errorMsgs.removeAllElements();
- }
-
- public void addErrorMessage(ErrorMessage error) {
- int vectorSize = errorMsgs.size();
- boolean add = true;
-
- if (vectorSize != 0) {
- int index = 0;
-
- while (add == true && index < vectorSize) {
- if (((ErrorMessage) errorMsgs.elementAt(index)).equals(error)) {
- add = false;
- }
- else {
- index++;
- }
- }
- }
-
- if (add) {
- errorMsgs.addElement(error);
- }
- }
-
- public Vector getErrors() {
- return errorMsgs;
- }
-
- // This gets the name without any pseudo namespace prefix
- public static String getBaseName(DTDObject obj) {
- return getName(obj, null);
- }
-
- // This gets the name with pseudo namespace prefixes if dtdFile is not
- // null
- public static String getName(DTDObject obj, DTDFile dtdFile) {
- String name = ""; //$NON-NLS-1$
- if (obj instanceof DTDEntity) {
- DTDEntity entity = (DTDEntity) obj;
- if (dtdFile != null && !entity.getDTDFile().equals(dtdFile)) {
- name = new Path(entity.getDTDFile().getName()).lastSegment() + ": "; //$NON-NLS-1$
- }
- name += "%" + ((DTDEntity) obj).getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else if (obj instanceof DTDElement) {
- DTDElement element = (DTDElement) obj;
- if (dtdFile != null && !element.getDTDFile().equals(dtdFile)) {
- name = new Path(element.getDTDFile().getName()).lastSegment() + ": "; //$NON-NLS-1$
- }
- name += ((DTDElement) obj).getName();
- }
- else if (obj instanceof DTDElementContent) {
- return ((DTDElementContent) obj).getContentName();
- }
- return name;
- }
-
- public static String getGroupType(int groupKind, int occurrence) {
- String type = null;
-
- switch (groupKind) {
- case DTDGroupKind.SEQUENCE :
- type = "DTDSequence"; //$NON-NLS-1$
- break;
- case DTDGroupKind.CHOICE :
- type = "DTDChoice"; //$NON-NLS-1$
- break;
- }
-
- type += getRepeatableTypeSuffix(occurrence);
- return type;
- }
-
- public static String getReferenceType(int occurrence) {
- String type = "DTDReference"; //$NON-NLS-1$
- type += getRepeatableTypeSuffix(occurrence);
- return type;
- }
-
- private static String getRepeatableTypeSuffix(int occurrence) {
- return "(" + (char) occurrence + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static void main(String args[]) {
- System.out.println("\nStarting ..."); //$NON-NLS-1$
-
- if (args.length != 1)
- System.out.println("usage: DtdUtil inputfile.dtd"); //$NON-NLS-1$
-
- java.io.File inputFile = new File(args[0]);
-
- String dtdFileName = ""; //$NON-NLS-1$
- try {
- dtdFileName = inputFile.getCanonicalPath();
- }
- catch (IOException ex) {
- }
-
- String dtdModelName = dtdFileName;
-
- if (DTDConstants.DTD_EXTENSION.equals(new Path(dtdFileName).getFileExtension())) {
- dtdModelName = new Path(dtdFileName).removeFileExtension().lastSegment();
- }
- DTDUtil d2m = new DTDUtil();
- // TODO: fix port
- // d2m.parse(dtdFileName);
- try {
- d2m.saveAs(dtdModelName + "." + DTDConstants.DTD_XMI_EXTENSION); //$NON-NLS-1$
- }
- catch (Exception e) {
- System.out.println("Exception thrown during model save: " + e); //$NON-NLS-1$
- }
- System.out.println("Done."); //$NON-NLS-1$
- }
-
- public org.eclipse.core.runtime.IPath getPath() {
- Path currentDTDPath = new Path(dtdModelFile);
- if (currentDTDPath.segmentCount() > 1) {
- return currentDTDPath.removeLastSegments(1).addTrailingSeparator();
- }
-
- return new Path(""); //$NON-NLS-1$
- }
-
- // /**
- // * @generated
- // */
- // protected static DTDUtil getDTDUtilForGen(String filename) {
- //
- // DTDUtil util = (DTDUtil) utilCache.get(filename);
- // if (util == null)
- // {
- // util = new DTDUtil();
- // utilCache.put(filename, util);
- // }
- //
- // return util;
- // }
- // /**
- // * @generated
- // */
- // protected void parseGen(String uri) {
- //
- // parse(new ResourceSetImpl(), uri);
- // }
- // /**
- // * Invoke parse to parse a .dtd file into a MOF object model
- // * This is invoked by the RegisteredDTDParser that registers this parser
- // for MOF to use
- // * against the .dtd type
- // * @param filename - the fully qualifed name of a .dtd file
- // */
- // protected void parseGen(ResourceSet resources, String filename) {
- //
- // // Get the dtd name from the file name
- // Path path = new Path(filename);
- // IPath iPath = path.removeFileExtension();
- // String dtdName = iPath.toFile().getName();
- //
- //
- // try
- // {
- // parser = new DTDParser(false);
- // if (expandEntityReferences)
- // {
- // parser.setExpandEntityReferences(expandEntityReferences);
- // }
- // parser.parse(filename);
- // }
- // catch(IOException ex)
- // {
- // ex.printStackTrace(System.err);
- // }
- //
- //
- // dtdModelFile = filename;
- //
- //
- // factory = DTDFactoryImpl.instance();
- //
- //
- // extent = new BasicEList();
- //
- //
- // dtdFile = factory.createDTDFile();
- // extent.add(dtdFile);
- //
- //
- // dtdFile.setName(dtdName);
- //
- //
- // populateDTD(resources, expandEntityReferences);
- // }
- // /**
- // * @generated
- // */
- // protected DTDFactory getFactoryGen() {
- //
- // return factory;
- // }
- // /**
- // * @generated
- // */
- // protected DTDFile getDTDFileGen() {
- //
- // return dtdFile;
- // }
- // /**
- // * @generated
- // */
- // protected Hashtable getPEPoolGen() {
- //
- // return pePool;
- // }
- // /**
- // * @generated
- // */
- // protected Hashtable getElementPoolGen() {
- //
- // return elementPool;
- // }
- // /**
- // * @generated
- // */
- // protected EList getExtentGen() {
- //
- // return extent;
- // }
- // /**
- // * @generated
- // */
- // protected void setResourceGen(Resource resource) {
- //
- // this.resource = resource;
- // }
- // /**
- // * @generated
- // */
- // protected Resource getResourceGen(Resource resource) {
- //
- // return resource;
- // }
- // /**
- // * @generated
- // */
- // protected void setexpandEntityReferencesGen(boolean
- // expandEntityReferences) {
- //
- // this.expandEntityReferences = expandEntityReferences;
- // }
- // /**
- // * @generated
- // */
- // protected boolean getExpandEntityReferencesGen() {
- //
- // return expandEntityReferences;
- // }
- // /**
- // * Return true if the model has been modified
- // */
- // protected boolean isModelDirtyGen() {
- //
- // if (resource != null)
- // {
- // return resource.isModified();
- // }
- // return false;
- // }
- // /**
- // * Save the .dtd file
- // */
- // protected boolean saveGen() {
- //
- // try
- // {
- // resource.save();
- // return true;
- // }
- // catch (Exception ex)
- // {
- // System.out.println("Save model exception " + ex);
- // ex.printStackTrace();
- // return false;
- // }
- // }
- // /**
- // * @generated
- // */
- // protected boolean saveAsGen(String newFilename) {
- //
- // resource.setURI(newFilename);
- // boolean ok = save();
- //
- //
- // if (ok)
- // {
- // Path path = new Path(newFilename);
- // IPath iPath = path.removeFileExtension();
- // String dtdName = iPath.toFile().getName();
- //
- //
- // dtdFile.setName(dtdName);
- // }
- // return ok;
- // }
- // /**
- // * @generated
- // */
- // protected boolean saveDTDFileGen(String filename) {
- //
- // boolean result=true;
- // try
- // {
- // PrintWriter pw = new PrintWriter(new FileWriter(filename),true);
- // DTDPrinter printer = new DTDPrinter(true);
- // printer.visitDTDFile(dtdFile);
- //
- //
- // String s = printer.getBuffer().getName().toString();
- // pw.println(s);
- // pw.close();
- // }
- //
- //
- // catch (Exception e)
- // {
- // result = false;
- // }
- // return result;
- // }
- // /**
- // * @generated
- // */
- // protected String getDTDSourceGen(boolean includeError) {
- //
- // return dtdFile.unparse(includeError); // true = include error lines
- // }
- // /**
- // * Create MOF objects from DTD
- // */
- // protected void populateDTDGen(ResourceSet resources, boolean
- // expandEntityReferences) {
- //
- // Vector dtdList = parser.getDTDList();
- //
- //
- // // create XMIModel for the included DTDs
- // if ( dtdList.size() > 0)
- // {
- // if (!expandEntityReferences)
- // {
- // for (int i=dtdList.size() - 1; i > 0; i--)
- // {
- // DTD dtd = (DTD) dtdList.elementAt(i);
- // loadIncludedDTD(resources, dtd);
- // }
- //
- //
- // DTD dtd = (DTD) dtdList.elementAt(0);
- // populateDTD(resources, dtd, dtdFile); // populate the main DTD
- // // validateWithModel(dtd);
- // }
- // else
- // {
- // for (int i = dtdList.size() - 1; i >= 0; i--)
- // {
- // DTD dtd = (DTD) dtdList.elementAt(i);
- // populateDTD(resources, dtd, dtdFile);
- // // validateWithModel(dtd);
- // }
- // }
- // }
- // }
- // /**
- // * @generated
- // */
- // protected ExternalDTDModel getExternalDTDModelGen(ResourceSet
- // resources, String uri) {
- //
- // if (expandEntityReferences)
- // {
- // return null;
- // }
- //
- // DefaultMsgLogger.write("External DTD name: " + uri);
- //
- //
- // if (externalDTDModels.containsKey(uri))
- // {
- // return (ExternalDTDModel) externalDTDModels.get(uri);
- // }
- // else
- // {
- // ExternalDTDModel extModel = new ExternalDTDModel();
- // if (extModel.loadModel(resources, uri))
- // {
- // externalDTDModels.put(uri, extModel);
- // return extModel;
- // }
- // }
- // return null;
- // }
- // /**
- // * @generated
- // */
- // protected void loadIncludedDTDGen(ResourceSet resources, DTD dtd) {
- //
- // ExternalDTDModel extModel = getExternalDTDModel(resources,
- // dtd.getName());
- // if (extModel != null)
- // {
- // // now fill our hash tables for elements and parameter entities
- // // so that we know what can be referenced by our main dtd
- // DTDFile file = extModel.getExternalDTDFile();
- // Collection elementList = file.listDTDElement();
- // Collection entityList = file.listDTDEntity();
- //
- //
- // Iterator i = elementList.iterator();
- // while (i.hasNext())
- // {
- // DTDObject object = (DTDObject) i.next();
- // elementPool.put(getBaseName(object), object);
- // }
- //
- // i = entityList.iterator();
- // while (i.hasNext())
- // {
- // DTDEntity entity = (DTDEntity) i.next();
- // if (entity.isParameterEntity())
- // {
- // pePool.put(getBaseName(entity), entity);
- // }
- // }
- // }
- // }
- // /**
- // * Create MOF objects from DTD
- // *
- // * 1) will create the corresponding DTD Mof object for EntityDecl,
- // NotationDecl
- // * and ElementDecl declarations during the 1st pass
- // * 2) During the 2nd pass, it will add the contentModel and Attlist to
- // all
- // * ElementDecl.
- // *
- // */
- // protected void populateDTDGen(ResourceSet resources, DTD dtd, DTDFile
- // dFile) {
- //
- // DTDModelBuilder modelBuilder = new DTDModelBuilder(resources, this,
- // dtd, dFile);
- //
- //
- // modelBuilder.visitDTD(dtd);
- // }
- // /**
- // * @generated
- // */
- // protected void emptyErrorMessagesGen() {
- //
- // errorMsgs.removeAllElements();
- // }
- // /**
- // * @generated
- // */
- // protected void addErrorMessageGen(ErrorMessage error) {
- //
- // int vectorSize = errorMsgs.size();
- // boolean add = true;
- //
- //
- // if (vectorSize != 0)
- // {
- // int index = 0;
- //
- //
- // while (add == true && index < vectorSize)
- // {
- // if (((ErrorMessage) errorMsgs.elementAt(index)).equals(error))
- // {
- // add =false;
- // }
- // else
- // {
- // index++;
- // }
- // }
- // }
- //
- //
- // if (add)
- // {
- // errorMsgs.addElement(error);
- // }
- // }
- // /**
- // * @generated
- // */
- // protected Vector getErrorsGen() {
- //
- // return errorMsgs;
- // }
- // /**
- // * @generated
- // */
- // protected boolean validateDTDGen() {
- //
- // String tempDTDFile=getPath().toOSString()+"tempValidatingFileName.dtd";
- // try
- // {
- // saveDTDFile(tempDTDFile);
- //
- //
- // parser = new DTDParser(false);
- // if (FileUtility.fileExists(tempDTDFile))
- // {
- // parser.parse(tempDTDFile);
- // }
- // Vector dtdList = parser.getDTDList();
- // if ( dtdList.size() > 0)
- // {
- // // reset the errors and update what we have in the element pool
- // emptyErrorMessages();
- // updateElementHashtable();
- //
- //
- // // TODO: do we just validate the current one?
- // validateWithModel((DTD)dtdList.elementAt(0));
- // }
- // }
- // catch(IOException ex)
- // {
- // ex.printStackTrace(System.err);
- // FileUtility.delete(tempDTDFile);
- // }
- // FileUtility.delete(tempDTDFile);
- //
- //
- // return dtdFile.isParseError();
- // }
- // /**
- // * @generated
- // */
- // protected void validateWithModelGen(DTD dtd) {
- //
- // Enumeration en = dtd.externalElements();
- // while (en.hasMoreElements())
- // {
- // Object e = en.nextElement();
- //
- //
- // if ( e instanceof EntityDecl )
- // {
- // EntityDecl entity = (EntityDecl) e;
- // ErrorMessage errMsg = entity.getErrorMessage();
- // if ( errMsg!= null)
- // {
- // addErrorMessage(errMsg);
- // // dtdFile.setParseError(true);
- // }
- // }
- // else if ( e instanceof ElementDecl )
- // {
- // ElementDecl elem = (ElementDecl) e;
- // ErrorMessage errMsg = elem.getErrorMessage();
- // DTDElement dtdelement = (DTDElement)
- // getElementPool().get(elem.getNodeName());
- //
- //
- // if ( errMsg!= null)
- // {
- // addErrorMessage(errMsg);
- // }
- // checkForMissingElementReferences(dtdelement);
- // }
- // else if ( e instanceof NotationDecl )
- // {
- // NotationDecl notation = (NotationDecl) e;
- // ErrorMessage errMsg = notation.getErrorMessage();
- // if ( errMsg!= null)
- // {
- // addErrorMessage(errMsg);
- // }
- // }
- // else if ( e instanceof Attlist )
- // {
- // Attlist attList = (Attlist) e;
- // ErrorMessage errMsg = attList.getErrorMessage();
- // if ( errMsg!= null)
- // {
- // addErrorMessage(errMsg);
- // }
- // }
- // }
- //
- //
- // checkForDuplicateIDAttribute();
- // }
- // /**
- // * @generated
- // */
- // protected void updateElementHashtableGen() {
- //
- // elementPool.clear();
- // CreateListItems itemsHelper = new CreateListItems(dtdFile);
- //
- //
- // Vector allElements = itemsHelper.getElements();
- // // go through all the dtdFiles and list the elements
- // int numElements = allElements.size();
- //
- //
- // for (int i = 0; i < numElements; i++)
- // {
- // DTDElement element = (DTDElement) allElements.elementAt(i);
- // elementPool.put(getBaseName(element), element);
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void updateEntityHashtableGen() {
- //
- // updateHashTable(pePool, dtdFile.listDTDEntity());
- // }
- // /**
- // * @generated
- // */
- // protected void updateHashTableGen(Hashtable h, Collection dtdObjects) {
- //
- // h.clear();
- // Iterator i = dtdObjects.iterator();
- // while (i.hasNext())
- // {
- // String name = "";
- // DTDObject o = (DTDObject) i.next();
- // name = getBaseName(o);
- // h.put(name,o);
- // }
- // }
- // /**
- // * @generated
- // */
- // protected static String getBaseNameGen(DTDObject obj) {
- //
- // return getName(obj, null);
- // }
- // /**
- // * @generated
- // */
- // protected static String getNameGen(DTDObject obj, DTDFile dtdFile) {
- //
- // String name = "";
- // if (obj instanceof DTDEntity)
- // {
- // DTDEntity entity = (DTDEntity) obj;
- // if (dtdFile != null &&
- // !entity.getDTDFile().equals(dtdFile))
- // {
- // name = new Path(entity.getDTDFile().getName()).lastSegment() + ": ";
- // }
- // name += "%" + ((DTDEntity)obj).getName() + ";";
- // }
- // else if (obj instanceof DTDElement)
- // {
- // DTDElement element = (DTDElement) obj;
- // if (dtdFile != null &&
- // !element.getDTDFile().equals(dtdFile))
- // {
- // name = new Path(element.getDTDFile().getName()).lastSegment() + ": ";
- // }
- // name += ((DTDElement)obj).getName();
- // }
- // else if (obj instanceof DTDElementContent)
- // {
- // return ((DTDElementContent) obj).getContentName();
- // }
- // return name;
- // }
- // /**
- // * @generated
- // */
- // protected void checkForMissingElementReferencesGen(DTDElement element)
- // {
- //
- // String dtdString = null;
- // if ( element == null )
- // return;
- //
- //
- // Vector elementRefs = new Vector();
- // findElementReferences(element.getContent(),elementRefs);
- //
- //
- // Enumeration en = elementRefs.elements();
- // while (en.hasMoreElements())
- // {
- // String elementRefName = "";
- // DTDObject dtdObject = (DTDObject) en.nextElement();
- //
- //
- // if ( dtdObject instanceof DTDElement)
- // {
- // elementRefName = ((DTDElement)dtdObject).getName();
- // if ( getElementPool().get(elementRefName) == null)
- // {
- // if (dtdString == null)
- // {
- // dtdString = getDTDSource(false);
- // }
- // String errorMsg = "Element \"" + element.getName() + "\", refers to
- // undeclared element "
- // + "\"" + elementRefName + "\", in content model.\n";
- // ErrorMessage dtdError = new ErrorMessage();
- // dtdError.setErrorMessage(errorMsg);
- // SourceLocationHelper.LineColumn lineColumn =
- // SourceLocationHelper.offsetToLineColumn(dtdString,
- // element.getStartOffset());
- // dtdError.setErrorLine(lineColumn.getLine());
- // dtdError.setErrorColumn(lineColumn.getColumn());
- // addErrorMessage(dtdError);
- // }
- // }
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void findElementReferencesGen(DTDElementContent content,
- // Vector result) {
- //
- //
- // if (content instanceof DTDElementReferenceContent)
- // {
- // result.addElement(((DTDElementReferenceContent)content).getReferencedElement());
- // }
- // else if (content instanceof DTDEntityReferenceContent)
- // {
- // result.addElement(((DTDEntityReferenceContent)content).getElementReferencedEntity());
- // }
- // else if (content instanceof DTDGroupContent)
- // {
- // DTDGroupContent group = (DTDGroupContent)content;
- // EList contents = group.getContent();
- // Iterator i = contents.iterator();
- // while (i.hasNext())
- // {
- // findElementReferences((DTDElementContent) i.next(), result);
- // }
- // }
- // }
- // /**
- // * @generated
- // */
- // protected void checkForDuplicateIDAttributeGen() {
- //
- // String dtdString = null;
- // Collection elements = dtdFile.listDTDElement();
- // Iterator i = elements.iterator();
- // while (i.hasNext())
- // {
- // DTDElement element = (DTDElement) i.next();
- // Iterator k = element.getDTDAttribute().iterator();
- // boolean saw1stID = false;
- // while (k.hasNext())
- // {
- // DTDAttribute attr = (DTDAttribute) k.next();
- // DTDType dType = attr.getDTDType();
- // if (dType instanceof DTDBasicType)
- // {
- // if ( ((DTDBasicType)dType).getKind().intValue() == DTDBasicTypeKind.ID)
- // {
- // if (saw1stID)
- // {
- // if (dtdString == null)
- // {
- // dtdString = getDTDSource(false);
- // }
- // String errMsg = DTDPlugin.getDTDString("_ERROR_DUP_ID_ATTRIBUTE_1");
- // errMsg += attr.getName() +
- // DTDPlugin.getDTDString("_UI_ERRORPART_DUP_ID_ATTRIBUTE_2");
- //
- // ErrorMessage dtdError = new ErrorMessage();
- // dtdError.setErrorMessage(errMsg);
- // SourceLocationHelper.LineColumn lineColumn =
- // SourceLocationHelper.offsetToLineColumn(dtdString,
- // attr.getStartOffset());
- // dtdError.setErrorLine(lineColumn.getLine());
- // dtdError.setErrorColumn(lineColumn.getColumn());
- // dtdError.setObject(attr);
- // addErrorMessage(dtdError);
- // // dtdFile.setParseError(true);
- // break;
- // }
- // else
- // {
- // saw1stID = true;
- // }
- // }
- // }
- // }
- // }
- // }
- // /**
- // * @generated
- // */
- // protected static String getGroupTypeGen(int groupKind, int occurrence)
- // {
- //
- // String type = null;
- //
- //
- // switch (groupKind)
- // {
- // case DTDGroupKind.SEQUENCE:
- // type = "DTDSequence";
- // break;
- // case DTDGroupKind.CHOICE:
- // type = "DTDChoice";
- // break;
- // }
- //
- //
- // type += getRepeatableTypeSuffix(occurrence);
- // return type;
- // }
- // /**
- // * @generated
- // */
- // protected static String getReferenceTypeGen(int occurrence) {
- //
- // String type = "DTDReference";
- // type += getRepeatableTypeSuffix(occurrence);
- // return type;
- // }
- // /**
- // * @generated
- // */
- // protected static String getRepeatableTypeSuffixGen(int occurrence) {
- //
- // return "(" + (char)occurrence + ")";
- // }
- // /**
- // * @generated
- // */
- // protected static void mainGen(String[] args) {
- //
- // System.out.println("\nStarting ...");
- //
- //
- // if (args.length != 1)
- // System.out.println("usage: DtdUtil inputfile.dtd");
- //
- //
- // java.io.File inputFile = new File(args[0]);
- //
- //
- // String dtdFileName = "";
- // try
- // {
- // dtdFileName = inputFile.getCanonicalPath();
- // }
- // catch(IOException ex)
- // {}
- //
- //
- // String dtdModelName = dtdFileName;
- //
- //
- // if (DTDConstants.DTD_EXTENSION.equals(new
- // Path(dtdFileName).getFileExtension()))
- // {
- // dtdModelName= new
- // Path(dtdFileName).removeFileExtension().lastSegment();
- // }
- // DTDUtil d2m = new DTDUtil();
- // // TODO: fix port
- // // d2m.parse(dtdFileName);
- // try
- // {
- // d2m.saveAs(dtdModelName + "." + DTDConstants.DTD_XMI_EXTENSION);
- // }
- // catch (Exception e)
- // {
- // System.out.println("Exception thrown during model save: " + e);
- // }
- // System.out.println("Done.");
- // }
- // /**
- // * @generated
- // */
- // protected org.eclipse.core.runtime.IPath getPathGen() {
- //
- // Path currentDTDPath = new Path(dtdModelFile);
- // if (currentDTDPath.segmentCount() > 1)
- // {
- // return currentDTDPath.removeLastSegments(1).addTrailingSeparator();
- // }
- //
- // return new Path("");
- // }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDVisitor.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDVisitor.java
deleted file mode 100644
index f65a422b27..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/DTDVisitor.java
+++ /dev/null
@@ -1,315 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.dtd.core.internal.emf.DTDAnyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDAttribute;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElement;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDElementReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEmptyContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntity;
-import org.eclipse.wst.dtd.core.internal.emf.DTDEntityReferenceContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDGroupKind;
-import org.eclipse.wst.dtd.core.internal.emf.DTDNotation;
-import org.eclipse.wst.dtd.core.internal.emf.DTDObject;
-import org.eclipse.wst.dtd.core.internal.emf.DTDPCDataContent;
-import org.eclipse.wst.dtd.core.internal.emf.DTDParameterEntityReference;
-import org.eclipse.wst.dtd.core.internal.emf.DTDRepeatableContent;
-
-
-
-public class DTDVisitor {
-
- public DTDVisitor() {
- }
-
- public void visitDTDFile(DTDFile file) {
- Collection notations = file.listDTDNotation();
- for (Iterator i = notations.iterator(); i.hasNext();) {
- visitDTDNotation((DTDNotation) i.next());
- }
-
- Collection entities = file.listDTDEntity();
- for (Iterator i = entities.iterator(); i.hasNext();) {
- visitDTDEntity((DTDEntity) i.next());
- }
-
- Collection objects = file.listDTDElementAndDTDParameterEntityReference();
- for (Iterator i = objects.iterator(); i.hasNext();) {
- DTDObject object = (DTDObject) i.next();
- if (object instanceof DTDElement) {
- visitDTDElement((DTDElement) object);
- } // end of if ()
- else {
- visitDTDParameterEntityReference((DTDParameterEntityReference) object);
- } // end of if ()
- }
-
- }
-
- public void visitDTDNotation(DTDNotation notation) {
- }
-
- public void visitDTDEntity(DTDEntity entity) {
- }
-
- public void visitDTDElement(DTDElement element) {
- visitDTDElementContent(element.getContent());
- visitDTDAttributeList(element.getDTDAttribute());
- }
-
- public void visitDTDParameterEntityReference(DTDParameterEntityReference parmEntity) {
-
- }
-
- public void visitDTDElementContent(DTDElementContent content) {
- // System.out.println("visitDTDElementContent : " + content);
- if (content instanceof DTDEmptyContent) {
- visitDTDEmptyContent((DTDEmptyContent) content);
- }
- else if (content instanceof DTDAnyContent) {
- visitDTDAnyContent((DTDAnyContent) content);
- }
- else if (content instanceof DTDPCDataContent) {
- visitDTDPCDataContent((DTDPCDataContent) content);
- }
- if (content instanceof DTDRepeatableContent) {
- if (content instanceof DTDGroupContent) {
- visitDTDGroupContent((DTDGroupContent) content);
- }
- else if (content instanceof DTDElementReferenceContent) {
- visitDTDElementReferenceContent((DTDElementReferenceContent) content);
- }
- else {
- visitDTDEntityReferenceContent((DTDEntityReferenceContent) content);
- } // end of else
-
- // System.out.println("occurrence: " +
- // (char)((DTDRepeatableContent)content).getOccurrence());
- }
- }
-
- public void visitDTDEmptyContent(DTDEmptyContent dtdEmptyContent) {
- // System.out.println("content: EMPTY");
- }
-
- public void visitDTDAnyContent(DTDAnyContent dtdAnyContent) {
- // System.out.println("content: ANY");
- }
-
- public void visitDTDPCDataContent(DTDPCDataContent pcDataContent) {
- // System.out.println("content: PCDATA");
- }
-
- public void visitDTDGroupContent(DTDGroupContent groupContent) {
- if (groupContent.getGroupKind().getValue() == DTDGroupKind.SEQUENCE) {
- // System.out.println("content: Sequence");
- }
- else // if (contentgetGroupKind() == DTDGroupKind.CHOICE)
- {
- // System.out.println("content: Choice");
- }
-
- Collection groupContents = groupContent.getContent();
- for (Iterator i = groupContents.iterator(); i.hasNext();) {
- visitDTDElementContent((DTDElementContent) i.next());
- }
- }
-
- public void visitDTDElementReferenceContent(DTDElementReferenceContent elementReferenceContent) {
- }
-
- public void visitDTDEntityReferenceContent(DTDEntityReferenceContent entityReferenceContent) {
- }
-
- public void visitDTDAttributeList(List attrs) {
- Iterator iter = attrs.iterator();
-
- while (iter.hasNext()) {
- visitDTDAttribute((DTDAttribute) iter.next());
- } // end of while ()
- }
-
- public void visitDTDAttribute(DTDAttribute attribute) {
- }
-
- /**
- * @generated
- */
- protected void visitDTDFileGen(DTDFile file) {
-
- Collection notations = file.listDTDNotation();
- for (Iterator i = notations.iterator(); i.hasNext();) {
- visitDTDNotation((DTDNotation) i.next());
- }
-
- Collection entities = file.listDTDEntity();
- for (Iterator i = entities.iterator(); i.hasNext();) {
- visitDTDEntity((DTDEntity) i.next());
- }
-
- Collection objects = file.listDTDElementAndDTDParameterEntityReference();
- for (Iterator i = objects.iterator(); i.hasNext();) {
- DTDObject object = (DTDObject) i.next();
- if (object instanceof DTDElement) {
- visitDTDElement((DTDElement) object);
- } // end of if ()
- else {
- visitDTDParameterEntityReference((DTDParameterEntityReference) object);
- } // end of if ()
- }
- }
-
- /**
- * @generated
- */
- protected void visitDTDNotationGen(DTDNotation notation) {
-
- }
-
- /**
- * @generated
- */
- protected void visitDTDEntityGen(DTDEntity entity) {
-
- }
-
- /**
- * @generated
- */
- protected void visitDTDElementGen(DTDElement element) {
-
- visitDTDElementContent(element.getContent());
- visitDTDAttributeList(element.getDTDAttribute());
- }
-
- /**
- * @generated
- */
- protected void visitDTDParameterEntityReferenceGen(DTDParameterEntityReference parmEntity) {
-
- }
-
- /**
- * @generated
- */
- protected void visitDTDElementContentGen(DTDElementContent content) {
-
- // System.out.println("visitDTDElementContent : " + content);
- if (content instanceof DTDEmptyContent) {
- visitDTDEmptyContent((DTDEmptyContent) content);
- }
- else if (content instanceof DTDAnyContent) {
- visitDTDAnyContent((DTDAnyContent) content);
- }
- else if (content instanceof DTDPCDataContent) {
- visitDTDPCDataContent((DTDPCDataContent) content);
- }
- if (content instanceof DTDRepeatableContent) {
- if (content instanceof DTDGroupContent) {
- visitDTDGroupContent((DTDGroupContent) content);
- }
- else if (content instanceof DTDElementReferenceContent) {
- visitDTDElementReferenceContent((DTDElementReferenceContent) content);
- }
- else {
- visitDTDEntityReferenceContent((DTDEntityReferenceContent) content);
- } // end of else
-
- // System.out.println("occurrence: " +
- // (char)((DTDRepeatableContent)content).getOccurrence());
- }
- }
-
- /**
- * @generated
- */
- protected void visitDTDEmptyContentGen(DTDEmptyContent dtdEmptyContent) {
-
- // System.out.println("content: EMPTY");
- }
-
- /**
- * @generated
- */
- protected void visitDTDAnyContentGen(DTDAnyContent dtdAnyContent) {
-
- // System.out.println("content: ANY");
- }
-
- /**
- * @generated
- */
- protected void visitDTDPCDataContentGen(DTDPCDataContent pcDataContent) {
-
- // System.out.println("content: PCDATA");
- }
-
- /**
- * @generated
- */
- protected void visitDTDGroupContentGen(DTDGroupContent groupContent) {
-
- if (groupContent.getGroupKind().getValue() == DTDGroupKind.SEQUENCE) {
- // System.out.println("content: Sequence");
- }
- else // if (contentgetGroupKind() == DTDGroupKind.CHOICE)
- {
- // System.out.println("content: Choice");
- }
-
- Collection groupContents = groupContent.getContent();
- for (Iterator i = groupContents.iterator(); i.hasNext();) {
- visitDTDElementContent((DTDElementContent) i.next());
- }
- }
-
- /**
- * @generated
- */
- protected void visitDTDElementReferenceContentGen(DTDElementReferenceContent elementReferenceContent) {
-
- }
-
- /**
- * @generated
- */
- protected void visitDTDEntityReferenceContentGen(DTDEntityReferenceContent entityReferenceContent) {
-
- }
-
- /**
- * @generated
- */
- protected void visitDTDAttributeListGen(List attrs) {
-
- Iterator iter = attrs.iterator();
-
- while (iter.hasNext()) {
- visitDTDAttribute((DTDAttribute) iter.next());
- } // end of while ()
- }
-
- /**
- * @generated
- */
- protected void visitDTDAttributeGen(DTDAttribute attribute) {
-
- }
-}
diff --git a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/ExternalDTDModel.java b/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/ExternalDTDModel.java
deleted file mode 100644
index 247653565f..0000000000
--- a/bundles/org.eclipse.wst.dtd.core/emfmodel/org/eclipse/wst/dtd/core/internal/emf/util/ExternalDTDModel.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 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.dtd.core.internal.emf.util;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.wst.dtd.core.internal.emf.DTDFile;
-
-
-/**
- * Load another DTD model - use when there is external entity references from
- * another model
- */
-public class ExternalDTDModel {
- DTDFile dtdFile = null;
-
- public ExternalDTDModel() {
- }
-
- public DTDFile getExternalDTDFile() {
- return dtdFile;
- }
-
- /**
- * Load the DTD model specified by the uri e.g.
- * file:C:/eclipse/examples/purchaseorder.dtd
- */
- public boolean loadModel(ResourceSet resources, String uri) {
- boolean rc = true;
-
- if (uri == null || uri.equals("")) { //$NON-NLS-1$
- return false;
- }
-
- try {
- // todo... Investigate why we can not create a new DTDUtil to load
- // the external
- // without breaking the bvt test bucket on the oagis cases.
- // Are depending on mof's built in caching via
- // resources.load(uri)?
- //
- URI uriObj = URI.createURI(uri);
- Resource r = resources.createResource(uriObj);
- Map options = new HashMap();
- r.load(options);
-
- for (Iterator i = resources.getResources().iterator(); i.hasNext();) {
- DTDFile currentFile = (DTDFile) ((Resource) i.next()).getContents().get(0);
- String currentURI = currentFile.eResource().getURI().toString();
- // note : mof stores a slightly different uri than the one we
- // passed in to resources.load(uri)
- // In the 'file:' protocol case, the call
- // resource.load("file:D:\x.dtd") will store a resource with
- // uri "D:\x.dtd".
- // This is why we use 'endswith()' instead of 'equals()' to
- // compare.
- if (uri.endsWith(currentURI)) {
- dtdFile = currentFile;
- break;
- }
- }
- if (dtdFile == null) {
- rc = false;
- }
- }
- catch (Exception ex) {
- rc = false;
- }
- return rc;
- }
-}

Back to the top