deleting existing version in prep for refresh
diff --git a/bundles/org.eclipse.wst.xml.core/.classpath b/bundles/org.eclipse.wst.xml.core/.classpath
deleted file mode 100644
index 065ac06..0000000
--- a/bundles/org.eclipse.wst.xml.core/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/bundles/org.eclipse.wst.xml.core/.cvsignore b/bundles/org.eclipse.wst.xml.core/.cvsignore
deleted file mode 100644
index ba077a4..0000000
--- a/bundles/org.eclipse.wst.xml.core/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/bundles/org.eclipse.wst.xml.core/.options b/bundles/org.eclipse.wst.xml.core/.options
deleted file mode 100644
index 29b1a4e..0000000
--- a/bundles/org.eclipse.wst.xml.core/.options
+++ /dev/null
@@ -1,2 +0,0 @@
-org.eclipse.wst.xml.core/debug=true
-org.eclipse.wst.xml.core/debug/tracefilter=
\ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.core/.project b/bundles/org.eclipse.wst.xml.core/.project
deleted file mode 100644
index 702ddfa..0000000
--- a/bundles/org.eclipse.wst.xml.core/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.wst.xml.core</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.eclipse.pde.PluginNature</nature>
- </natures>
-</projectDescription>
diff --git a/bundles/org.eclipse.wst.xml.core/build.properties b/bundles/org.eclipse.wst.xml.core/build.properties
deleted file mode 100644
index f0910cc..0000000
--- a/bundles/org.eclipse.wst.xml.core/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-bin.includes = xmlmodel.jar,\
- plugin.properties,\
- plugin.xml,\
- .options
-jars.compile.order = xmlmodel.jar
-source.xmlmodel.jar = src/
-output.xmlmodel.jar = bin/
diff --git a/bundles/org.eclipse.wst.xml.core/plugin.properties b/bundles/org.eclipse.wst.xml.core/plugin.properties
deleted file mode 100644
index 752cf2a..0000000
--- a/bundles/org.eclipse.wst.xml.core/plugin.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-Structured_Source_XML_Model.name=Structured Source XML Model
-Structured_Source_XML_Model_NL_Support.name=Structured Source XML Model NL Support
diff --git a/bundles/org.eclipse.wst.xml.core/plugin.xml b/bundles/org.eclipse.wst.xml.core/plugin.xml
deleted file mode 100644
index 86aa995..0000000
--- a/bundles/org.eclipse.wst.xml.core/plugin.xml
+++ /dev/null
@@ -1,147 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.xml.core"
- name="%Structured_Source_XML_Model.name"
- version="1.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.wst.xml.core.XMLModelPlugin">
-
- <runtime>
- <library name="xmlmodel.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.wst.encoding"/>
- <import plugin="org.eclipse.wst.sse.core"/>
- <import plugin="org.eclipse.wst.contentmodel"/>
- <import plugin="org.eclipse.wst.xml.uriresolver"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.wst.sse.ui"/>
- </requires>
-
-
- <extension
- point="org.eclipse.wst.sse.core.modelHandler">
- <modelHandler
- default="true"
- class="org.eclipse.wst.xml.core.modelhandler.ModelHandlerForXML"
- associatedContentTypeId="org.eclipse.core.runtime.xml"
- id="org.eclipse.wst.sse.core.handler.xml">
- </modelHandler>
- </extension>
- <extension
- point="org.eclipse.wst.sse.core.embeddedTypeHandler">
- <embeddedTypeHandler
- class="org.eclipse.wst.xml.core.modelhandler.EmbeddedXML">
- </embeddedTypeHandler>
- </extension>
-
- <extension
- id="org.eclipse.wst.xml.core.builderdelegate.todo"
- point="org.eclipse.wst.sse.core.builderdelegate">
- <participant
- class="org.eclipse.wst.xml.core.builder.delegates.XMLTaskTagSeeker"
- contentType="org.eclipse.core.runtime.xml,org.eclipse.wst.xml.core.xmlsource">
- </participant>
- </extension>
-
- <!--
- <extension point="org.eclipse.core.filebuffers.documentCreation"
- id="org.eclipse.wst.xml.core.XMLDocumentFactory.runtime.xml"
- name="Structured XML Document Factory">
- <factory
- contentTypeId="org.eclipse.core.runtime.xml"
- class="org.eclipse.wst.xml.core.internal.filebuffers.DocumentFactoryForXML">
- </factory>
- </extension>
-
- <extension point="org.eclipse.core.filebuffers.documentSetup"
- id="org.eclipse.wst.xml.core.XMLDocumentSetup.runtime.xml"
- name="Structured XML Document Setup">
- <participant
- contentTypeId="org.eclipse.core.runtime.xml"
- class="org.eclipse.wst.xml.core.internal.filebuffers.SetupParticipantForXML">
- </participant>
- </extension>
- -->
-
- <!-- to be deleted. I think runtime.xml will work fine
- <extension point="org.eclipse.core.filebuffers.documentCreation"
- id="org.eclipse.wst.xml.core.XMLDocumentFactory.xml.xmlsource"
- name="Structured XML Document Factory">
- <factory
- contentTypeId="org.eclipse.wst.xml.core.xmlsource"
- class="org.eclipse.wst.xml.core.internal.filebuffers.DocumentFactoryForXML">
- </factory>
- </extension>
-
- <extension point="org.eclipse.core.filebuffers.documentSetup"
- id="org.eclipse.wst.xml.core.XMLDocumentSetup.xml.xmlsource"
- name="Structured XML Document Setup">
- <participant
- contentTypeId="org.eclipse.wst.xml.core.xmlsource"
- class="org.eclipse.wst.xml.core.internal.filebuffers.SetupParticipantForXML">
- </participant>
- </extension>
- -->
-
- <extension
- point="org.eclipse.team.core.fileTypes">
- <fileTypes
- type="text"
- extension="xsl">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xslt">
- </fileTypes>
- <fileTypes
- type="text"
- extension="dadx">
- </fileTypes>
- <fileTypes
- type="text"
- extension="wsdl">
- </fileTypes>
- <fileTypes
- type="text"
- extension="nst">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xmi">
- </fileTypes>
- <fileTypes
- type="text"
- extension="xsd">
- </fileTypes>
- </extension>
- <extension
- point="org.eclipse.wst.sse.core.formatProcessors">
- <processor
- class="org.eclipse.wst.xml.core.format.FormatProcessorXML"
- contentTypeId="org.eclipse.core.runtime.xml">
- </processor>
- </extension>
-
- <extension
- point="org.eclipse.core.runtime.contentTypes">
- <content-type
- priority="high"
- name="XML Content Type"
- id="xmlsource"
- base-type="org.eclipse.core.runtime.xml"
- default-charset="UTF-8">
- <describer class="org.eclipse.wst.xml.core.contenttype.ContentDescriberForXML"/>
- </content-type>
- <file-association
- content-type="org.eclipse.core.runtime.xml"
- file-extensions="xsl,xslt,dadx,wsdl,nst,xmi,xsd,exsd"/>
- </extension>
-
-</plugin>
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/Logger.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/Logger.java
deleted file mode 100644
index 631fd01..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/Logger.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if desired,
- * the console. This class should only be used by classes in this plugin. Other
- * plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static Plugin fPlugin = XMLModelPlugin.getDefault();
- private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier();
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
-
- public static final int OK = IStatus.OK; // 0
- public static final int INFO = IStatus.INFO; // 1
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int ERROR = IStatus.ERROR; // 4
-
- public static final int OK_DEBUG = 200 + OK;
- public static final int INFO_DEBUG = 200 + INFO;
- public static final int WARNING_DEBUG = 200 + WARNING;
- public static final int ERROR_DEBUG = 200 + ERROR;
-
- /**
- * Adds message to log.
- * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message text to add to the log
- * @param exception exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, fPluginId, severity, message, exception);
- fPlugin.getLog().log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- * @param message text to print
- * @param category category of the message, to be compared with /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, fPluginId, IStatus.OK, message, exception);
- fPlugin.getLog().log(statusObj);
- }
- }
-
- /**
- * @return true if the plugin for this logger is debugging
- */
- public static boolean isDebugging() {
- return fPlugin.isDebugging();
- }
-
- /**
- * Determines if currently tracing a category
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(fPluginId + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/NameValidator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/NameValidator.java
deleted file mode 100644
index a352024..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/NameValidator.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core;
-
-import java.io.IOException;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.parser.XMLTokenizer;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-
-
-public class NameValidator {
- /**
- * Verify that the given string is a Name as defined in the XML recommendation at http://www.w3.org/TR/REC-xml
- *
- * [ 5] Name ::= (Letter | '_' | ':') (NameChar)*
- *
- * [ 4] NameChar ::= Letter | Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender
- * [84] Letter ::= BaseChar | Ideographic
- * [85] BaseChar ::= [#x0041-#x005A] | [#x0061-#x007A] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x00FF] | [#x0100-#x0131] | [#x0134-#x013E] | [#x0141-#x0148] | [#x014A-#x017E] | [#x0180-#x01C3] | [#x01CD-#x01F0] | [#x01F4-#x01F5] | [#x01FA-#x0217] | [#x0250-#x02A8] | [#x02BB-#x02C1] | #x0386 | [#x0388-#x038A] | #x038C | [#x038E-#x03A1] | [#x03A3-#x03CE] | [#x03D0-#x03D6] | #x03DA | #x03DC | #x03DE | #x03E0 | [#x03E2-#x03F3] | [#x0401-#x040C] | [#x040E-#x044F] | [#x0451-#x045C] | [#x045E-#x0481] | [#x0490-#x04C4] | [#x04C7-#x04C8] | [#x04CB-#x04CC] | [#x04D0-#x04EB] | [#x04EE-#x04F5] | [#x04F8-#x04F9] | [#x0531-#x0556] | #x0559 | [#x0561-#x0586] | [#x05D0-#x05EA] | [#x05F0-#x05F2] | [#x0621-#x063A] | [#x0641-#x064A] | [#x0671-#x06B7] | [#x06BA-#x06BE] | [#x06C0-#x06CE] | [#x06D0-#x06D3] | #x06D5 | [#x06E5-#x06E6] | [#x0905-#x0939] | #x093D | [#x0958-#x0961] | [#x0985-#x098C] | [#x098F-#x0990] | [#x0993-#x09A8] | [#x09AA-#x09B0] | #x09B2 | [#x09B6-#x09B9] | [#x09DC-#x09DD] | [#x09DF-#x09E1] | [#x09F0-#x09F1] | [#x0A05-#x0A0A] | [#x0A0F-#x0A10] | [#x0A13-#x0A28] | [#x0A2A-#x0A30] | [#x0A32-#x0A33] | [#x0A35-#x0A36] | [#x0A38-#x0A39] | [#x0A59-#x0A5C] | #x0A5E | [#x0A72-#x0A74] | [#x0A85-#x0A8B] | #x0A8D | [#x0A8F-#x0A91] | [#x0A93-#x0AA8] | [#x0AAA-#x0AB0] | [#x0AB2-#x0AB3] | [#x0AB5-#x0AB9] | #x0ABD | #x0AE0 | [#x0B05-#x0B0C] | [#x0B0F-#x0B10] | [#x0B13-#x0B28] | [#x0B2A-#x0B30] | [#x0B32-#x0B33] | [#x0B36-#x0B39] | #x0B3D | [#x0B5C-#x0B5D] | [#x0B5F-#x0B61] | [#x0B85-#x0B8A] | [#x0B8E-#x0B90] | [#x0B92-#x0B95] | [#x0B99-#x0B9A] | #x0B9C | [#x0B9E-#x0B9F] | [#x0BA3-#x0BA4] | [#x0BA8-#x0BAA] | [#x0BAE-#x0BB5] | [#x0BB7-#x0BB9] | [#x0C05-#x0C0C] | [#x0C0E-#x0C10] | [#x0C12-#x0C28] | [#x0C2A-#x0C33] | [#x0C35-#x0C39] | [#x0C60-#x0C61] | [#x0C85-#x0C8C] | [#x0C8E-#x0C90] | [#x0C92-#x0CA8] | [#x0CAA-#x0CB3] | [#x0CB5-#x0CB9] | #x0CDE | [#x0CE0-#x0CE1] | [#x0D05-#x0D0C] | [#x0D0E-#x0D10] | [#x0D12-#x0D28] | [#x0D2A-#x0D39] | [#x0D60-#x0D61] | [#x0E01-#x0E2E] | #x0E30 | [#x0E32-#x0E33] | [#x0E40-#x0E45] | [#x0E81-#x0E82] | #x0E84 | [#x0E87-#x0E88] | #x0E8A | #x0E8D | [#x0E94-#x0E97] | [#x0E99-#x0E9F] | [#x0EA1-#x0EA3] | #x0EA5 | #x0EA7 | [#x0EAA-#x0EAB] | [#x0EAD-#x0EAE] | #x0EB0 | [#x0EB2-#x0EB3] | #x0EBD | [#x0EC0-#x0EC4] | [#x0F40-#x0F47] | [#x0F49-#x0F69] | [#x10A0-#x10C5] | [#x10D0-#x10F6] | #x1100 | [#x1102-#x1103] | [#x1105-#x1107] | #x1109 | [#x110B-#x110C] | [#x110E-#x1112] | #x113C | #x113E | #x1140 | #x114C | #x114E | #x1150 | [#x1154-#x1155] | #x1159 | [#x115F-#x1161] | #x1163 | #x1165 | #x1167 | #x1169 | [#x116D-#x116E] | [#x1172-#x1173] | #x1175 | #x119E | #x11A8 | #x11AB | [#x11AE-#x11AF] | [#x11B7-#x11B8] | #x11BA | [#x11BC-#x11C2] | #x11EB | #x11F0 | #x11F9 | [#x1E00-#x1E9B] | [#x1EA0-#x1EF9] | [#x1F00-#x1F15] | [#x1F18-#x1F1D] | [#x1F20-#x1F45] | [#x1F48-#x1F4D] | [#x1F50-#x1F57] | #x1F59 | #x1F5B | #x1F5D | [#x1F5F-#x1F7D] | [#x1F80-#x1FB4] | [#x1FB6-#x1FBC] | #x1FBE | [#x1FC2-#x1FC4] | [#x1FC6-#x1FCC] | [#x1FD0-#x1FD3] | [#x1FD6-#x1FDB] | [#x1FE0-#x1FEC] | [#x1FF2-#x1FF4] | [#x1FF6-#x1FFC] | #x2126 | [#x212A-#x212B] | #x212E | [#x2180-#x2182] | [#x3041-#x3094] | [#x30A1-#x30FA] | [#x3105-#x312C] | [#xAC00-#xD7A3]
- * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]
- * [87] CombiningChar ::= [#x0300-#x0345] | [#x0360-#x0361] | [#x0483-#x0486] | [#x0591-#x05A1] | [#x05A3-#x05B9] | [#x05BB-#x05BD] | #x05BF | [#x05C1-#x05C2] | #x05C4 | [#x064B-#x0652] | #x0670 | [#x06D6-#x06DC] | [#x06DD-#x06DF] | [#x06E0-#x06E4] | [#x06E7-#x06E8] | [#x06EA-#x06ED] | [#x0901-#x0903] | #x093C | [#x093E-#x094C] | #x094D | [#x0951-#x0954] | [#x0962-#x0963] | [#x0981-#x0983] | #x09BC | #x09BE | #x09BF | [#x09C0-#x09C4] | [#x09C7-#x09C8] | [#x09CB-#x09CD] | #x09D7 | [#x09E2-#x09E3] | #x0A02 | #x0A3C | #x0A3E | #x0A3F | [#x0A40-#x0A42] | [#x0A47-#x0A48] | [#x0A4B-#x0A4D] | [#x0A70-#x0A71] | [#x0A81-#x0A83] | #x0ABC | [#x0ABE-#x0AC5] | [#x0AC7-#x0AC9] | [#x0ACB-#x0ACD] | [#x0B01-#x0B03] | #x0B3C | [#x0B3E-#x0B43] | [#x0B47-#x0B48] | [#x0B4B-#x0B4D] | [#x0B56-#x0B57] | [#x0B82-#x0B83] | [#x0BBE-#x0BC2] | [#x0BC6-#x0BC8] | [#x0BCA-#x0BCD] | #x0BD7 | [#x0C01-#x0C03] | [#x0C3E-#x0C44] | [#x0C46-#x0C48] | [#x0C4A-#x0C4D] | [#x0C55-#x0C56] | [#x0C82-#x0C83] | [#x0CBE-#x0CC4] | [#x0CC6-#x0CC8] | [#x0CCA-#x0CCD] | [#x0CD5-#x0CD6] | [#x0D02-#x0D03] | [#x0D3E-#x0D43] | [#x0D46-#x0D48] | [#x0D4A-#x0D4D] | #x0D57 | #x0E31 | [#x0E34-#x0E3A] | [#x0E47-#x0E4E] | #x0EB1 | [#x0EB4-#x0EB9] | [#x0EBB-#x0EBC] | [#x0EC8-#x0ECD] | [#x0F18-#x0F19] | #x0F35 | #x0F37 | #x0F39 | #x0F3E | #x0F3F | [#x0F71-#x0F84] | [#x0F86-#x0F8B] | [#x0F90-#x0F95] | #x0F97 | [#x0F99-#x0FAD] | [#x0FB1-#x0FB7] | #x0FB9 | [#x20D0-#x20DC] | #x20E1 | [#x302A-#x302F] | #x3099 | #x309A
- * [88] Digit ::= [#x0030-#x0039] | [#x0660-#x0669] | [#x06F0-#x06F9] | [#x0966-#x096F] | [#x09E6-#x09EF] | [#x0A66-#x0A6F] | [#x0AE6-#x0AEF] | [#x0B66-#x0B6F] | [#x0BE7-#x0BEF] | [#x0C66-#x0C6F] | [#x0CE6-#x0CEF] | [#x0D66-#x0D6F] | [#x0E50-#x0E59] | [#x0ED0-#x0ED9] | [#x0F20-#x0F29]
- * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 | #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] | [#x309D-#x309E] | [#x30FC-#x30FE]
- */
-
- private static XMLTokenizer tokenizer = null;
-
- // TODO: Optimize by writing an actual test
- public synchronized static final boolean isValid(String name) {
- if (tokenizer == null)
- tokenizer = new XMLTokenizer();
- tokenizer.reset(name.toCharArray());
- tokenizer.yybegin(XMLTokenizer.ST_XML_TAG_NAME);
- ITextRegion nameregion = null;
- try {
- nameregion = tokenizer.getNextToken();
- }
- catch (IOException e) {
- // should not occur
- return false;
- }
- return (nameregion != null && nameregion.getType() == XMLRegionContext.XML_TAG_NAME);
- // return XMLChar.isValidName(name);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLModelPlugin.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLModelPlugin.java
deleted file mode 100644
index 0ca8969..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLModelPlugin.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class XMLModelPlugin extends Plugin {
- //The shared instance.
- private static XMLModelPlugin plugin;
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- public XMLModelPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.core.XmlPluginResources"); //$NON-NLS-1$
- }
- catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- */
- public static XMLModelPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = XMLModelPlugin.getDefault().getResourceBundle();
- try {
- return bundle.getString(key);
- }
- catch (MissingResourceException e) {
- return key;
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#initializeDefaultPluginPreferences()
- */
- protected void initializeDefaultPluginPreferences() {
- super.initializeDefaultPluginPreferences();
- Preferences prefs = getDefault().getPluginPreferences();
- // set model preference defaults
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true);
- prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true);
- prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false);
-
- prefs.setDefault(CommonModelPreferenceNames.INPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonModelPreferenceNames.OUTPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonModelPreferenceNames.END_OF_LINE_CODE, new String());
-
- prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, 4);
-
- prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, true);
- prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72);
- prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false);
- prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true);
- prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false);
-
- prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.LOWER);
- prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER);
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLPreferenceNames.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLPreferenceNames.java
deleted file mode 100644
index 9129c38..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/XMLPreferenceNames.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core;
-
-
-
-public interface XMLPreferenceNames {
-
- // content assist preference names
- /** @deprecated */
- String AUTO_PROPOSE = "autoPropose";//$NON-NLS-1$
- /** @deprecated */
- String AUTO_PROPOSE_CODE = "autoProposeCode";//$NON-NLS-1$
-
- // content assist preference values
- /** @deprecated */
- String LT = "<";//$NON-NLS-1$
-
- // cleanup preference names
- String CLEANUP_TAG_NAME_CASE = "cleanupTagNameCase";//$NON-NLS-1$
- String CLEANUP_ATTR_NAME_CASE = "cleanupAttrNameCase";//$NON-NLS-1$
- String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
- String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
- String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
- String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
- String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
-
- // others
- /** @deprecated use CommonPreferenceNames.SHOW_HOVER_HELP*/
- String HOVER_HELP = "hoverHelp";//$NON-NLS-1$
- String LAST_ACTIVE_PAGE = "lastActivePage";//$NON-NLS-1$
-
- /* not used for now
- // highlighting types
- String COMMENT_BORDER = "commentBorder";//$NON-NLS-1$
- String COMMENT_TEXT = "commentText";//$NON-NLS-1$
- String CDATA_BORDER = "cdataBorder";//$NON-NLS-1$
- String CDATA_TEXT = "cdataText";//$NON-NLS-1$
- String PI_BORDER = "piBorder";//$NON-NLS-1$
- String PI_CONTENT = "piContent";//$NON-NLS-1$
- String TAG_BORDER = "tagBorder";//$NON-NLS-1$
- String TAG_NAME = "tagName";//$NON-NLS-1$
- String TAG_ATTRIBUTE_NAME = "tagAttributeName";//$NON-NLS-1$
- String TAG_ATTRIBUTE_VALUE = "tagAttributeValue";//$NON-NLS-1$
- String DECL_BORDER = "declBoder";//$NON-NLS-1$
- String DOCTYPE_NAME = "doctypeName";//$NON-NLS-1$
- String DOCTYPE_EXTERNAL_ID = "doctypeExternalId";//$NON-NLS-1$
- String DOCTYPE_EXTERNAL_ID_PUBREF = "doctypeExternalPubref";//$NON-NLS-1$
- String DOCTYPE_EXTERNAL_ID_SYSREF = "doctypeExtrenalSysref";//$NON-NLS-1$
- String XML_CONTENT = "xmlContent";//$NON-NLS-1$
-
- // highlighting preferences
- String COMMA = ",";//$NON-NLS-1$
- String COLOR = "color";//$NON-NLS-1$
- String NAME = "name";//$NON-NLS-1$
- String FOREGROUND = "foreground";//$NON-NLS-1$
- String BACKGROUND = "background";//$NON-NLS-1$
- String BOLD = "bold";//$NON-NLS-1$
- String ITALIC = "italic";//$NON-NLS-1$
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/delegates/XMLTaskTagSeeker.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/delegates/XMLTaskTagSeeker.java
deleted file mode 100644
index 526d51b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/delegates/XMLTaskTagSeeker.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.builder.delegates;
-
-import org.eclipse.wst.sse.core.builder.participants.TaskTagSeeker;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-
-
-public class XMLTaskTagSeeker extends TaskTagSeeker {
-
- /**
- *
- */
- public XMLTaskTagSeeker() {
- super();
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) {
- return textRegion.getType().equals(XMLRegionContext.XML_COMMENT_TEXT);
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/participants/XMLTaskTagParticipant.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/participants/XMLTaskTagParticipant.java
deleted file mode 100644
index 44a643a..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/builder/participants/XMLTaskTagParticipant.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.builder.participants;
-
-import org.eclipse.wst.sse.core.builder.participants.TaskTagParticipant;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-
-
-public class XMLTaskTagParticipant extends TaskTagParticipant {
- protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) {
- return textRegion.getType().equals(XMLRegionContext.XML_COMMENT_TEXT);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/CleanupProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/CleanupProcessorXML.java
deleted file mode 100644
index 9936ebf..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/CleanupProcessorXML.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.encoding.content.IContentTypeIdentifier;
-import org.eclipse.wst.sse.core.cleanup.AbstractStructuredCleanupProcessor;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.cleanup.StructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.xml.core.XMLModelPlugin;
-import org.eclipse.wst.xml.core.format.FormatProcessorXML;
-import org.w3c.dom.Node;
-
-
-public class CleanupProcessorXML extends AbstractStructuredCleanupProcessor {
- protected IStructuredCleanupPreferences fCleanupPreferences = null;
-
- public IStructuredCleanupPreferences getCleanupPreferences() {
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new StructuredCleanupPreferences();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fCleanupPreferences.setTagNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE));
- fCleanupPreferences.setAttrNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE));
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(CommonModelPreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(CommonModelPreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(CommonModelPreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(CommonModelPreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(CommonModelPreferenceNames.CLEANUP_EOL_CODE));
- }
- }
-
- return fCleanupPreferences;
- }
-
- protected String getContentType() {
- return IContentTypeIdentifier.ContentTypeID_SSEXML;
- }
-
- protected IStructuredCleanupHandler getCleanupHandler(Node node) {
- short nodeType = node.getNodeType();
- IStructuredCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE : {
- cleanupHandler = new ElementNodeCleanupHandler();
- break;
- }
- case Node.TEXT_NODE : {
- cleanupHandler = new NodeCleanupHandler();
- break;
- }
- default : {
- cleanupHandler = new NodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
-
- return cleanupHandler;
- }
-
- protected IStructuredFormatProcessor getFormatProcessor() {
- return new FormatProcessorXML();
- }
-
- protected Preferences getModelPreferences() {
- return XMLModelPlugin.getDefault().getPluginPreferences();
- }
-
- protected void refreshCleanupPreferences() {
- fCleanupPreferences = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/ElementNodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/ElementNodeCleanupHandler.java
deleted file mode 100644
index 44161fb..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/ElementNodeCleanupHandler.java
+++ /dev/null
@@ -1,560 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.document.XMLAttr;
-import org.eclipse.wst.xml.core.document.XMLDocument;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.eclipse.wst.xml.core.document.XMLGenerator;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-public class ElementNodeCleanupHandler extends NodeCleanupHandler {
-
- /** Non-NLS strings */
- protected static final String START_TAG_OPEN = "<"; //$NON-NLS-1$
- protected static final String END_TAG_OPEN = "</"; //$NON-NLS-1$
- protected static final String TAG_CLOSE = ">"; //$NON-NLS-1$
- protected static final String EMPTY_TAG_CLOSE = "/>"; //$NON-NLS-1$
- protected static final String SINGLE_QUOTES = "''"; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTES = "\"\""; //$NON-NLS-1$
- protected static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$
- protected static final char DOUBLE_QUOTE = '\"'; //$NON-NLS-1$
-
- public Node cleanup(Node node) {
- Node newNode = cleanupChildren(node);
- XMLNode renamedNode = newNode instanceof XMLNode ? (XMLNode) newNode : null;
-
- // call quoteAttrValue() first so it will close any unclosed attr
- // quoteAttrValue() will return the new start tag if there is a
- // structure change
- renamedNode = quoteAttrValue(renamedNode);
-
- // insert tag close if missing
- // if node is not comment tag
- // and not implicit tag
- if (!isCommentTag(renamedNode) && !isImplicitTag(renamedNode)) {
- XMLModel structuredModel = renamedNode.getModel();
-
- // save start offset before insertTagClose()
- // or else renamedNode.getStartOffset() will be zero if
- // renamedNode replaced by insertTagClose()
- int startTagStartOffset = renamedNode.getStartOffset();
-
- // for start tag
- IStructuredDocumentRegion startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
- insertTagClose(structuredModel, startTagStructuredDocumentRegion);
-
- // update renamedNode and startTagStructuredDocumentRegion after
- // insertTagClose()
- renamedNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset);
- startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
-
- // for end tag
- IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion)
- insertTagClose(structuredModel, endTagStructuredDocumentRegion);
- }
-
- // call insertMissingTags() next, it will generate implicit tags if
- // there are any
- // insertMissingTags() will return the new missing start tag if one is
- // missing
- renamedNode = insertMissingTags(renamedNode);
-
- renamedNode = compressEmptyElementTag(renamedNode);
-
- renamedNode = insertRequiredAttrs(renamedNode);
-
- return renamedNode;
- }
-
- private XMLNode compressEmptyElementTag(XMLNode node) {
- boolean compressEmptyElementTags = getCleanupPreferences().getCompressEmptyElementTags();
- XMLNode newNode = node;
-
- IStructuredDocumentRegion startTagStructuredDocumentRegion = newNode.getFirstStructuredDocumentRegion();
- IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getLastStructuredDocumentRegion();
-
- if (compressEmptyElementTags && startTagStructuredDocumentRegion != endTagStructuredDocumentRegion && startTagStructuredDocumentRegion != null) {
- ITextRegionList regions = startTagStructuredDocumentRegion.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- // format children and end tag if not empty element tag
- if (lastRegion.getType() != XMLRegionContext.XML_EMPTY_TAG_CLOSE) {
- NodeList childNodes = newNode.getChildNodes();
- if (childNodes == null || childNodes.getLength() == 0 || (childNodes.getLength() == 1 && (childNodes.item(0)).getNodeType() == Node.TEXT_NODE && ((childNodes.item(0)).getNodeValue().trim().length() == 0))) {
- XMLModel structuredModel = newNode.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- int startTagStartOffset = newNode.getStartOffset();
- int offset = endTagStructuredDocumentRegion.getStart();
- int length = endTagStructuredDocumentRegion.getLength();
- structuredDocument.replaceText(structuredDocument, offset, length, ""); //$NON-NLS-1$
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
-
- offset = startTagStructuredDocumentRegion.getStart() + lastRegion.getStart();
- structuredDocument.replaceText(structuredDocument, offset, 0, "/"); //$NON-NLS-1$
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- }
- }
- }
-
- return newNode;
- }
-
- private XMLNode insertRequiredAttrs(XMLNode node) {
- boolean insertRequiredAttrs = getCleanupPreferences().getInsertRequiredAttrs();
- XMLNode newNode = node;
-
- if (insertRequiredAttrs) {
- List requiredAttrs = getRequiredAttrs(newNode);
- if (requiredAttrs.size() > 0) {
- NamedNodeMap currentAttrs = node.getAttributes();
- List insertAttrs = new ArrayList();
- if (currentAttrs.getLength() == 0)
- insertAttrs.addAll(requiredAttrs);
- else {
- for (int i = 0; i < requiredAttrs.size(); i++) {
- String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName();
- boolean found = false;
- for (int j = 0; j < currentAttrs.getLength(); j++) {
- String currentAttrName = currentAttrs.item(j).getNodeName();
- if (requiredAttrName.compareTo(currentAttrName) == 0) {
- found = true;
- break;
- }
- }
- if (!found)
- insertAttrs.add(requiredAttrs.get(i));
- }
- }
- if (insertAttrs.size() > 0) {
- IStructuredDocumentRegion startStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
- int index = startStructuredDocumentRegion.getEndOffset();
- ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion();
- if (lastRegion.getType() == XMLRegionContext.XML_TAG_CLOSE) {
- index--;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- else if (lastRegion.getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE) {
- index = index - 2;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- try {
- for (int i = insertAttrs.size() - 1; i >= 0; i--) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
- String requiredAttributeName = attrDecl.getAttrName();
- String defaultValue = attrDecl.getDefaultValue();
- if (defaultValue == null)
- defaultValue = ""; //$NON-NLS-1$
- String nameAndDefaultValue = " "; //$NON-NLS-1$
- if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
- nameAndDefaultValue = ""; //$NON-NLS-1$
- nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
- // BUG3381: MultiTextEdit applies all child TextEdit's basing on offsets
- // in the document before the first TextEdit, not after each
- // child TextEdit. Therefore, do not need to advance the index.
- //index += nameAndDefaultValue.length();
- }
- multiTextEdit.apply(newNode.getStructuredDocument());
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
- }
- }
-
- return newNode;
- }
-
-
- protected ModelQuery getModelQuery(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return ModelQueryUtil.getModelQuery((Document) node);
- }
- else {
- return ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- }
- }
-
- protected List getRequiredAttrs(Node node) {
- List result = new ArrayList();
-
- ModelQuery modelQuery = getModelQuery(node);
- if (modelQuery != null) {
- CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
- if (elementDecl != null) {
- CMNamedNodeMap attrMap = elementDecl.getAttributes();
- Iterator it = attrMap.iterator();
- CMAttributeDeclaration attr = null;
- while (it.hasNext()) {
- attr = (CMAttributeDeclaration) it.next();
- if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
- result.add(attr);
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * A tag is implicit if it has not corresponding region in document.
- *
- * @param renamedNode
- * @return
- */
- private boolean isImplicitTag(XMLNode renamedNode) {
- return renamedNode.getStartStructuredDocumentRegion() == null;
- }
-
- /**
- * @param renamedNode
- * @return
- */
- private boolean isCommentTag(Node renamedNode) {
- boolean result = false;
- if (renamedNode instanceof XMLElement) {
- XMLElement element = (XMLElement) renamedNode;
- result = element.isCommentTag();
- }
- return result;
- }
-
- protected Node cleanupChildren(Node node) {
- Node parentNode = node;
-
- if (node != null) {
- Node childNode = node.getFirstChild();
- while (childNode != null) {
- // get cleanup handler
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler(childNode);
-
- // cleanup each child
- childNode = cleanupHandler.cleanup(childNode);
-
- // get new parent node
- parentNode = (XMLNode) childNode.getParentNode();
-
- // get next child node
- childNode = (XMLNode) childNode.getNextSibling();
- }
- }
-
- return parentNode;
- }
-
- private boolean isEmptyElement(XMLElement element) {
- Document document = element.getOwnerDocument();
- if (document == null)
- // undefined tag, return default
- return false;
-
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery == null)
- // undefined tag, return default
- return false;
-
- CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
- if (decl == null)
- // undefined tag, return default
- return false;
-
- return (decl.getContentType() == CMElementDeclaration.EMPTY);
- }
-
- private XMLNode insertEndTag(XMLNode node) {
- XMLNode newNode = node;
- XMLElement element = (XMLElement) node;
- if (element.isCommentTag())
- return node; // do nothing
-
- int startTagStartOffset = node.getStartOffset();
- XMLModel structuredModel = node.getModel();
-
- if (isEmptyElement(element)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- ITextRegionList regions = startStructuredDocumentRegion.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), lastRegion.getLength(), EMPTY_TAG_CLOSE);
-
- if (regions.size() > 1) {
- ITextRegion regionBeforeTagClose = regions.get(regions.size() - 1 - 1);
-
- // insert a space separator before tag close if the previous
- // region does not have extra spaces
- if (regionBeforeTagClose.getTextLength() == regionBeforeTagClose.getLength())
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$
- }
- }
- else {
- String tagName = node.getNodeName();
- String endTag = END_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
-
- XMLNode lastChild = (XMLNode) node.getLastChild();
- int endTagStartOffset = 0;
- if (lastChild != null)
- // if this node has children, insert the end tag after the
- // last child
- endTagStartOffset = lastChild.getEndOffset();
- else
- // if this node does not has children, insert the end tag
- // after the start tag
- endTagStartOffset = node.getEndOffset();
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, endTagStartOffset, 0, endTag);
- }
-
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
-
- return newNode;
- }
-
- private XMLNode insertMissingTags(XMLNode node) {
- boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags();
- XMLNode newNode = node;
-
- if (insertMissingTags) {
- IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startTagStructuredDocumentRegion == null) {
- // implicit start tag; generate tag for it
- newNode = insertStartTag(node);
- startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
- }
-
- IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion();
- ITextRegionList startStructuredDocumentRegionRegions = startTagStructuredDocumentRegion.getRegions();
- if (startTagStructuredDocumentRegion != null && startStructuredDocumentRegionRegions != null && (startStructuredDocumentRegionRegions.get(startStructuredDocumentRegionRegions.size() - 1)).getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE) {
-
- }
- else {
- if (startTagStructuredDocumentRegion == null) {
- // start tag missing
- if (isStartTagRequired(newNode))
- newNode = insertStartTag(newNode);
- }
- else if (endTagStructuredDocumentRegion == null) {
- // end tag missing
- if (isEndTagRequired(newNode))
- newNode = insertEndTag(newNode);
- }
- }
- }
-
- return newNode;
- }
-
- private XMLNode insertStartTag(XMLNode node) {
- XMLNode newNode = node;
-
- if (isCommentTag(node))
- return node; // do nothing
-
- String tagName = node.getNodeName();
- String startTag = START_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
- int startTagStartOffset = node.getStartOffset();
-
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, startTagStartOffset, 0, startTag);
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
-
- return newNode;
- }
-
- private void insertTagClose(XMLModel structuredModel, IStructuredDocumentRegion flatNode) {
- if (flatNode != null) {
- ITextRegionList flatnodeRegions = flatNode.getRegions();
- if (flatnodeRegions != null) {
- ITextRegion lastRegion = flatnodeRegions.get(flatnodeRegions.size() - 1);
- if (lastRegion != null) {
- String regionType = lastRegion.getType();
- if ((regionType != XMLRegionContext.XML_EMPTY_TAG_CLOSE) && (regionType != XMLRegionContext.XML_TAG_CLOSE)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- // insert ">" after lastRegion of flatNode
- // as in "<a</a>" if flatNode is for start tag, or in
- // "<a></a" if flatNode is for end tag
- structuredDocument.replaceText(structuredDocument, flatNode.getTextEndOffset(lastRegion), 0, ">"); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- private boolean isEndTagRequired(XMLNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- /**
- * The end tags of HTML EMPTY content type, such as IMG, and HTML
- * undefined tags are parsed separately from the start tags. So inserting
- * the missing start tag is useless and even harmful.
- */
- private boolean isStartTagRequired(XMLNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- private boolean isXMLType(XMLModel structuredModel) {
- boolean result = false;
-
- if (structuredModel != null && structuredModel != null) {
- XMLDocument document = structuredModel.getDocument();
-
- if (document != null)
- result = document.isXMLType();
- }
-
- return result;
- }
-
- private XMLNode quoteAttrValue(XMLNode node) {
- XMLNode newNode = node;
- //XMLElement element = (XMLElement) node;
- if (isCommentTag(node))
- return node; // do nothing
-
- boolean quoteAttrValues = getCleanupPreferences().getQuoteAttrValues();
-
- if (quoteAttrValues) {
- NamedNodeMap attributes = newNode.getAttributes();
- if (attributes != null) {
- int attributesLength = attributes.getLength();
- XMLGenerator generator = node.getModel().getGenerator();
-
- for (int i = 0; i < attributesLength; i++) {
- attributes = newNode.getAttributes();
- attributesLength = attributes.getLength();
- XMLAttr eachAttr = (XMLAttr) attributes.item(i);
- //ITextRegion oldAttrValueRegion =
- // eachAttr.getValueRegion();
- String oldAttrValue = eachAttr.getValueRegionText();
- if (oldAttrValue == null) {
- XMLModel structuredModel = node.getModel();
- if (isXMLType(structuredModel)) {
- String newAttrValue = "\"" + eachAttr.getNameRegionText() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- if (eachAttr.getEqualRegion() != null)
- // equal region exists
- structuredDocument.replaceText(structuredDocument, eachAttr.getEndOffset(), 0, newAttrValue);
- else
- // no equal region
- structuredDocument.replaceText(structuredDocument, eachAttr.getNameRegionTextEndOffset(), 0, "=".concat(newAttrValue)); //$NON-NLS-1$
- newNode = (XMLNode) structuredModel.getIndexedRegion(node.getStartOffset()); // save
- // new
- // node
- }
- }
- else {
- //String oldAttrValue = oldAttrValueRegion.getText();
- char quote = StringUtils.isQuoted(oldAttrValue) ? oldAttrValue.charAt(0) : DOUBLE_QUOTE;
- String newAttrValue = generator.generateAttrValue(eachAttr, quote);
-
- // There is a problem in
- // StructuredDocumentRegionUtil.getAttrValue(ITextRegion)
- // when the region is instanceof ContextRegion.
- // Workaround for now...
- if (oldAttrValue.length() == 1) {
- char firstChar = oldAttrValue.charAt(0);
- if (firstChar == SINGLE_QUOTE)
- newAttrValue = SINGLE_QUOTES;
- else if (firstChar == DOUBLE_QUOTE)
- newAttrValue = DOUBLE_QUOTES;
- }
-
- if (newAttrValue != null) {
- if (newAttrValue.compareTo(oldAttrValue) != 0) {
- int attrValueStartOffset = eachAttr.getValueRegionStartOffset();
- int attrValueLength = oldAttrValue.length();
- int startTagStartOffset = node.getStartOffset();
-
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, attrValueStartOffset, attrValueLength, newAttrValue);
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
- // new
- // node
- }
- }
- }
- }
- }
- }
-
- return newNode;
- }
-
- protected IStructuredCleanupHandler getCleanupHandler(Node node) {
- short nodeType = node.getNodeType();
- IStructuredCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case org.w3c.dom.Node.ELEMENT_NODE : {
- cleanupHandler = new ElementNodeCleanupHandler();
- break;
- }
- case org.w3c.dom.Node.TEXT_NODE : {
- cleanupHandler = new NodeCleanupHandler();
- break;
- }
- default : {
- cleanupHandler = new NodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
-
- return cleanupHandler;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/NodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/NodeCleanupHandler.java
deleted file mode 100644
index 44bb453..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/NodeCleanupHandler.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupHandler;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.cleanup.StructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.xml.core.XMLModelPlugin;
-import org.w3c.dom.Node;
-
-
-public class NodeCleanupHandler implements IStructuredCleanupHandler {
-
- protected IStructuredCleanupPreferences fCleanupPreferences = null;
- protected IProgressMonitor fProgressMonitor = null;
-
- /**
- */
- public Node cleanup(Node node) {
-
- return node;
- }
-
- public void setCleanupPreferences(IStructuredCleanupPreferences cleanupPreferences) {
-
- fCleanupPreferences = cleanupPreferences;
- }
-
- /**
- */
- public IStructuredCleanupPreferences getCleanupPreferences() {
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new StructuredCleanupPreferences();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fCleanupPreferences.setTagNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE));
- fCleanupPreferences.setAttrNameCase(preferences.getInt(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE));
- fCleanupPreferences.setCompressEmptyElementTags(preferences.getBoolean(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCleanupPreferences.setInsertRequiredAttrs(preferences.getBoolean(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS));
- fCleanupPreferences.setInsertMissingTags(preferences.getBoolean(CommonModelPreferenceNames.INSERT_MISSING_TAGS));
- fCleanupPreferences.setQuoteAttrValues(preferences.getBoolean(CommonModelPreferenceNames.QUOTE_ATTR_VALUES));
- fCleanupPreferences.setFormatSource(preferences.getBoolean(CommonModelPreferenceNames.FORMAT_SOURCE));
- fCleanupPreferences.setConvertEOLCodes(preferences.getBoolean(CommonModelPreferenceNames.CONVERT_EOL_CODES));
- fCleanupPreferences.setEOLCode(preferences.getString(CommonModelPreferenceNames.CLEANUP_EOL_CODE));
- }
- }
-
- return fCleanupPreferences;
- }
-
- protected Preferences getModelPreferences() {
- return XMLModelPlugin.getDefault().getPluginPreferences();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupHandler.java
deleted file mode 100644
index db2ab65..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupHandler.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-
-
-import org.w3c.dom.Node;
-
-/**
- * @deprecated renamed to IStructuredCleanupHandler
- *
- * TODO will delete in C5
- */
-public interface XMLCleanupHandler {
- Node cleanup(Node node);
-
- void setCleanupPreferences(XMLCleanupPreferences cleanupPreferences);
-
- XMLCleanupPreferences getCleanupPreferences();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferences.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferences.java
deleted file mode 100644
index 2f84d6f..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferences.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-
-/**
- * @deprecated renamed to IStructuredCleanupPreferences
- *
- * TODO will delete in C5
- */
-public interface XMLCleanupPreferences {
- int getTagNameCase();
-
- int getAttrNameCase();
-
- boolean getInsertMissingTags();
-
- boolean getQuoteAttrValues();
-
- boolean getFormatSource();
-
- boolean getConvertEOLCodes();
-
- String getEOLCode();
-
- void setTagNameCase(int tagNameCase);
-
- void setAttrNameCase(int attrNameCase);
-
- void setInsertMissingTags(boolean insertMissingTags);
-
- void setQuoteAttrValues(boolean quoteAttrValues);
-
- void setFormatSource(boolean formatSource);
-
- void setConvertEOLCodes(boolean convertEOLCodes);
-
- void setEOLCode(String EOLCode);
-
- //void setPreferenceStore(IPreferenceStore preferenceStore);
- void setPreferences(Preferences preferences);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferencesImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferencesImpl.java
deleted file mode 100644
index e05fbfb..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupPreferencesImpl.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.xml.core.XMLPreferenceNames;
-
-
-/**
- * @deprecated renamed to StructuredCleanupPreferences
- *
- * TODO will delete in C5
- */
-public class XMLCleanupPreferencesImpl implements XMLCleanupPreferences {
-
- private static XMLCleanupPreferencesImpl fInstance;
- private int fTagNameCase;
- private int fAttrNameCase;
- private boolean fInsertMissingTags;
- private boolean fQuoteAttrValues;
- private boolean fFormatSource;
- private boolean fConvertEOLCodes;
- private String fEOLCode;
- //private IPreferenceStore fPreferenceStore = null;
- private Preferences fPreferences = null;
-
- public int getTagNameCase() {
-
- return fTagNameCase;
- }
-
- public int getAttrNameCase() {
-
- return fAttrNameCase;
- }
-
- public boolean getInsertMissingTags() {
-
- return fInsertMissingTags;
- }
-
- public boolean getQuoteAttrValues() {
-
- return fQuoteAttrValues;
- }
-
- public boolean getFormatSource() {
-
- return fFormatSource;
- }
-
- public boolean getConvertEOLCodes() {
-
- return fConvertEOLCodes;
- }
-
- public String getEOLCode() {
-
- return fEOLCode;
- }
-
- public void setTagNameCase(int tagNameCase) {
-
- fTagNameCase = tagNameCase;
- }
-
- public void setAttrNameCase(int attrNameCase) {
-
- fAttrNameCase = attrNameCase;
- }
-
- public void setInsertMissingTags(boolean insertMissingTags) {
-
- fInsertMissingTags = insertMissingTags;
- }
-
- public void setQuoteAttrValues(boolean quoteAttrValues) {
-
- fQuoteAttrValues = quoteAttrValues;
- }
-
- public void setFormatSource(boolean formatSource) {
-
- fFormatSource = formatSource;
- }
-
- public void setConvertEOLCodes(boolean convertEOLCodes) {
-
- fConvertEOLCodes = convertEOLCodes;
- }
-
- public void setEOLCode(String EOLCode) {
-
- fEOLCode = EOLCode;
- }
-
- public Preferences getPreferences() {
-
- if (fPreferences == null) {
- fPreferences = getModelManagerPlugin().getPluginPreferences();
- }
- return fPreferences;
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- public void setPreferences(Preferences prefs) {
-
- fPreferences = prefs;
- updateOptions();
- }
-
- protected void updateOptions() {
-
- Preferences p = getPreferences();
- fTagNameCase = p.getInt(XMLPreferenceNames.CLEANUP_TAG_NAME_CASE);
- fAttrNameCase = p.getInt(XMLPreferenceNames.CLEANUP_ATTR_NAME_CASE);
- fInsertMissingTags = p.getBoolean(XMLPreferenceNames.INSERT_MISSING_TAGS);
- fQuoteAttrValues = p.getBoolean(XMLPreferenceNames.QUOTE_ATTR_VALUES);
- fFormatSource = p.getBoolean(XMLPreferenceNames.FORMAT_SOURCE);
- fConvertEOLCodes = p.getBoolean(XMLPreferenceNames.CONVERT_EOL_CODES);
- fEOLCode = p.getString(XMLPreferenceNames.CLEANUP_EOL_CODE);
- }
-
- public synchronized static XMLCleanupPreferencesImpl getInstance() {
-
- // added for one method in CleanupDialog ... may be better way
- if (fInstance == null) {
- fInstance = new XMLCleanupPreferencesImpl();
- }
- return fInstance;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupProcessorImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupProcessorImpl.java
deleted file mode 100644
index 7840c83..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLCleanupProcessorImpl.java
+++ /dev/null
@@ -1,541 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.encoding.content.IContentTypeIdentifier;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.cleanup.CleanupProcessor;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.Logger;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.format.FormatProcessorXML;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-/**
- * @deprecated renamed to CleanupProcessorXML
- *
- * TODO will delete in C5
- */
-public class XMLCleanupProcessorImpl implements CleanupProcessor {
-
- protected XMLCleanupPreferences fCleanupPreferences = null;
-
- public String cleanupContent(String input) {
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String cleanupContent(String input, int start, int length) {
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file) {
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save();
- }
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file, int start, int length) {
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save();
- }
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName) {
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName, int start, int length) {
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupModel(IStructuredModel structuredModel) {
-
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
- cleanupModel(structuredModel, start, length);
- }
-
- public void cleanupModel(IStructuredModel structuredModel, int start, int length) {
-
- if (structuredModel != null) {
- if ((start >= 0) && (length <= structuredModel.getStructuredDocument().getLength())) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- XMLNode firstNode = (XMLNode) activeNodes.firstElement();
- XMLNode lastNode = (XMLNode) activeNodes.lastElement();
- boolean done = false;
- XMLNode eachNode = firstNode;
- XMLNode nextNode = null;
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before cleanup because eachNode may
- // be deleted,
- // for example when it's an empty text node
- nextNode = (XMLNode) eachNode.getNextSibling();
-
- // cleanup selected node(s)
- _cleanupNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during cleanup
- eachNode = (XMLNode) eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
- }
-
- // format source
- if (getFormatSourcePreference(structuredModel)) {
- // format the document
- IStructuredFormatProcessor formatProcessor = createFormatProcessor();
- formatProcessor.formatModel(structuredModel);
- }
-
- // convert EOL codes
- if (getConvertEOLCodesPreference(structuredModel)) {
- IDocument document = structuredModel.getStructuredDocument();
- String endOfLineCode = getEOLCodePreference(structuredModel);
- String endOfLineCodeString = null;
- if (endOfLineCode.compareTo(CommonModelPreferenceNames.LF) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_LF;
- else if (endOfLineCode.compareTo(CommonModelPreferenceNames.CR) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_CR;
- else if (endOfLineCode.compareTo(CommonModelPreferenceNames.CRLF) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_CRLF;
- if (endOfLineCodeString != null) {
- convertLineDelimiters(document, endOfLineCodeString);
- // DMW: 8/24/2002 setting line delimiter in
- // document allows
- // subsequent editing to insert the same line
- // delimiter.
- if (document instanceof IStructuredDocument) {
- ((IStructuredDocument) document).setLineDelimiter(endOfLineCodeString);
- }
- structuredModel.setDirtyState(true);
- }
- }
-
- // clear fCleanupPreferences so CleanupProcessor will
- // retrieve the latest preferences next time
- fCleanupPreferences = null;
- }
- }
- }
- }
-
- protected void _cleanupNode(XMLNode node) {
-
- if (node != null) {
- XMLNode cleanupNode = node;
-
- // cleanup the owner node if it's an attribute node
- if (cleanupNode.getNodeType() == Node.ATTRIBUTE_NODE)
- cleanupNode = (XMLNode) ((Attr) cleanupNode).getOwnerElement();
-
- // get cleanup handler
- XMLCleanupHandler cleanupHandler = getCleanupHandler(cleanupNode);
- if (cleanupHandler != null) {
- // cleanup each node
- cleanupHandler.cleanup(cleanupNode);
- }
- }
- }
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
-
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- protected Vector getActiveNodes(IStructuredModel structuredModel, int startNodeOffset, int length) {
-
- Vector activeNodes = new Vector();
- if (structuredModel != null) {
- Node startNode = (Node) structuredModel.getIndexedRegion(startNodeOffset);
- Node endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
-
- // make sure it's an non-empty document
- if (startNode != null) {
- while (isSiblingOf(startNode, endNode) == false) {
- if (endNode != null)
- endNode = endNode.getParentNode();
- if (endNode == null) {
- startNode = startNode.getParentNode();
- endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
- }
- }
- while (startNode != endNode) {
- activeNodes.addElement(startNode);
- startNode = startNode.getNextSibling();
- }
- if (startNode != null)
- activeNodes.addElement(startNode);
- }
- }
- return activeNodes;
- }
-
- protected boolean isSiblingOf(Node node, Node endNode) {
-
- if (endNode == null) {
- return true;
- }
- else {
- Node siblingNode = node;
- while (siblingNode != null) {
- if (siblingNode == endNode)
- return true;
- else
- siblingNode = siblingNode.getNextSibling();
- }
- return false;
- }
- }
-
- protected IModelManager getModelManager() {
-
- return ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- }
-
- protected void convertLineDelimiters(IDocument document, String newDelimiter) {
-
- final int lineCount = document.getNumberOfLines();
- IDocumentPartitioner partitioner = document.getDocumentPartitioner();
- if (partitioner != null) {
- partitioner.disconnect();
- document.setDocumentPartitioner(null);
- }
- try {
- for (int i = 0; i < lineCount; i++) {
- final String delimiter = document.getLineDelimiter(i);
- if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(newDelimiter)) {
- IRegion region = document.getLineInformation(i);
- document.replace(region.getOffset() + region.getLength(), delimiter.length(), newDelimiter);
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- finally {
- if (partitioner != null) {
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
- }
- }
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- public XMLCleanupPreferences getCleanupPreferences() {
-
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new XMLCleanupPreferencesImpl();
- Preferences preferences = getModelManagerPlugin().getPluginPreferences();
- if (preferences != null) {
- fCleanupPreferences.setPreferences(preferences);
- }
- }
- return fCleanupPreferences;
- }
-
- protected boolean getFormatSourcePreference(IStructuredModel structuredModel) {
-
- boolean formatSource = true;
- XMLCleanupHandler cleanupHandler = getCleanupHandler((XMLNode) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- XMLCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- formatSource = cleanupPreferences.getFormatSource();
- }
- return formatSource;
- }
-
- protected boolean getConvertEOLCodesPreference(IStructuredModel structuredModel) {
-
- boolean convertEOLCodes = true;
- XMLCleanupHandler cleanupHandler = getCleanupHandler((XMLNode) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- XMLCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- convertEOLCodes = cleanupPreferences.getConvertEOLCodes();
- }
- return convertEOLCodes;
- }
-
- protected String getEOLCodePreference(IStructuredModel structuredModel) {
-
- String eolCode = System.getProperty("line.separator"); //$NON-NLS-1$
-
- XMLCleanupHandler cleanupHandler = getCleanupHandler((XMLNode) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- XMLCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- eolCode = cleanupPreferences.getEOLCode();
- }
- return eolCode;
- }
-
- protected String getContentType() {
-
- return IContentTypeIdentifier.ContentTypeID_SSEXML;
- }
-
- protected XMLCleanupHandler getCleanupHandler(XMLNode node) {
-
- short nodeType = ((Node) node).getNodeType();
- XMLCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE :
- {
- cleanupHandler = new XMLElementNodeCleanupHandler();
- break;
- }
- case Node.TEXT_NODE :
- {
- cleanupHandler = new XMLNodeCleanupHandler();
- break;
- }
- default :
- {
- cleanupHandler = new XMLNodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
- return cleanupHandler;
- }
-
- protected IStructuredFormatProcessor createFormatProcessor() {
-
- return new FormatProcessorXML();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLElementNodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLElementNodeCleanupHandler.java
deleted file mode 100644
index 6cf11f5..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLElementNodeCleanupHandler.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.document.XMLAttr;
-import org.eclipse.wst.xml.core.document.XMLDocument;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.eclipse.wst.xml.core.document.XMLGenerator;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-/**
- * @deprecated renamed to ElementNodeCleanupHandler
- *
- * TODO will delete in C5
- */
-public class XMLElementNodeCleanupHandler extends XMLNodeCleanupHandler {
-
- /** Non-NLS strings */
- protected static final String START_TAG_OPEN = "<"; //$NON-NLS-1$
- protected static final String END_TAG_OPEN = "</"; //$NON-NLS-1$
- protected static final String TAG_CLOSE = ">"; //$NON-NLS-1$
- protected static final String EMPTY_TAG_CLOSE = "/>"; //$NON-NLS-1$
- protected static final String SINGLE_QUOTES = "''"; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTES = "\"\""; //$NON-NLS-1$
- protected static final char SINGLE_QUOTE = '\''; //$NON-NLS-1$
- protected static final char DOUBLE_QUOTE = '\"'; //$NON-NLS-1$
-
- public Node cleanup(Node node) {
- Node newNode = cleanupChildren(node);
- XMLNode renamedNode = newNode instanceof XMLNode ? (XMLNode) newNode : null;
-
- // call quoteAttrValue() first so it will close any unclosed attr
- // quoteAttrValue() will return the new start tag if there is a structure change
- renamedNode = quoteAttrValue(renamedNode);
-
- // insert tag close if missing
- // if node is not comment tag
- // and not implicit tag
- if (!isCommentTag(renamedNode) && !isImplicitTag(renamedNode)) {
- XMLModel structuredModel = renamedNode.getModel();
-
- // save start offset before insertTagClose()
- // or else renamedNode.getStartOffset() will be zero if renamedNode replaced by insertTagClose()
- int startTagStartOffset = renamedNode.getStartOffset();
-
- // for start tag
- IStructuredDocumentRegion startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
- insertTagClose(structuredModel, startTagStructuredDocumentRegion);
-
- // update renamedNode and startTagStructuredDocumentRegion after insertTagClose()
- renamedNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset);
- startTagStructuredDocumentRegion = renamedNode.getStartStructuredDocumentRegion();
-
- // for end tag
- IStructuredDocumentRegion endTagStructuredDocumentRegion = renamedNode.getEndStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion != startTagStructuredDocumentRegion)
- insertTagClose(structuredModel, endTagStructuredDocumentRegion);
- }
-
- // call insertMissingTags() next, it will generate implicit tags if there are any
- // insertMissingTags() will return the new missing start tag if one is missing
- renamedNode = insertMissingTags(renamedNode);
-
- return renamedNode;
- }
-
- /**
- * A tag is implicit if it has not corresponding region in document.
- * @param renamedNode
- * @return
- */
- private boolean isImplicitTag(XMLNode renamedNode) {
- return renamedNode.getStartStructuredDocumentRegion() == null;
- }
-
- /**
- * @param renamedNode
- * @return
- */
- private boolean isCommentTag(Node renamedNode) {
- boolean result = false;
- if (renamedNode instanceof XMLElement) {
- XMLElement element = (XMLElement) renamedNode;
- result = element.isCommentTag();
- }
- return result;
- }
-
- protected Node cleanupChildren(Node node) {
- Node parentNode = node;
-
- if (node != null) {
- Node childNode = node.getFirstChild();
- while (childNode != null) {
- // get cleanup handler
- XMLCleanupHandler cleanupHandler = getCleanupHandler(childNode);
-
- // cleanup each child
- childNode = cleanupHandler.cleanup(childNode);
-
- // get new parent node
- parentNode = (XMLNode) childNode.getParentNode();
-
- // get next child node
- childNode = (XMLNode) childNode.getNextSibling();
- }
- }
-
- return parentNode;
- }
-
- private boolean isEmptyElement(XMLElement element) {
- Document document = element.getOwnerDocument();
- if (document == null)
- // undefined tag, return default
- return false;
-
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery == null)
- // undefined tag, return default
- return false;
-
- CMElementDeclaration decl = modelQuery.getCMElementDeclaration(element);
- if (decl == null)
- // undefined tag, return default
- return false;
-
- return (decl.getContentType() == CMElementDeclaration.EMPTY);
- }
-
- private XMLNode insertEndTag(XMLNode node) {
- XMLNode newNode = node;
- XMLElement element = (XMLElement) node;
- if (element.isCommentTag())
- return node; // do nothing
-
- int startTagStartOffset = node.getStartOffset();
- XMLModel structuredModel = node.getModel();
-
- if (isEmptyElement(element)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- ITextRegionList regions = startStructuredDocumentRegion.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), lastRegion.getLength(), EMPTY_TAG_CLOSE);
-
- if (regions.size() > 1) {
- ITextRegion regionBeforeTagClose = regions.get(regions.size() - 1 - 1);
-
- // insert a space separator before tag close if the previous region does not have extra spaces
- if (regionBeforeTagClose.getTextLength() == regionBeforeTagClose.getLength())
- structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$
- }
- }
- else {
- String tagName = node.getNodeName();
- String endTag = END_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
-
- XMLNode lastChild = (XMLNode) node.getLastChild();
- int endTagStartOffset = 0;
- if (lastChild != null)
- // if this node has children, insert the end tag after the last child
- endTagStartOffset = lastChild.getEndOffset();
- else
- // if this node does not has children, insert the end tag after the start tag
- endTagStartOffset = node.getEndOffset();
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, endTagStartOffset, 0, endTag);
- }
-
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node
-
- return newNode;
- }
-
- private XMLNode insertMissingTags(XMLNode node) {
- boolean insertMissingTags = getCleanupPreferences().getInsertMissingTags();
- XMLNode newNode = node;
-
- if (insertMissingTags) {
- IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startTagStructuredDocumentRegion == null) {
- // implicit start tag; generate tag for it
- newNode = insertStartTag(node);
- startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
- }
-
- IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion();
- ITextRegionList startStructuredDocumentRegionRegions = startTagStructuredDocumentRegion.getRegions();
- if (startTagStructuredDocumentRegion != null && startStructuredDocumentRegionRegions != null && (startStructuredDocumentRegionRegions.get(startStructuredDocumentRegionRegions.size() - 1)).getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE) {
-
- }
- else {
- if (startTagStructuredDocumentRegion == null) {
- // start tag missing
- if (isStartTagRequired(newNode))
- newNode = insertStartTag(newNode);
- }
- else if (endTagStructuredDocumentRegion == null) {
- // end tag missing
- if (isEndTagRequired(newNode))
- newNode = insertEndTag(newNode);
- }
- }
- }
-
- return newNode;
- }
-
- private XMLNode insertStartTag(XMLNode node) {
- XMLNode newNode = node;
-
- if (isCommentTag(node))
- return node; // do nothing
-
- String tagName = node.getNodeName();
- String startTag = START_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
- int startTagStartOffset = node.getStartOffset();
-
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, startTagStartOffset, 0, startTag);
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node
-
- return newNode;
- }
-
- private void insertTagClose(XMLModel structuredModel, IStructuredDocumentRegion flatNode) {
- if (flatNode != null) {
- ITextRegionList flatnodeRegions = flatNode.getRegions();
- if (flatnodeRegions != null) {
- ITextRegion lastRegion = flatnodeRegions.get(flatnodeRegions.size() - 1);
- if (lastRegion != null) {
- String regionType = lastRegion.getType();
- if ((regionType != XMLRegionContext.XML_EMPTY_TAG_CLOSE) && (regionType != XMLRegionContext.XML_TAG_CLOSE)) {
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- // insert ">" after lastRegion of flatNode
- // as in "<a</a>" if flatNode is for start tag, or in "<a></a" if flatNode is for end tag
- structuredDocument.replaceText(structuredDocument, flatNode.getTextEndOffset(lastRegion), 0, ">"); //$NON-NLS-1$
- }
- }
- }
- }
- }
-
- private boolean isEndTagRequired(XMLNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- /**
- * The end tags of HTML EMPTY content type, such as IMG,
- * and HTML undefined tags are parsed separately from the start tags.
- * So inserting the missing start tag is useless and even harmful.
- */
- private boolean isStartTagRequired(XMLNode node) {
- if (node == null)
- return false;
- return node.isContainer();
- }
-
- private boolean isXMLType(XMLModel structuredModel) {
- boolean result = false;
-
- if (structuredModel != null && structuredModel != null) {
- XMLDocument document = structuredModel.getDocument();
-
- if (document != null)
- result = document.isXMLType();
- }
-
- return result;
- }
-
- private XMLNode quoteAttrValue(XMLNode node) {
- XMLNode newNode = node;
- //XMLElement element = (XMLElement) node;
- if (isCommentTag(node))
- return node; // do nothing
-
- boolean quoteAttrValues = getCleanupPreferences().getQuoteAttrValues();
-
- if (quoteAttrValues) {
- NamedNodeMap attributes = newNode.getAttributes();
- if (attributes != null) {
- int attributesLength = attributes.getLength();
- XMLGenerator generator = node.getModel().getGenerator();
-
- for (int i = 0; i < attributesLength; i++) {
- attributes = newNode.getAttributes();
- attributesLength = attributes.getLength();
- XMLAttr eachAttr = (XMLAttr) attributes.item(i);
- //ITextRegion oldAttrValueRegion = eachAttr.getValueRegion();
- String oldAttrValue = eachAttr.getValueRegionText();
- if (oldAttrValue == null) {
- XMLModel structuredModel = node.getModel();
- if (isXMLType(structuredModel)) {
- String newAttrValue = "\"" + eachAttr.getNameRegionText() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
-
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- if (eachAttr.getEqualRegion() != null)
- // equal region exists
- structuredDocument.replaceText(structuredDocument, eachAttr.getEndOffset(), 0, newAttrValue);
- else
- // no equal region
- structuredDocument.replaceText(structuredDocument, eachAttr.getNameRegionTextEndOffset(), 0, "=".concat(newAttrValue)); //$NON-NLS-1$
- newNode = (XMLNode) structuredModel.getIndexedRegion(node.getStartOffset()); // save new node
- }
- }
- else {
- //String oldAttrValue = oldAttrValueRegion.getText();
- char quote = StringUtils.isQuoted(oldAttrValue) ? oldAttrValue.charAt(0) : DOUBLE_QUOTE;
- String newAttrValue = generator.generateAttrValue(eachAttr, quote);
-
- // There is a problem in StructuredDocumentRegionUtil.getAttrValue(ITextRegion) when the region is instanceof ContextRegion.
- // Workaround for now...
- if (oldAttrValue.length() == 1) {
- char firstChar = oldAttrValue.charAt(0);
- if (firstChar == SINGLE_QUOTE)
- newAttrValue = SINGLE_QUOTES;
- else if (firstChar == DOUBLE_QUOTE)
- newAttrValue = DOUBLE_QUOTES;
- }
-
- if (newAttrValue != null) {
- if (newAttrValue.compareTo(oldAttrValue) != 0) {
- int attrValueStartOffset = eachAttr.getValueRegionStartOffset();
- int attrValueLength = oldAttrValue.length();
- int startTagStartOffset = node.getStartOffset();
-
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- structuredDocument.replaceText(structuredDocument, attrValueStartOffset, attrValueLength, newAttrValue);
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node
- }
- }
- }
- }
- }
- }
-
- return newNode;
- }
-
- protected XMLCleanupHandler getCleanupHandler(Node node) {
- short nodeType = node.getNodeType();
- XMLCleanupHandler cleanupHandler = null;
- switch (nodeType) {
- case org.w3c.dom.Node.ELEMENT_NODE :
- {
- cleanupHandler = new XMLElementNodeCleanupHandler();
- break;
- }
- case org.w3c.dom.Node.TEXT_NODE :
- {
- cleanupHandler = new XMLNodeCleanupHandler();
- break;
- }
- default :
- {
- cleanupHandler = new XMLNodeCleanupHandler();
- }
- }
-
- // init CleanupPreferences
- cleanupHandler.setCleanupPreferences(getCleanupPreferences());
-
- return cleanupHandler;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLNodeCleanupHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLNodeCleanupHandler.java
deleted file mode 100644
index cbd79ba..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/cleanup/XMLNodeCleanupHandler.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.cleanup;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.w3c.dom.Node;
-
-/**
- * @deprecated renamed to NodeCleanupHandler
- *
- * TODO will delete in C5
- */
-public class XMLNodeCleanupHandler implements XMLCleanupHandler {
-
- protected XMLCleanupPreferences fCleanupPreferences = null;
- protected IProgressMonitor fProgressMonitor = null;
-
- /**
- */
- public Node cleanup(Node node) {
-
- return node;
- }
-
- public void setCleanupPreferences(XMLCleanupPreferences cleanupPreferences) {
-
- fCleanupPreferences = cleanupPreferences;
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- /**
- */
- public XMLCleanupPreferences getCleanupPreferences() {
-
- if (fCleanupPreferences == null) {
- fCleanupPreferences = new XMLCleanupPreferencesImpl();
- Preferences preferenceStore = getModelManagerPlugin().getPluginPreferences();
- if (preferenceStore != null) {
- fCleanupPreferences.setPreferences(preferenceStore);
- }
- }
- return fCleanupPreferences;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementAdapter.java
deleted file mode 100644
index c3ca6b9..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementAdapter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement;
-
-
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.xml.core.commentelement.impl.CommentElementConfiguration;
-import org.eclipse.wst.xml.core.document.TagAdapter;
-import org.eclipse.wst.xml.core.document.XMLElement;
-
-
-/**
- */
-public class CommentElementAdapter implements TagAdapter {
- public CommentElementAdapter(boolean isEndTag, CommentElementHandler handler) {
- fEndTag = isEndTag;
- fHandler = handler;
- }
-
- /**
- */
- public String getStartTag(XMLElement element) {
- String content = fHandler.generateStartTagContent(element);
- if (content == null) {
- return null;
- }
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(generateCommentOpen(element));
- buffer.append(content);
- buffer.append(generateCommentClose(element));
-
- return buffer.toString();
- }
-
- /**
- */
- public String getEndTag(XMLElement element) {
- String content = fHandler.generateEndTagContent(element);
- if (content == null) {
- return null;
- }
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(generateCommentOpen(element));
- buffer.append(content);
- buffer.append(generateCommentClose(element));
-
- return buffer.toString();
- }
-
- public String getHandlerID() {
- return getConfiguration().getHandlerID();
- }
-
- public IPluginDescriptor getHandlerPluginDescriptor() {
- return fConfiguration.getHandlerPluginDescriptor();
- }
-
- /**
- */
- public boolean isEndTag() {
- return fEndTag;
- }
-
- public boolean isContainer() {
- return (!fHandler.isEmpty());
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == CommentElementAdapter.class || type == TagAdapter.class);
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- private String generateCommentOpen(XMLElement element) {
- return (element.isJSPTag()) ? "<%--" : "<!--"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String generateCommentClose(XMLElement element) {
- return (element.isJSPTag()) ? "--%>" : "-->"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void setConfiguration(CommentElementConfiguration configuration) {
- fConfiguration = configuration;
- }
-
- public String getProperty(String name) {
- return getConfiguration().getProperty(name);
- }
-
- private CommentElementConfiguration getConfiguration() {
- return fConfiguration;
- }
-
- private boolean fEndTag;
- private CommentElementHandler fHandler;
- private CommentElementConfiguration fConfiguration;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementHandler.java
deleted file mode 100644
index ad17725..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/CommentElementHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement;
-
-
-
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public interface CommentElementHandler {
- /**
- * This method is called when the prefix of the comment content matches
- * the string specified in <startswith prefix=""/> in plugin extension.
- * Comment content is parsed and new DOM element is created in this method.
- * Implementor has to do following:
- * <li>For start tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * </ul>
- * </li>
- * <li>For end tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * <li>make isEndTag flag true.</li>
- * <li>Parser framework searches mached start tag element instance after this createElement call, and new instance is just thrown away.</li>
- * </ul>
- * </li>
- * <li>For empty tag :
- * <ul>
- * <li>parse comment content and create new element instance.</li>
- * <li>make isEndTag flag true.</li>
- * </ul>
- * </li>
- *
- * @param document parent DOM document
- * @param data comment content. comment prefix (<!-- or <%--),
- * suffix (--> or --%>), and surrounding spaces are trimmed.
- * @param isJSPTag true if the comment is JSP style comment.
- * This information may be required by handler when the handler accepts
- * both XML style and JSP style comment (namely, commenttype="both" in plugin.xml).
- * @return comment element instance if the comment content is rightly parsed.
- * if parse failed, returns null.
- */
- Element createElement(Document document, String data, boolean isJSPTag);
-
- /**
- * This method generates the source text of the start tag for the passed element.
- * Do not generate comment prefix (<!-- or <%--) and suffix (--> or --%>).
- * XMLGenerator uses this method to generate XML/HTML source for a comment element.
- *
- * @param element the comment element
- * @return generated tag string
- */
- String generateStartTagContent(XMLElement element);
-
- /**
- * This method generates the source text of the end tag for the passed element.
- * Do not generate comment prefix (<!-- or <%--) and suffix (--> or --%>).
- * XMLGenerator uses this method to generate XML/HTML source for a comment element.
- *
- * @param element the comment element
- * @return generated tag string
- */
- String generateEndTagContent(XMLElement element);
-
- /**
- *
- * @return boolean whether this element can have children or not
- */
- boolean isEmpty();
-
- /**
- *
- * @param element the element
- * @return boolean whether the element is comment element or not
- */
- boolean isCommentElement(XMLElement element);
-
- /**
- * @return String
- */
- // String getElementPrefix();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/BasicCommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/BasicCommentElementHandler.java
deleted file mode 100644
index 2a71f6e..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/BasicCommentElementHandler.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement.impl;
-
-
-
-import org.eclipse.wst.xml.core.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.commentelement.util.CommentElementFactory;
-import org.eclipse.wst.xml.core.commentelement.util.TagScanner;
-import org.eclipse.wst.xml.core.document.XMLAttr;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.eclipse.wst.xml.core.document.XMLGenerator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-
-/**
- */
-class BasicCommentElementHandler implements CommentElementHandler {
-
- public BasicCommentElementHandler(String elementName, boolean isEmpty) {
- super();
- this.elementName = elementName;
- this.isEmpty = isEmpty;
- }
-
- /**
- */
- public Element createElement(Document document, String data, boolean isJSPTag) {
- Element element = null;
- String str = data.trim();
- CommentElementFactory factory = new CommentElementFactory(document, isJSPTag, this);
- if (str.charAt(0) == '/') { // end tag
- TagScanner scanner = new TagScanner(str, 1); // skip '/'
- String name = scanner.nextName();
- if (name.equals(elementName)) {
- element = factory.create(name, CommentElementFactory.IS_END);
- }
- }
- else { // start tag
- TagScanner scanner = new TagScanner(str, 0);
- String name = scanner.nextName();
- if (name.equals(elementName)) {
- element = factory.create(name, (isEmpty) ? CommentElementFactory.IS_EMPTY : CommentElementFactory.IS_START);
- // set attributes
- String attrName = scanner.nextName();
- while (attrName != null) {
- String attrValue = scanner.nextValue();
- Attr attr = document.createAttribute(attrName);
- if (attr != null) {
- if (attrValue != null)
- ((XMLAttr) attr).setValueSource(attrValue);
- element.setAttributeNode(attr);
- }
- attrName = scanner.nextName();
- }
- }
- }
- return element;
- }
-
- /**
- */
- public String generateStartTagContent(XMLElement element) {
- XMLGenerator generator = element.getModel().getGenerator();
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(' ');
- String tagName = generator.generateTagName(element);
- if (tagName != null) {
- buffer.append(tagName);
- }
-
- NamedNodeMap attributes = element.getAttributes();
- int length = attributes.getLength();
- for (int i = 0; i < length; i++) {
- Attr attr = (Attr) attributes.item(i);
- if (attr == null) {
- continue;
- }
- buffer.append(' ');
- String attrName = generator.generateAttrName(attr);
- if (attrName != null) {
- buffer.append(attrName);
- }
- String attrValue = generator.generateAttrValue(attr);
- if (attrValue != null) {
- // attr name only for HTML boolean and JSP
- buffer.append('=');
- buffer.append(attrValue);
- }
- }
-
- buffer.append(' ');
-
- return buffer.toString();
- }
-
- /**
- */
- public String generateEndTagContent(XMLElement element) {
- if (isEmpty) {
- return null;
- }
- XMLGenerator generator = element.getModel().getGenerator();
- StringBuffer buffer = new StringBuffer();
-
- buffer.append(" /"); //$NON-NLS-1$
- String tagName = generator.generateTagName(element);
- if (tagName != null) {
- buffer.append(tagName);
- }
- buffer.append(' ');
-
- return buffer.toString();
- }
-
- /* (non-Javadoc)
- */
- public boolean isCommentElement(XMLElement element) {
- return (element != null && element.getTagName().equals(elementName)) ? true : false;
- }
-
- /* (non-Javadoc)
- */
- public boolean isEmpty() {
- return isEmpty;
- }
-
- private String elementName;
- private boolean isEmpty;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementConfiguration.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementConfiguration.java
deleted file mode 100644
index 602bb54..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementConfiguration.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement.impl;
-
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.wst.xml.core.Logger;
-import org.eclipse.wst.xml.core.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementConfiguration {
- CommentElementConfiguration() {
- super();
- }
-
- CommentElementConfiguration(IConfigurationElement element) {
- super();
- fElement = element;
- fCustom = (element.getName().equalsIgnoreCase("handler-custom")) ? true : false; //$NON-NLS-1$
-
- fillAttributes(element);
-
- fXMLComment = fJSPComment = false;
- String commentType = getProperty("commenttype"); //$NON-NLS-1$
- if (commentType.equalsIgnoreCase("xml")) { //$NON-NLS-1$
- fXMLComment = true;
- }
- else if (commentType.equalsIgnoreCase("jsp")) { //$NON-NLS-1$
- fJSPComment = true;
- }
- else if (commentType.equalsIgnoreCase("both")) { //$NON-NLS-1$
- fXMLComment = fJSPComment = true;
- }
- String empty = getProperty("isempty"); //$NON-NLS-1$
- fEmpty = (empty != null && !empty.equals("false")) ? true : false; //$NON-NLS-1$
- }
-
- private void fillAttributes(IConfigurationElement element) {
- if (fAttributes == null) {
- fAttributes = new HashMap();
- }
- else {
- fAttributes.clear();
- }
- String[] names = element.getAttributeNames();
- if (names == null) {
- return;
- }
- int length = names.length;
- for (int i = 0; i < length; i++) {
- String name = names[i];
- fAttributes.put(name.toLowerCase(), element.getAttribute(name));
- }
- }
-
- public String getProperty(String name) {
- return (fAttributes != null) ? (String) fAttributes.get(name) : null;
- }
-
- public boolean acceptXMLComment() {
- return fXMLComment;
- }
-
- public boolean acceptJSPComment() {
- return fJSPComment;
- }
-
- public String[] getPrefix() {
- if (fPrefix == null) {
- if (fElement != null) {
- if (isCustom()) { // custom
- IConfigurationElement[] prefixes = fElement.getChildren("startwith"); //$NON-NLS-1$
- if (prefixes != null) {
- fPrefix = new String[prefixes.length];
- for (int i = 0; i < prefixes.length; i++) {
- fPrefix[i] = prefixes[i].getAttribute("prefix"); //$NON-NLS-1$
- }
- }
- }
- else { // basic
- String name = getProperty("elementname"); //$NON-NLS-1$
- if (name != null) {
- if (isEmpty()) {
- fPrefix = new String[1];
- fPrefix[0] = name;
- }
- else {
- fPrefix = new String[2];
- fPrefix[0] = name;
- fPrefix[1] = '/' + name;
- }
- }
- }
- }
- }
- if (fPrefix == null) {
- fPrefix = new String[1];
- fPrefix[0] = ""; //$NON-NLS-1$
- }
- return fPrefix;
- }
-
- public CommentElementHandler getHandler() {
- if (fHandler == null) {
- if (fElement != null) {
- try {
- if (isCustom()) {
- fHandler = (CommentElementHandler) fElement.createExecutableExtension("class"); //$NON-NLS-1$
- }
- else {
- String elementName = getProperty("elementname"); //$NON-NLS-1$
- fHandler = new BasicCommentElementHandler(elementName, fEmpty);
- }
- // ((AbstractCommentElementHandler)fHandler).setElementPrefix(fElement.getAttribute("prefix"));
- }
- catch (Throwable e) {
- // catch and log (and ignore) ANY exception created
- // by executable extension.
- Logger.logException(e);
- fHandler = null;
- }
- }
- if (fHandler == null) {
- fHandler = new CommentElementHandler() {
- public Element createElement(Document document, String data, boolean isJSPTag) {
- return null;
- }
-
- public String generateStartTagContent(XMLElement element) {
- return null;
- }
-
- public String generateEndTagContent(XMLElement element) {
- return null;
- }
-
- public String getElementPrefix() {
- return null;
- }
-
- public boolean isCommentElement(XMLElement element) {
- return false;
- }
-
- public boolean isEmpty() {
- return false;
- }
- };
- }
- }
- return fHandler;
- }
-
- private boolean isCustom() {
- return fCustom;
- }
-
- private boolean isEmpty() {
- return fEmpty;
- }
-
- void setupCommentElement(XMLElement element) {
- element.setCommentTag(true);
- CommentElementAdapter adapter = new CommentElementAdapter(false, fHandler);
- adapter.setConfiguration(this);
- element.addAdapter(adapter);
- }
-
- public Element createElement(Document document, String data, boolean isJSPTag) {
- XMLElement element = (XMLElement) getHandler().createElement(document, data, isJSPTag);
- if (element != null) {
- CommentElementAdapter adapter = (CommentElementAdapter) element.getAdapterFor(CommentElementAdapter.class);
- if (adapter != null) {
- adapter.setConfiguration(this);
- }
- }
- return element;
- }
-
- public IPluginDescriptor getHandlerPluginDescriptor() {
- return fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
- }
-
- public String getHandlerID() {
- if (fID == null) {
- fID = getProperty("id"); //$NON-NLS-1$
- if (fID == null) {
- if (isCustom()) {
- fID = getProperty("class"); //$NON-NLS-1$
- }
- else {
- StringBuffer buf = new StringBuffer();
- buf.append(getHandlerPluginDescriptor().getUniqueIdentifier());
- buf.append('.');
- buf.append(getProperty("elementname")); //$NON-NLS-1$
- fID = buf.toString();
- }
- }
- }
- return fID;
- }
-
- private boolean fEmpty;
- private boolean fCustom;
- private boolean fXMLComment;
- private boolean fJSPComment;
- private String fID = null;
- private String[] fPrefix = null;
- private IConfigurationElement fElement = null;
- private CommentElementHandler fHandler = null;
- private Map fAttributes = null;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementRegistry.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementRegistry.java
deleted file mode 100644
index 70b5f1d..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/impl/CommentElementRegistry.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement.impl;
-
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.document.XMLElement;
-
-
-/**
- */
-public class CommentElementRegistry {
- public synchronized static CommentElementRegistry getInstance() {
- if (fInstance == null) {
- fInstance = new CommentElementRegistry();
- }
- return fInstance;
- }
-
- public CommentElementConfiguration[] getConfigurations() {
- if (fConfigurations == null) {
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- fConfigurations = new CommentElementConfiguration[elements.length];
- for (int i = 0; i < elements.length; i++) {
- fConfigurations[i] = new CommentElementConfiguration(elements[i]);
- }
- }
- if (fConfigurations == null) {
- fConfigurations = new CommentElementConfiguration[0];
- }
- }
- return fConfigurations;
- }
-
- public boolean setupCommentElement(XMLElement element) {
- CommentElementConfiguration configurations[] = getConfigurations();
- int length = configurations.length;
- for (int i = 0; i < length; i++) {
- CommentElementConfiguration conf = configurations[i];
- boolean isJSP = element.isJSPTag();
- if (isJSP && conf.acceptJSPComment() || !isJSP && conf.acceptXMLComment()) {
- CommentElementHandler handler = conf.getHandler();
- if (handler.isCommentElement(element)) {
- conf.setupCommentElement(element);
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Constructor for CommentElementRegistry.
- */
- private CommentElementRegistry() {
- super();
- }
-
- private static CommentElementRegistry fInstance = null;
- private CommentElementConfiguration[] fConfigurations = null;
-
- private String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- private String EXTENSION_POINT_ID = "commentElementHandler"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/CommentElementFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/CommentElementFactory.java
deleted file mode 100644
index 3cd12a3..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/CommentElementFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement.util;
-
-
-
-import org.eclipse.wst.xml.core.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementFactory {
-
- /**
- * Constructor for CommentElementFactory.
- */
- private CommentElementFactory() {
- super();
- }
-
- public CommentElementFactory(Document document, boolean isJSPTag, CommentElementHandler handler) {
- super();
- fDocument = document;
- fJSPTag = isJSPTag;
- fHandler = handler;
- }
-
- public Element create(String name, int nodeType) {
- XMLElement element = (XMLElement) fDocument.createElement(name);
- if (element == null)
- return null;
- element.setCommentTag(true);
- if (nodeType == IS_EMPTY) {
- element.setEmptyTag(true);
- }
- element.setJSPTag(fJSPTag);
-
- CommentElementAdapter adapter = new CommentElementAdapter((nodeType == IS_END), fHandler);
- element.addAdapter(adapter);
-
- return element;
- }
-
- public static final int IS_START = 28011;
- public static final int IS_END = 1808;
- public static final int IS_EMPTY = 4866;
-
- private Document fDocument;
- private CommentElementHandler fHandler;
- private boolean fJSPTag;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/TagScanner.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/TagScanner.java
deleted file mode 100644
index 3f67cba..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/commentelement/util/TagScanner.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.commentelement.util;
-
-
-
-/**
- */
-public class TagScanner {
-
- private String tag = null;
- private int offset = 0;
- private int memOffset = 0;
- private int length = 0;
- private boolean oneLine = false;
-
- /**
- */
- public TagScanner(String tag, int offset) {
- super();
-
- this.tag = tag;
- this.offset = offset;
- this.memOffset = -1;
- if (tag != null)
- this.length = tag.length();
- }
-
- /**
- */
- public TagScanner(String tag, int offset, boolean oneLine) {
- this(tag, offset);
-
- this.oneLine = oneLine;
- }
-
- /**
- */
- public int getNextOffset() {
- int i;
- char c;
- for (i = offset; i < length; i++) {
- c = tag.charAt(i);
- if (isEnd(c))
- break;
- if (isQuote(c)) {
- i++;
- break;
- }
- if (!isSpace(c) && !isEqual(c))
- break;
- }
- return i;
- }
-
- /**
- */
- public int getOffset() {
- return this.memOffset;
- }
-
- /**
- */
- public boolean isNewLine() {
- if (oneLine)
- return false;
- char c;
- for (int i = memOffset - 1; 0 <= i; i--) {
- c = tag.charAt(i);
- if (c == '\r' || c == '\n')
- return true;
- if (!isSpace(c))
- return false;
- }
- return false;
- }
-
- /**
- */
- private final boolean isEnd(char c) {
- return (this.oneLine && (c == '\r' || c == '\n'));
- }
-
- /**
- */
- private static boolean isEqual(char c) {
- return (c == '=');
- }
-
- /**
- */
- private static boolean isQuote(char c) {
- return (c == '"' || c == '\'');
- }
-
- /**
- */
- private static boolean isSpace(char c) {
- return Character.isWhitespace(c);
- }
-
- /**
- */
- private char nextChar() {
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c))
- break;
- if (!isSpace(c))
- return c;
- }
- return 0;
- }
-
- /**
- */
- public String nextName() {
- if (this.tag == null)
- return null;
- if (this.offset >= this.length)
- return null;
-
- if (nextChar() == 0)
- return null;
-
- int nameOffset = this.offset;
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c) || isSpace(c))
- break;
- if (isEqual(c) && this.offset > nameOffset)
- break;
- }
- if (this.offset == nameOffset)
- return null;
-
- this.memOffset = nameOffset;
- return this.tag.substring(nameOffset, this.offset);
- }
-
- /**
- */
- public String nextValue() {
- if (this.tag == null)
- return null;
- if (this.offset >= this.length)
- return null;
-
- char seperator = nextChar();
- if (!isEqual(seperator))
- return null;
- this.offset++; // skip '='
- char quote = nextChar();
- if (quote == 0)
- return null;
- if (isQuote(quote))
- this.offset++;
- else
- quote = 0;
-
- int valueOffset = this.offset;
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (isEnd(c)) {
- quote = 0;
- break;
- }
- if (quote == 0) {
- if (isSpace(c))
- break;
- }
- else {
- if (c == quote)
- break;
- }
- }
- int valueEnd = this.offset;
- if (quote != 0 && this.offset < this.length)
- this.offset++;
- if (valueEnd == valueOffset)
- return null;
-
- this.memOffset = valueOffset;
- return this.tag.substring(valueOffset, valueEnd);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java
deleted file mode 100644
index e12dcc6..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentDescriberForXML.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.contenttype;
-
-import org.eclipse.core.runtime.content.ITextContentDescriber;
-import org.eclipse.wst.encoding.AbstractContentDescriber;
-import org.eclipse.wst.encoding.IResourceCharsetDetector;
-
-
-public class ContentDescriberForXML extends AbstractContentDescriber implements ITextContentDescriber {
- protected IResourceCharsetDetector getDetector() {
- return new XMLResourceEncodingDetector();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentTypeIdentifierForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentTypeIdentifierForXML.java
deleted file mode 100644
index 7f21958..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/ContentTypeIdentifierForXML.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.contenttype;
-
-import org.eclipse.wst.encoding.content.IContentTypeIdentifier;
-
-/**
- * @deprecated - see org.eclipse.wst.sse.contentproperties.IContentTypeIdentifier
- * for constants. Use base Eclipse support for framework APIs (e.g. IContentType, IContentTypeManager, IContentDescription)
- * NO LONGER WORKS: This class to be removed soon.
- */
-public class ContentTypeIdentifierForXML {
- /**
- * @deprecated - see org.eclipse.wst.sse.contentproperties.IContentTypeIdentifier
- * for constants. Use base Eclipse support for framework APIs (e.g. IContentType, IContentTypeManager, IContentDescription)
- *
- */
- public static String ContentTypeID_XML = IContentTypeIdentifier.ContentTypeID_SSEXML;
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java
deleted file mode 100644
index ad8746f..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizer.java
+++ /dev/null
@@ -1,1234 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.contenttype;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.wst.encoding.EncodingParserConstants;
-import org.eclipse.wst.encoding.HeadParserToken;
-import org.eclipse.wst.encoding.IntStack;
-
-
-
-/**
- * This class is a scanner generated by
- * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2
- * on 4/6/04 11:13 PM from the specification file
- * <tt>file:/D:/DevTimeSupport/HeadParsers/XMLHeadTokenizer/XMLHeadTokenizer.jflex</tt>
- */
-public class XMLHeadTokenizer {
-
- /** this character denotes the end of file */
- final public static int YYEOF = -1;
-
- /** lexical states */
- final public static int YYINITIAL = 0;
- final public static int UnDelimitedString = 10;
- final public static int DQ_STRING = 6;
- final public static int SQ_STRING = 8;
- final public static int ST_XMLDecl = 2;
- final public static int QuotedAttributeValue = 4;
-
- /**
- * YY_LEXSTATE[l] is the state in the DFA for the lexical state l
- * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l
- * at the beginning of a line
- * l is of the form l = 2*k, k a non negative integer
- */
- private final static int YY_LEXSTATE[] = {0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6};
-
- /**
- * Translates characters to character classes
- */
- final private static String yycmap_packed = "\11\0\1\6\1\7\2\0\1\11\22\0\1\6\1\0\1\27\2\0" + "\1\31\1\0\1\30\24\0\1\12\1\10\1\26\1\13\3\0\1\21" + "\1\23\1\17\1\0\1\25\1\0\1\24\2\0\1\16\1\15\1\20" + "\1\22\10\0\1\14\12\0\1\21\1\23\1\17\1\0\1\25\1\0" + "\1\24\2\0\1\16\1\15\1\20\1\22\10\0\1\14\102\0\1\4" + "\3\0\1\5\17\0\1\3\16\0\1\1\20\0\1\3\16\0\1\1" + "\1\2\170\0\1\2\ufe87\0";
-
- /**
- * Translates characters to character classes
- */
- final private static char[] yycmap = yy_unpack_cmap(yycmap_packed);
-
-
- /* error codes */
- final private static int YY_UNKNOWN_ERROR = 0;
- final private static int YY_ILLEGAL_STATE = 1;
- final private static int YY_NO_MATCH = 2;
- final private static int YY_PUSHBACK_2BIG = 3;
-
- /* error messages for the codes above */
- final private static String YY_ERROR_MSG[] = {"Unkown internal scanner error", "Internal error: unknown state", "Error: could not match input", "Error: pushback value was too large"};
-
- /** the input device */
- private java.io.Reader yy_reader;
-
- /** the current state of the DFA */
- private int yy_state;
-
- /** the current lexical state */
- private int yy_lexical_state = YYINITIAL;
-
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char yy_buffer[] = new char[16384];
-
- /** the textposition at the last accepting state */
- private int yy_markedPos;
-
- /** the textposition at the last state to be included in yytext */
- private int yy_pushbackPos;
-
- /** the current text position in the buffer */
- private int yy_currentPos;
-
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int yy_startRead;
-
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int yy_endRead;
-
- /** number of newlines encountered up to the start of the matched text */
- private int yyline;
-
- /** the number of characters up to the start of the matched text */
- private int yychar;
-
- /**
- * the number of characters from the last newline up to the start of the
- * matched text
- */
- private int yycolumn;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning of a line
- */
- private boolean yy_atBOL;
-
- /** yy_atEOF == true <=> the scanner has returned a value for EOF */
- private boolean yy_atEOF;
-
- /** denotes if the user-EOF-code has already been executed */
- private boolean yy_eof_done;
-
- /* user code: */
-
-
- private boolean hasMore = true;
- private final static int MAX_TO_SCAN = 1000;
- StringBuffer string = new StringBuffer();
- // state stack for easier state handling
- private IntStack fStateStack = new IntStack();
- private String valueText = null;
-
-
- public XMLHeadTokenizer() {
- super();
- }
-
- public void reset(Reader in) {
- /* the input device */
- yy_reader = in;
-
- /* the current state of the DFA */
- yy_state = 0;
-
- /* the current lexical state */
- yy_lexical_state = YYINITIAL;
-
- /* this buffer contains the current text to be matched and is
- the source of the yytext() string */
- java.util.Arrays.fill(yy_buffer, (char) 0);
-
- /* the textposition at the last accepting state */
- yy_markedPos = 0;
-
- /* the textposition at the last state to be included in yytext */
- yy_pushbackPos = 0;
-
- /* the current text position in the buffer */
- yy_currentPos = 0;
-
- /* startRead marks the beginning of the yytext() string in the buffer */
- yy_startRead = 0;
-
- /**
- * endRead marks the last character in the buffer, that has been read
- * from input
- */
- yy_endRead = 0;
-
- /* number of newlines encountered up to the start of the matched text */
- yyline = 0;
-
- /* the number of characters up to the start of the matched text */
- yychar = 0;
-
- /**
- * the number of characters from the last newline up to the start
- * of the matched text
- */
- yycolumn = 0;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning
- * of a line
- */
- yy_atBOL = false;
-
- /* yy_atEOF == true <=> the scanner has returned a value for EOF */
- yy_atEOF = false;
-
- /* denotes if the user-EOF-code has already been executed */
- yy_eof_done = false;
-
-
- fStateStack.clear();
-
- hasMore = true;
-
- // its a little wasteful to "throw away" first char array generated
- // by class init (via auto generated code), but we really do want
- // a small buffer for our head parsers.
- if (yy_buffer.length != MAX_TO_SCAN) {
- yy_buffer = new char[MAX_TO_SCAN];
- }
-
-
- }
-
-
- public final HeadParserToken getNextToken() throws IOException {
- String context = null;
- context = primGetNextToken();
- HeadParserToken result = null;
- if (valueText != null) {
- result = createToken(context, yychar, valueText);
- valueText = null;
- }
- else {
- result = createToken(context, yychar, yytext());
- }
- return result;
- }
-
- public final boolean hasMoreTokens() {
- return hasMore && yychar < MAX_TO_SCAN;
- }
-
- private void pushCurrentState() {
- fStateStack.push(yystate());
-
- }
-
- private void popState() {
- yybegin(fStateStack.pop());
- }
-
- private HeadParserToken createToken(String context, int start, String text) {
- return new HeadParserToken(context, start, text);
- }
-
-
-
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- public XMLHeadTokenizer(java.io.Reader in) {
- this.yy_reader = in;
- }
-
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- public XMLHeadTokenizer(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
-
- /**
- * Unpacks the compressed character translation table.
- *
- * @param packed the packed character translation table
- * @return the unpacked character translation table
- */
- private static char[] yy_unpack_cmap(String packed) {
- char[] map = new char[0x10000];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 128) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do
- map[j++] = value;
- while (--count > 0);
- }
- return map;
- }
-
-
- /**
- * Gets the next input character.
- *
- * @return the next character of the input stream, EOF if the
- * end of the stream is reached.
- * @exception IOException if any I/O-Error occurs
- */
- private int yy_advance() throws java.io.IOException {
-
- /* standard case */
- if (yy_currentPos < yy_endRead)
- return yy_buffer[yy_currentPos++];
-
- /* if the eof is reached, we don't need to work hard */
- if (yy_atEOF)
- return YYEOF;
-
- /* otherwise: need to refill the buffer */
-
- /* first: make room (if you can) */
- if (yy_startRead > 0) {
- System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0, yy_endRead - yy_startRead);
-
- /* translate stored positions */
- yy_endRead -= yy_startRead;
- yy_currentPos -= yy_startRead;
- yy_markedPos -= yy_startRead;
- yy_pushbackPos -= yy_startRead;
- yy_startRead = 0;
- }
-
- /* is the buffer big enough? */
- if (yy_currentPos >= yy_buffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[yy_currentPos * 2];
- System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
- yy_buffer = newBuffer;
- }
-
- /* finally: fill the buffer with new input */
- int numRead = yy_reader.read(yy_buffer, yy_endRead, yy_buffer.length - yy_endRead);
-
- if (numRead == -1)
- return YYEOF;
-
- yy_endRead += numRead;
-
- return yy_buffer[yy_currentPos++];
- }
-
-
- /**
- * Closes the input stream.
- */
- final public void yyclose() throws java.io.IOException {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yy_reader.close();
- }
-
-
- /**
- * Returns the current lexical state.
- */
- final public int yystate() {
- return yy_lexical_state;
- }
-
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
- final public void yybegin(int newState) {
- yy_lexical_state = newState;
- }
-
-
- /**
- * Returns the text matched by the current regular expression.
- */
- final public String yytext() {
- return new String(yy_buffer, yy_startRead, yy_markedPos - yy_startRead);
- }
-
- /**
- * Returns the length of the matched text region.
- */
- final public int yylength() {
- return yy_markedPos - yy_startRead;
- }
-
-
- /**
- * Reports an error that occured while scanning.
- *
- * @param errorCode the code of the errormessage to display
- */
- private void yy_ScanError(int errorCode) {
- try {
- System.out.println(YY_ERROR_MSG[errorCode]);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
- }
-
- // System.exit(1);
- }
-
-
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
- private void yypushback(int number) {
- if (number > yylength())
- yy_ScanError(YY_PUSHBACK_2BIG);
-
- yy_markedPos -= number;
- }
-
-
- /**
- * Contains user EOF-code, which will be executed exactly once,
- * when the end of file is reached
- */
- private void yy_do_eof() {
- if (!yy_eof_done) {
- yy_eof_done = true;
- hasMore = false;
-
- }
- }
-
-
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception IOException if any I/O-Error occurs
- */
- public String primGetNextToken() throws java.io.IOException {
- int yy_input;
- int yy_action;
-
-
- while (true) {
-
- yychar += yylength();
-
- yy_atBOL = yy_markedPos <= 0 || yy_buffer[yy_markedPos - 1] == '\n';
- if (!yy_atBOL && yy_buffer[yy_markedPos - 1] == '\r') {
- yy_atBOL = yy_advance() != '\n';
- if (!yy_atEOF)
- yy_currentPos--;
- }
-
- yy_action = -1;
-
- yy_currentPos = yy_startRead = yy_markedPos;
-
- if (yy_atBOL)
- yy_state = YY_LEXSTATE[yy_lexical_state + 1];
- else
- yy_state = YY_LEXSTATE[yy_lexical_state];
-
-
- yy_forAction : {
- while (true) {
-
- yy_input = yy_advance();
-
- if (yy_input == YYEOF)
- break yy_forAction;
-
- yy_input = yycmap[yy_input];
-
- boolean yy_isFinal = false;
- boolean yy_noLookAhead = false;
-
- yy_forNext : {
- switch (yy_state) {
- case 0 :
- switch (yy_input) {
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 1 :
- switch (yy_input) {
- case 1 :
- yy_isFinal = true;
- yy_state = 8;
- break yy_forNext;
- case 2 :
- yy_isFinal = true;
- yy_state = 9;
- break yy_forNext;
- case 3 :
- yy_isFinal = true;
- yy_state = 10;
- break yy_forNext;
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 11;
- break yy_forNext;
- case 10 :
- yy_isFinal = true;
- yy_state = 12;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 2 :
- switch (yy_input) {
- case 11 :
- yy_isFinal = true;
- yy_state = 13;
- break yy_forNext;
- case 15 :
- yy_isFinal = true;
- yy_state = 14;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 3 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_isFinal = true;
- yy_state = 17;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 18;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 19;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 4 :
- switch (yy_input) {
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- case 11 :
- yy_isFinal = true;
- yy_state = 22;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 23;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 24;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 5 :
- switch (yy_input) {
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 25;
- break yy_forNext;
- case 25 :
- yy_isFinal = true;
- yy_state = 26;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 6 :
- switch (yy_input) {
- case 11 :
- yy_isFinal = true;
- yy_state = 26;
- break yy_forNext;
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 27;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 28;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 29;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 8 :
- switch (yy_input) {
- case 2 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 30;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 9 :
- switch (yy_input) {
- case 1 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 31;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 10 :
- switch (yy_input) {
- case 4 :
- yy_state = 32;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 11 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 33;
- break yy_forNext;
- case 10 :
- yy_state = 34;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 12 :
- switch (yy_input) {
- case 11 :
- yy_state = 35;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 13 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 36;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 14 :
- switch (yy_input) {
- case 16 :
- yy_state = 37;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 16 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 17 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 22 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 39;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 24 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 25 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 26 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 41;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 29 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 32 :
- switch (yy_input) {
- case 5 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 42;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 33 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 33;
- break yy_forNext;
- case 10 :
- yy_state = 34;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 34 :
- switch (yy_input) {
- case 11 :
- yy_state = 35;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 35 :
- switch (yy_input) {
- case 12 :
- yy_state = 43;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 37 :
- switch (yy_input) {
- case 17 :
- yy_state = 44;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 38 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 40 :
- switch (yy_input) {
- case 24 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 43 :
- switch (yy_input) {
- case 13 :
- yy_state = 45;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 44 :
- switch (yy_input) {
- case 18 :
- yy_state = 46;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 45 :
- switch (yy_input) {
- case 14 :
- yy_state = 47;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 46 :
- switch (yy_input) {
- case 19 :
- yy_state = 48;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 47 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 49;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 48 :
- switch (yy_input) {
- case 20 :
- yy_state = 50;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 49 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 49;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 50 :
- switch (yy_input) {
- case 16 :
- yy_state = 51;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 51 :
- switch (yy_input) {
- case 21 :
- yy_state = 52;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 52 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 52;
- break yy_forNext;
- case 8 :
- yy_isFinal = true;
- yy_state = 53;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 53 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 53;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- default :
- yy_ScanError(YY_ILLEGAL_STATE);
- break;
- }
- }
-
- if (yy_isFinal) {
- yy_action = yy_state;
- yy_markedPos = yy_currentPos;
- if (yy_noLookAhead)
- break yy_forAction;
- }
-
- }
- }
-
-
- switch (yy_action) {
-
- case 25 :
- {
- popState();
- valueText = string.toString();
- return EncodingParserConstants.StringValue;
- }
- case 55 :
- break;
- case 21 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 56 :
- break;
- case 15 :
- case 16 :
- {
- yypushback(1);
- yybegin(UnDelimitedString);
- string.setLength(0);
- }
- case 57 :
- break;
- case 28 :
- case 29 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;
- }
- case 58 :
- break;
- case 39 :
- {
- yypushback(2);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 59 :
- break;
- case 41 :
- {
- yypushback(2);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 60 :
- break;
- case 7 :
- case 8 :
- case 9 :
- case 10 :
- case 11 :
- case 12 :
- case 13 :
- case 14 :
- case 17 :
- {
- if (yychar > MAX_TO_SCAN) {
- hasMore = false;
- return EncodingParserConstants.MAX_CHARS_REACHED;
- }
- }
- case 61 :
- break;
- case 30 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF16BE;
- }
- }
- case 62 :
- break;
- case 31 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF16LE;
- }
- }
- case 63 :
- break;
- case 42 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF83ByteBOM;
- }
- }
- case 64 :
- break;
- case 49 :
- {
- if (yychar == 0) {
- yybegin(ST_XMLDecl);
- return XMLHeadTokenizerConstants.XMLDeclStart;
- }
- }
- case 65 :
- break;
- case 36 :
- {
- yybegin(YYINITIAL);
- hasMore = false;
- return XMLHeadTokenizerConstants.XMLDeclEnd;
- }
- case 66 :
- break;
- case 53 :
- {
- pushCurrentState();
- yybegin(QuotedAttributeValue);
- return XMLHeadTokenizerConstants.XMLDelEncoding;
- }
- case 67 :
- break;
- case 23 :
- {
- popState();
- valueText = string.toString();
- return EncodingParserConstants.StringValue;
- }
- case 68 :
- break;
- case 20 :
- case 22 :
- case 24 :
- case 26 :
- {
- string.append(yytext());
- }
- case 69 :
- break;
- case 19 :
- {
- yybegin(SQ_STRING);
- string.setLength(0);
- }
- case 70 :
- break;
- case 18 :
- {
- yybegin(DQ_STRING);
- string.setLength(0);
- }
- case 71 :
- break;
- case 27 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.UnDelimitedStringValue;
- }
- case 72 :
- break;
- default :
- if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
- yy_atEOF = true;
- yy_do_eof();
- {
- hasMore = false;
- return EncodingParserConstants.EOF;
- }
- }
- else {
- yy_ScanError(YY_NO_MATCH);
- }
- }
- }
- }
-
- /**
- * Runs the scanner on input files.
- *
- * This main method is the debugging routine for the scanner.
- * It prints each returned token to System.out until the end of
- * file is reached, or an error occured.
- *
- * @param argv the command line, contains the filenames to run
- * the scanner on.
- */
- public static void main(String argv[]) {
- for (int i = 0; i < argv.length; i++) {
- XMLHeadTokenizer scanner = null;
- try {
- scanner = new XMLHeadTokenizer(new java.io.FileReader(argv[i]));
- }
- catch (java.io.FileNotFoundException e) {
- System.out.println("File not found : \"" + argv[i] + "\"");
- System.exit(1);
- }
-// catch (java.io.IOException e) {
-// System.out.println("Error opening file \"" + argv[i] + "\"");
-// System.exit(1);
-// }
- catch (ArrayIndexOutOfBoundsException e) {
- System.out.println("Usage : java XMLHeadTokenizer <inputfile>");
- System.exit(1);
- }
-
- try {
- do {
- System.out.println(scanner.primGetNextToken());
- }
- while (!scanner.yy_atEOF);
-
- }
- catch (java.io.IOException e) {
- System.out.println("An I/O error occured while scanning :");
- System.out.println(e);
- System.exit(1);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizerConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizerConstants.java
deleted file mode 100644
index 1f1f0d2..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLHeadTokenizerConstants.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.contenttype;
-
-import org.eclipse.wst.encoding.EncodingParserConstants;
-
-public interface XMLHeadTokenizerConstants extends EncodingParserConstants {
-
- final String XMLDeclEnd = "XMLDeclEnd"; //$NON-NLS-1$
-
- final String XMLDeclStart = "XMLDeclStart"; //$NON-NLS-1$
-
- final String XMLDelEncoding = "XMLDelEncoding"; //$NON-NLS-1$
- // final String XMLDeclVersion = "XMLDeclVersion";
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLResourceEncodingDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLResourceEncodingDetector.java
deleted file mode 100644
index 43e0e5c..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/contenttype/XMLResourceEncodingDetector.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.contenttype;
-
-import java.io.IOException;
-
-import org.eclipse.wst.encoding.AbstractResourceEncodingDetector;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.EncodingParserConstants;
-import org.eclipse.wst.encoding.HeadParserToken;
-import org.eclipse.wst.encoding.IResourceCharsetDetector;
-
-public class XMLResourceEncodingDetector extends AbstractResourceEncodingDetector implements IResourceCharsetDetector {
- private XMLHeadTokenizer fTokenizer;
-
- public String getSpecDefaultEncoding() {
- // by default, UTF-8 as per XML spec
- final String enc = "UTF-8"; //$NON-NLS-1$
- return enc;
- }
-
- private boolean isLegalString(String valueTokenType) {
- if (valueTokenType == null)
- return false;
- else
- return valueTokenType.equals(EncodingParserConstants.StringValue) || valueTokenType.equals(EncodingParserConstants.UnDelimitedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTerminatedStringValue) || valueTokenType.equals(EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue);
- }
-
- /**
- * @return Returns the tokenizer.
- */
- private XMLHeadTokenizer getTokenizer() {
- // TODO: need to work on 'reset' in tokenizer, so new instance isn't always needed
- //if (fTokenizer == null) {
- fTokenizer = new XMLHeadTokenizer();
- //}
- return fTokenizer;
- }
-
- private boolean canHandleAsUnicodeStream(String tokenType) {
- boolean canHandleAsUnicodeStream = false;
- if (tokenType == EncodingParserConstants.UTF83ByteBOM) {
- canHandleAsUnicodeStream = true;
- String enc = "UTF-8"; //$NON-NLS-1$
- createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
- fEncodingMemento.setUTF83ByteBOMUsed(true);
- }
- else if (tokenType == EncodingParserConstants.UTF16BE) {
- canHandleAsUnicodeStream = true;
- String enc = "UTF-16"; //$NON-NLS-1$
- createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
- }
- else if (tokenType == EncodingParserConstants.UTF16LE) {
- canHandleAsUnicodeStream = true;
- String enc = "UTF-16LE"; //$NON-NLS-1$
- createEncodingMemento(enc, EncodingMemento.DETECTED_STANDARD_UNICODE_BYTES);
- }
- return canHandleAsUnicodeStream;
- }
-
- protected void parseInput() throws IOException {
- XMLHeadTokenizer tokenizer = getTokenizer();
- tokenizer.reset(fReader);
- HeadParserToken token = null;
- String tokenType = null;
- do {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (canHandleAsUnicodeStream(tokenType)) {
- // side effect of canHandle is to create appropriate memento
- }
- else {
- if (tokenType == XMLHeadTokenizerConstants.XMLDelEncoding) {
- if (tokenizer.hasMoreTokens()) {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (isLegalString(tokenType)) {
- String enc = token.getText();
- if (enc != null && enc.length() > 0) {
- createEncodingMemento(enc, EncodingMemento.FOUND_ENCODING_IN_CONTENT);
- }
-
- }
- }
- }
- }
- }
- while (tokenizer.hasMoreTokens());
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentLoaderForXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentLoaderForXML.java
deleted file mode 100644
index 7286b4f..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentLoaderForXML.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.encoding.CodedReaderCreator;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IDocumentLoaderForFileBuffers;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.document.StructuredDocumentLoader;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.xml.core.encoding.XMLDocumentCharsetDetector;
-import org.eclipse.wst.xml.core.internal.filebuffers.DocumentFactoryForXML;
-import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.internal.parser.XMLStructuredDocumentReParser;
-import org.eclipse.wst.xml.core.text.rules.StructuredTextPartitionerForXML;
-
-
-
-public class DocumentLoaderForXML extends StructuredDocumentLoader implements IDocumentLoader, IDocumentLoaderForFileBuffers {
- /*
- * (non-Javadoc)
- *
- */
- public IEncodedDocument createNewStructuredDocument() {
- DocumentFactoryForXML factory = new DocumentFactoryForXML();
- IEncodedDocument document = (IEncodedDocument) factory.createDocument();
- return document;
- }
-
- public IEncodedDocument createNewStructuredDocument(Reader reader) throws UnsupportedEncodingException, IOException {
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- StringBuffer allText = readInputStream(reader);
- structuredDocument.set(allText.toString());
- return structuredDocument;
-
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream) throws IOException {
- return createNewStructuredDocument(filename, inputStream, EncodingRule.CONTENT_BASED);
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream, EncodingRule encodingRule) throws IOException {
- if (filename == null && inputStream == null) {
- throw new IllegalArgumentException("can not have both null filename and inputstream"); //$NON-NLS-1$
- }
- CodedReaderCreator codedReaderCreator = new CodedReaderCreator();
- Reader fullPreparedReader = null;
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- try {
- codedReaderCreator.set(filename, inputStream);
- codedReaderCreator.setEncodingRule(encodingRule);
- EncodingMemento encodingMemento = codedReaderCreator.getEncodingMemento();
- fullPreparedReader = codedReaderCreator.getCodedReader();
- structuredDocument.setEncodingMemento(encodingMemento);
- StringBuffer allText = readInputStream(fullPreparedReader);
- structuredDocument.set(allText.toString());
- }
- catch (CoreException e) {
- // impossible in this context
- throw new Error(e);
- }
- finally {
- if (fullPreparedReader != null) {
- fullPreparedReader.close();
- }
- }
-
- return structuredDocument;
- }
-
-
-
- /*
- * (non-Javadoc)
- *
- */
- public IDocumentPartitioner getDefaultDocumentPartitioner() {
- return new StructuredTextPartitionerForXML();
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IDocumentCharsetDetector getDocumentEncodingDetector() {
- return new XMLDocumentCharsetDetector();
- }
-
- /**
- * deprecated - no longer used/needed - may no longer work.
- */
- public EncodingMemento getEncodingMemento() {
-
- return CodedIO.createEncodingMemento("UTF-8"); //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public StringBuffer handleLineDelimiter(StringBuffer originalString, IEncodedDocument theStructuredDocument) {
- // TODO Auto-generated method stub
- return originalString;
- }
-
- /**
- * @deprecated
- */
- public IEncodedDocument newEncodedDocument() {
- BasicStructuredDocument structuredDocument = new BasicStructuredDocument(new XMLSourceParser());
- structuredDocument.setReParser(new XMLStructuredDocumentReParser());
- return structuredDocument;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentTypeAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentTypeAdapter.java
deleted file mode 100644
index 1146550..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/DocumentTypeAdapter.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.w3c.dom.DocumentType;
-
-/**
- */
-public interface DocumentTypeAdapter extends INodeAdapter {
- static final int STRICT_CASE = 0;
- static final int UPPER_CASE = 1;
- static final int LOWER_CASE = 2;
-
- /**
- */
- DocumentType getDocumentType();
-
- /**
- */
- int getTagNameCase();
-
- /**
- */
- int getAttrNameCase();
-
- /**
- */
- boolean hasFeature(String feature);
-
- /**
- */
- boolean isXMLType();
-
- /**
- */
- void release();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/InvalidCharacterException.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/InvalidCharacterException.java
deleted file mode 100644
index 60550d0..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/InvalidCharacterException.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-/**
- * Thrown an invalid character is specified in :
- * XMLNode#setSource(String)
- */
-public class InvalidCharacterException extends Exception {
-
- private char invalidChar = 0;
- private int offset = -1;
-
- /**
- */
- public InvalidCharacterException() {
- super();
- }
-
- /**
- */
- public InvalidCharacterException(String s) {
- super(s);
- }
-
- /**
- */
- public InvalidCharacterException(String s, char c) {
- super(s);
- this.invalidChar = c;
- }
-
- /**
- */
- public InvalidCharacterException(String s, char c, int offset) {
- super(s);
- this.invalidChar = c;
- this.offset = offset;
- }
-
- /**
- */
- public char getInvalidChar() {
- return this.invalidChar;
- }
-
- /**
- */
- public int getOffset() {
- return this.offset;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/JSPTag.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/JSPTag.java
deleted file mode 100644
index c2167bd..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/JSPTag.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-/**
- * JSPTag interface
- */
-public interface JSPTag {
-
- static final String JSP_SCRIPTLET = "jsp:scriptlet";//$NON-NLS-1$
- static final String JSP_EXPRESSION = "jsp:expression";//$NON-NLS-1$
- static final String JSP_DECLARATION = "jsp:declaration";//$NON-NLS-1$
- static final String JSP_DIRECTIVE = "jsp:directive";//$NON-NLS-1$
- static final String JSP_ROOT = "jsp:root";//$NON-NLS-1$
- static final String TAG_OPEN = "<%";//$NON-NLS-1$
- static final String TAG_CLOSE = "%>";//$NON-NLS-1$
- static final String COMMENT_OPEN = "<%--";//$NON-NLS-1$
- static final String COMMENT_CLOSE = "--%>";//$NON-NLS-1$
- static final String EXPRESSION_TOKEN = "=";//$NON-NLS-1$
- static final String DECLARATION_TOKEN = "!";//$NON-NLS-1$
- static final String DIRECTIVE_TOKEN = "@";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/TagAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/TagAdapter.java
deleted file mode 100644
index f065cc2..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/TagAdapter.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-
-/**
- */
-public interface TagAdapter extends INodeAdapter {
-
- /**
- */
- String getStartTag(XMLElement element);
-
- /**
- */
- String getEndTag(XMLElement element);
-
- /**
- */
- boolean isEndTag();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLAttr.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLAttr.java
deleted file mode 100644
index 3db8425..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLAttr.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.w3c.dom.Attr;
-
-/**
- */
-public interface XMLAttr extends XMLNode, Attr {
-
- /**
- */
- ITextRegion getEqualRegion();
-
- /**
- * Check if Attr has JSP in value
- */
- boolean hasJSPValue();
-
- /**
- * Check if Attr has only name but not equal sign nor value
- */
- boolean hasNameOnly();
-
- /**
- */
- boolean isGlobalAttr();
-
- /**
- */
- boolean isXMLAttr();
-
- String getValueRegionText();
-
- int getValueRegionStartOffset();
-
- String getNameRegionText();
-
- int getNameRegionStartOffset();
-
- /**
- * @return
- */
- int getNameRegionEndOffset();
-
- /**
- * @return
- */
- int getNameRegionTextEndOffset();
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLCharEntity.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLCharEntity.java
deleted file mode 100644
index 554de86..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLCharEntity.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-/**
- * XML Namespace constants
- */
-public interface XMLCharEntity {
-
- static final String LT_NAME = "lt";//$NON-NLS-1$
- static final String LT_VALUE = "<";//$NON-NLS-1$
- static final String LT_REF = "<";//$NON-NLS-1$
- static final String GT_NAME = "gt";//$NON-NLS-1$
- static final String GT_VALUE = ">";//$NON-NLS-1$
- static final String GT_REF = ">";//$NON-NLS-1$
- static final String AMP_NAME = "amp";//$NON-NLS-1$
- static final String AMP_VALUE = "&";//$NON-NLS-1$
- static final String AMP_REF = "&";//$NON-NLS-1$
- static final String QUOT_NAME = "quot";//$NON-NLS-1$
- static final String QUOT_VALUE = "\"";//$NON-NLS-1$
- static final String QUOT_REF = """;//$NON-NLS-1$
- static final String APOS_NAME = "apos";//$NON-NLS-1$
- static final String APOS_VALUE = "'";//$NON-NLS-1$
- static final String APOS_REF = "'";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocument.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocument.java
deleted file mode 100644
index c4ea813..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocument.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.ranges.DocumentRange;
-import org.w3c.dom.traversal.DocumentTraversal;
-
-/**
- * This interface enables creation of DOCTYPE declaration
- * and some DOM Level 2 interfaces.
- */
-public interface XMLDocument extends XMLNode, Document, DocumentRange, DocumentTraversal {
-
- /**
- */
- DocumentType createDoctype(String name);
-
- /**
- */
- String getDocumentTypeId();
-
- /**
- */
- boolean isJSPDocument();
-
- /**
- */
- boolean isJSPType();
-
- /**
- */
- boolean isXMLType();
-
- /**
- * create comment element.
- * tagName must be registered as comment element name in plugin.xml
- *
- * @param tagName the element name
- * @param isJSPTag true if the element is JSP style comment (<%-- ... --%>)
- * @return Element element instance
- * @throws DOMException throwed if the element name is registered as comment element
- */
- Element createCommentElement(String tagName, boolean isJSPTag) throws DOMException;
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocumentType.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocumentType.java
deleted file mode 100644
index 866db8c..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLDocumentType.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.DocumentType;
-
-/**
- * This interface enables setting of Public and System ID for DOCTYPE declaration.
- */
-public interface XMLDocumentType extends XMLNode, DocumentType {
-
- /**
- */
- void setPublicId(String publicId);
-
- /**
- */
- void setSystemId(String systemId);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLElement.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLElement.java
deleted file mode 100644
index 0cb9aa9..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLElement.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.Element;
-
-/**
- */
-public interface XMLElement extends XMLNode, Element {
-
- /**
- */
- String getEndTagName();
-
- /**
- */
- boolean hasStartTag();
-
- /**
- */
- boolean hasEndTag();
-
- /**
- */
- boolean isCommentTag();
-
- /**
- * isEmptyTag method
- * @return boolean
- */
- boolean isEmptyTag();
-
- /**
- */
- boolean isEndTag();
-
- /**
- * Returns true for "global tag" (basically, without prefix)
- */
- boolean isGlobalTag();
-
- /**
- * Returns true for no the start and the end tags
- */
- boolean isImplicitTag();
-
- /**
- * isJSPTag method
- * @return boolean
- */
- boolean isJSPTag();
-
- /**
- */
- boolean isStartTagClosed();
-
- /**
- */
- boolean isXMLTag();
-
- /**
- */
- void setCommentTag(boolean isCommentTag);
-
- /**
- */
- void setEmptyTag(boolean isEmptyTag);
-
- /**
- */
- void setJSPTag(boolean isJSPTag);
-
- /**
- * @deprecated this should probably not be public
- *
- */
- int getStartEndOffset();
-
- /**
- * @deprecated this should probably not be public
- *
- */
- int getEndStartOffset();
-
- /**
- * @deprecated this should not be public
- *
- */
- void notifyEndTagChanged();
-
- /**
- * @deprecated this should not be public
- *
- */
- void notifyStartTagChanged();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLGenerator.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLGenerator.java
deleted file mode 100644
index be5b5c7..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLGenerator.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-public interface XMLGenerator {
-
- /**
- */
- String generateAttrName(Attr attr);
-
- /**
- */
- String generateAttrValue(String value, char quote);
-
- /**
- */
- String generateAttrValue(Attr attr);
-
- /**
- */
- String generateAttrValue(Attr attr, char quote);
-
- /**
- * generateCDATASection method
- * @return java.lang.String
- * @param comment org.w3c.dom.CDATASection
- */
- String generateCDATASection(CDATASection cdata);
-
- /**
- * generateChild method
- * @return java.lang.String
- * @param org.w3c.dom.Node
- */
- String generateChild(Node parentNode);
-
- /**
- */
- String generateCloseTag(Node node);
-
- /**
- * generateComment method
- * @return java.lang.String
- * @param comment org.w3c.dom.Comment
- */
- String generateComment(Comment comment);
-
- /**
- * generateDoctype method
- * @return java.lang.String
- * @param docType org.w3c.dom.DocumentType
- */
- String generateDoctype(DocumentType docType);
-
- /**
- * generateElement method
- * @return java.lang.String
- * @param element Element
- */
- String generateElement(Element element);
-
- /**
- * generateEndTag method
- * @return java.lang.String
- * @param element org.w3c.dom.Element
- */
- String generateEndTag(Element element);
-
- /**
- * generateEntityRef method
- * @return java.lang.String
- * @param entityRef org.w3c.dom.EntityReference
- */
- String generateEntityRef(EntityReference entityRef);
-
- /**
- * generatePI method
- * @return java.lang.String
- * @param pi org.w3c.dom.ProcessingInstruction
- */
- String generatePI(ProcessingInstruction pi);
-
- /**
- * generateSource method
- * @return java.lang.String
- * @param node org.w3c.dom.Node
- */
- String generateSource(Node node);
-
- /**
- * generateStartTag method
- * @return java.lang.String
- * @param element Element
- */
- String generateStartTag(Element element);
-
- /**
- */
- String generateTagName(Element element);
-
- /**
- * generateText method
- * @return java.lang.String
- * @param text org.w3c.dom.Text
- */
- String generateText(Text text);
-
- /**
- */
- String generateTextData(Text text, String data);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModel.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModel.java
deleted file mode 100644
index f03a83b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModel.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-
-/**
- */
-public interface XMLModel extends IStructuredModel {
-
- XMLDocument getDocument();
-
- /**
- */
- XMLGenerator getGenerator();
-
- /**
- */
- XMLModelNotifier getModelNotifier();
-
- /**
- */
- void setModelNotifier(XMLModelNotifier notifier);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModelNotifier.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModelNotifier.java
deleted file mode 100644
index 557c33a..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLModelNotifier.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public interface XMLModelNotifier {
-
- /**
- * attrReplaced method
- * @param element org.w3c.dom.Element
- * @param newAttr org.w3c.dom.Attr
- * @param oldAttr org.w3c.dom.Attr
- */
- void attrReplaced(Element element, Attr newAttr, Attr oldAttr);
-
- /**
- */
- void beginChanging();
-
- /**
- */
- void beginChanging(boolean newModel);
-
- /**
- * childReplaced method
- * @param parentNode org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- void childReplaced(Node parentNode, Node newChild, Node oldChild);
-
- /**
- */
- void endChanging();
-
- /**
- */
- void endTagChanged(Element element);
-
- /**
- */
- boolean hasChanged();
-
- /**
- */
- boolean isChanging();
-
- /**
- */
- void propertyChanged(Node node);
-
- /**
- */
- void startTagChanged(Element element);
-
- /**
- */
- void editableChanged(Node node);
-
- /**
- */
- void structureChanged(Node node);
-
- /**
- * valueChanged method
- * @param node org.w3c.dom.Node
- */
- void valueChanged(Node node);
-
- /**
- * Cancel pending notifications. This is called in the context
- * of "reinitialization" so is assumed ALL notifications can
- * be safely canceled, assuming that once factories and adapters
- * are re-initialized they will be re-notified as text is set in
- * model, if still appropriate.
- */
- void cancelPending();
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNamespace.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNamespace.java
deleted file mode 100644
index f28a51b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNamespace.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-/**
- * XML Namespace constants
- */
-public interface XMLNamespace {
-
- static final String XMLNS = "xmlns";//$NON-NLS-1$
- static final String XMLNS_PREFIX = "xmlns:";//$NON-NLS-1$
- static final String XMLNS_URI = "http://www.w3.org/2000/xmlns/";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNode.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNode.java
deleted file mode 100644
index 97c6c98..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLNode.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-/**
- * A interface to make concept clearer, just to denote the combination of
- * three other interfaces.
- *
- */
-public interface XMLNode extends org.eclipse.wst.sse.core.IndexedRegion, org.eclipse.wst.sse.core.INodeNotifier, org.w3c.dom.Node {
-
- /**
- *
- */
- IStructuredDocumentRegion getEndStructuredDocumentRegion();
-
- /**
- */
- IStructuredDocumentRegion getFirstStructuredDocumentRegion();
-
- /**
- *
- */
- IStructuredDocument getStructuredDocument();
-
- /**
- */
- IStructuredDocumentRegion getLastStructuredDocumentRegion();
-
- /**
- */
- XMLModel getModel();
-
- /**
- */
- ITextRegion getNameRegion();
-
- /**
- */
- String getSource();
-
- /**
- *
- */
- IStructuredDocumentRegion getStartStructuredDocumentRegion();
-
- /**
- */
- ITextRegion getValueRegion();
-
- /**
- */
- String getValueSource();
-
- /**
- */
- boolean isClosed();
-
- /**
- * isContainer method
- * @return boolean
- */
- boolean isContainer();
-
- /**
- * Sets the specified raw source to the Text node.
- * Throws InvalidCharacterException when the specified raw source includes
- * invalid characters, such as, '<', '>' and '&'.
- * Valid character entities, such as, "<", are accepted.
- */
- void setSource(String source) throws InvalidCharacterException;
-
- /**
- * Sets the specified raw source to the Text or Attr node's value.
- * When the specified raw source includes invalid characters, such as,
- * '<', '>' and '&', converts them.
- * Valid character entities, such as, "<", are accepted.
- */
- void setValueSource(String source);
-
- /**
- *
- * @return boolean Whether children of the element can be appended or removed.
- */
- boolean isChildEditable();
-
- /**
- */
- void setChildEditable(boolean editable);
-
- /**
- */
- boolean isDataEditable();
-
- /**
- */
- void setDataEditable(boolean editable);
-
- /**
- * faster approach to set
- */
- void setEditable(boolean editable, boolean deep);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLText.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLText.java
deleted file mode 100644
index 69af030..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/document/XMLText.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.document;
-
-
-
-import org.w3c.dom.Text;
-
-/**
- */
-public interface XMLText extends XMLNode, Text {
-
- /**
- * Appends the content of the text node
- */
- void appendText(Text text);
-
- /**
- * Inserts the content of the text node at the specified position
- */
- void insertText(Text text, int offset);
-
- /**
- */
- boolean isInvalid();
-
- /**
- */
- boolean isWhitespace();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentCharsetDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentCharsetDetector.java
deleted file mode 100644
index 72a265b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentCharsetDetector.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.encoding;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.document.DocumentReader;
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.xml.core.contenttype.XMLResourceEncodingDetector;
-
-
-/**
- * This class reads and parses first of XML file to get encoding.
- *
- */
-public class XMLDocumentCharsetDetector extends XMLResourceEncodingDetector implements IDocumentCharsetDetector {
-
- /**
- * XMLLoader constructor comment.
- */
- public XMLDocumentCharsetDetector() {
- super();
- }
-
- public void set(IDocument document) {
- set(new DocumentReader(document, 0));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentLoader.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentLoader.java
deleted file mode 100644
index 8436864..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/encoding/XMLDocumentLoader.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.encoding;
-
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.encoding.content.IContentTypeIdentifier;
-import org.eclipse.wst.sse.core.document.AbstractDocumentLoader;
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.internal.parser.XMLStructuredDocumentReParser;
-import org.eclipse.wst.xml.core.text.rules.StructuredTextPartitionerForXML;
-
-
-/**
- * This class reads an XML file and creates an XML Structured Model.
- *
- */
-public class XMLDocumentLoader extends AbstractDocumentLoader {
-
- public XMLDocumentLoader() {
- super();
- }
-
- public RegionParser getParser() {
- return new XMLSourceParser();
- }
-
- public IEncodedDocument newEncodedDocument() {
- BasicStructuredDocument structuredDocument = new BasicStructuredDocument(getParser());
- structuredDocument.setReParser(new XMLStructuredDocumentReParser());
-
- return structuredDocument;
- }
-
- protected String getPreferredNewLineDelimiter() {
- return ContentTypeEncodingPreferences.getPreferredNewLineDelimiter(IContentTypeIdentifier.ContentTypeID_SSEXML);
- }
-
- protected String getSpecDefaultEncoding() {
- // by default, UTF-8 as per XML spec
- final String enc = "UTF-8"; //$NON-NLS-1$
- return enc;
- }
-
- public IDocumentCharsetDetector getDocumentEncodingDetector() {
- if (fDocumentEncodingDetector == null) {
- fDocumentEncodingDetector = new XMLDocumentCharsetDetector();
- }
- return fDocumentEncodingDetector;
- }
-
- public IDocumentPartitioner getDefaultDocumentPartitioner() {
- return new StructuredTextPartitionerForXML();
- }
-
- public IDocumentLoader newInstance() {
- return new XMLDocumentLoader();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/CommentNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/CommentNodeFormatter.java
deleted file mode 100644
index 58bc21b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/CommentNodeFormatter.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.wst.sse.core.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.w3c.dom.Node;
-
-
-public class CommentNodeFormatter extends NodeFormatter {
- protected void formatNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- // lineDelimiterFound means multi line comment
- String nodeValue = node.getNodeValue();
- boolean lineDelimiterFoundInComment = StringUtils.containsLineDelimiter(nodeValue);
-
- if (lineDelimiterFoundInComment) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // adjust indentations in multi line comment
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- String lineIndent = formatContraints.getCurrentIndent();
- String singleIndent = getFormatPreferences().getIndent();
- String newNodevalue = adjustIndentations(nodeValue, lineDelimiter + lineIndent, singleIndent);
- if (nodeValue.compareTo(newNodevalue) != 0)
- node.setNodeValue(newNodevalue);
- }
-
- if (!nodeHasSiblings(node) || (node.getPreviousSibling() != null && node.getPreviousSibling().getNodeType() == Node.TEXT_NODE && !StringUtils.containsLineDelimiter(node.getPreviousSibling().getNodeValue()) && node.getNextSibling() == null)) {
- // single child
- // or inline comment after text
- // do nothing
- }
- else
- // format indentation after node
- formatIndentationAfterNode(node, formatContraints);
- }
- }
-
- protected String adjustIndentations(String aString, String lineIndent, String singleIndent) {
- String result = new String();
-
- int indexOfLineDelimiter = StringUtils.indexOfLineDelimiter(aString);
- result = aString.substring(0, indexOfLineDelimiter);
- while (indexOfLineDelimiter != -1) {
- // Before find the next LineDelimiter, we have to figure out the
- // size of the current LineDelimiter
- // so we can figure out how many bytes to skip before finding the
- // next LineDelimiter.
- // Otherwise, we may treat the LF in CRLF as the next
- // LineDelimiter.
- int lineDelimiterSize = 1;
- if (aString.length() >= indexOfLineDelimiter + 2 && aString.substring(indexOfLineDelimiter, indexOfLineDelimiter + 1).compareTo(CR) == 0 && aString.substring(indexOfLineDelimiter + 1, indexOfLineDelimiter + 2).compareTo(LF) == 0)
- lineDelimiterSize = 2;
-
- int indexOfNextLineDelimiter = StringUtils.indexOfLineDelimiter(aString, indexOfLineDelimiter + lineDelimiterSize);
- int indexOfNonblank = StringUtils.indexOfNonblank(aString, indexOfLineDelimiter);
-
- if (indexOfNonblank != -1) {
- if (indexOfNextLineDelimiter == -1) {
- // last line; copy till the end
- result += lineIndent + singleIndent + aString.substring(indexOfNonblank);
- }
- else if (indexOfNextLineDelimiter != -1 && indexOfNextLineDelimiter < indexOfNonblank) {
- // blank line; just add a indent
- result += lineIndent + singleIndent;
- }
- else {
- // copy all text between indexOfNonblank and
- // indexOfNextLineDelimiter
- result += lineIndent + singleIndent + aString.substring(indexOfNonblank, indexOfNextLineDelimiter);
- }
-
- indexOfLineDelimiter = indexOfNextLineDelimiter;
- }
- else {
- if (indexOfNextLineDelimiter == -1) {
- result += lineIndent;
- }
- else {
- // blank line; just add a indent
- result += lineIndent + singleIndent;
- }
-
- indexOfLineDelimiter = indexOfNextLineDelimiter;
- }
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/DocumentNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/DocumentNodeFormatter.java
deleted file mode 100644
index 4ff9da2..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/DocumentNodeFormatter.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.wst.sse.core.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.format.IStructuredFormatter;
-import org.eclipse.wst.xml.core.document.XMLNode;
-
-
-public class DocumentNodeFormatter extends NodeFormatter {
- protected void formatChildren(XMLNode node, IStructuredFormatContraints formatContraints) {
- String singleIndent = getFormatPreferences().getIndent();
- String lineIndent = formatContraints.getCurrentIndent();
-
- if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- // normalize node first to combine adjacent text nodes
- node.normalize();
-
- XMLNode nextChild = (XMLNode) node.getFirstChild();
- while (nextChild != null) {
- XMLNode eachChildNode = nextChild;
- nextChild = (XMLNode) eachChildNode.getNextSibling();
- IStructuredFormatter formatter = getFormatter(eachChildNode);
- IStructuredFormatContraints childFormatContraints = formatter.getFormatContraints();
- String childIndent = lineIndent + singleIndent;
- childFormatContraints.setCurrentIndent(childIndent);
- childFormatContraints.setClearAllBlankLines(formatContraints.getClearAllBlankLines());
-
- // format each child
- formatter.format(eachChildNode, childFormatContraints);
-
- if (nextChild != null && nextChild.getParentNode() == null)
- // nextNode is deleted during format
- nextChild = (XMLNode) eachChildNode.getNextSibling();
- }
- }
- }
-
- protected void formatNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null)
- formatChildren(node, formatContraints);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/ElementNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/ElementNodeFormatter.java
deleted file mode 100644
index e75f9cb..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/ElementNodeFormatter.java
+++ /dev/null
@@ -1,356 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.modelquery.ModelQueryAdapter;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.document.XMLDocument;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-public class ElementNodeFormatter extends DocumentNodeFormatter {
- static protected final String XML_SPACE = "xml:space";//$NON-NLS-1$
- static protected final String PRESERVE = "preserve";//$NON-NLS-1$
- static protected final String PRESERVE_QUOTED = "\"preserve\"";//$NON-NLS-1$
- static protected final String DOUBLE_QUOTES = "\"\"";//$NON-NLS-1$
- static protected final char SINGLE_QUOTE = '\'';//$NON-NLS-1$
- static protected final char DOUBLE_QUOTE = '"';//$NON-NLS-1$
- static protected final char EQUAL_CHAR = '='; // equal sign$NON-NLS-1$
-
- // format start tag name and
- // format attributes if available
- protected void formatStartTag(XMLNode node, IStructuredFormatContraints formatContraints) {
- String singleIndent = getFormatPreferences().getIndent();
- String lineIndent = formatContraints.getCurrentIndent();
- String attrIndent = lineIndent + singleIndent;
- boolean splitMultiAttrs = ((IStructuredFormatPreferencesXML) fFormatPreferences).getSplitMultiAttrs();
- IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
- NamedNodeMap attributes = node.getAttributes();
- String tagName = node.getNodeName();
-
- // note: attributes should not be null even if the node has no attributes
- // however, attributes.getLength() will be 0
- if (attributes != null) {
- // compute current available line width
- int currentAvailableLineWidth = 0;
- try {
- int nodeNameOffset = node.getStartOffset() + 1 + node.getNodeName().length(); // 1 for "<"
- int lineOffset = node.getStructuredDocument().getLineInformationOfOffset(nodeNameOffset).getOffset();
- String text = node.getStructuredDocument().get(lineOffset, nodeNameOffset - lineOffset);
- int usedWidth = getIndentationLength(text);
- currentAvailableLineWidth = getFormatPreferences().getLineWidth() - usedWidth;
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
-
- StringBuffer stringBuffer = new StringBuffer();
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- int attrLength = attributes.getLength();
- int lastUndefinedRegionOffset = 0;
- for (int i = 0; i < attrLength; i++) {
- AttrImpl attr = (AttrImpl) attributes.item(i);
- ITextRegion nameRegion = attr.getNameRegion();
- ITextRegion equalRegion = attr.getEqualRegion();
- ITextRegion valueRegion = attr.getValueRegion();
-
- // append undefined regions
- String undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, attr.getStartOffset() - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = attr.getStartOffset();
-
- // check for xml:space attribute
- if (flatNode.getText(nameRegion).compareTo(XML_SPACE) == 0) {
- if (valueRegion == null) {
- ModelQueryAdapter adapter = (ModelQueryAdapter) ((XMLDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class);
- CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node);
- if (elementDeclaration == null)
- // CMElementDeclaration not found, default to PRESERVE
- formatContraints.setClearAllBlankLines(false);
- else {
- CMAttributeDeclaration attributeDeclaration = (CMAttributeDeclaration) elementDeclaration.getAttributes().getNamedItem(XML_SPACE);
- if (attributeDeclaration == null)
- // CMAttributeDeclaration not found, default to PRESERVE
- formatContraints.setClearAllBlankLines(false);
- else {
- String defaultValue = attributeDeclaration.getAttrType().getImpliedValue();
-
- if (defaultValue.compareTo(PRESERVE) == 0)
- formatContraints.setClearAllBlankLines(false);
- else
- formatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines());
- }
- }
- }
- else {
- org.eclipse.wst.xml.core.document.XMLGenerator generator = node.getModel().getGenerator();
- String newAttrValue = generator.generateAttrValue(attr);
-
- // There is a problem in StructuredDocumentRegionUtil.getAttrValue(ITextRegion) when the region is instanceof ContextRegion.
- // Workaround for now...
- if (flatNode.getText(valueRegion).length() == 1) {
- char firstChar = flatNode.getText(valueRegion).charAt(0);
- if ((firstChar == DOUBLE_QUOTE) || (firstChar == SINGLE_QUOTE))
- newAttrValue = DOUBLE_QUOTES;
- }
-
- if (newAttrValue.compareTo(PRESERVE_QUOTED) == 0)
- formatContraints.setClearAllBlankLines(false);
- else
- formatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines());
- }
- }
-
- if (splitMultiAttrs && attrLength > 1) {
- stringBuffer.append(lineDelimiter + attrIndent);
- stringBuffer.append(flatNode.getText(nameRegion));
- if (valueRegion != null) {
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(equalRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(equalRegion);
-
- stringBuffer.append(EQUAL_CHAR);
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(valueRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(valueRegion);
-
- // Note: trim() should not be needed for valueRegion.getText()
- // Just a workaround for a problem found in valueRegion for now
- stringBuffer.append(flatNode.getText(valueRegion).trim());
- }
- }
- else {
- if (valueRegion != null) {
- int textLength = 1 + flatNode.getText(nameRegion).length() + 1 + flatNode.getText(valueRegion).length();
- if (i == attrLength - 1) {
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- if (lastRegion.getType() != XMLRegionContext.XML_EMPTY_TAG_CLOSE)
- textLength += 3; // add 3 for " />" if last attr
- else
- textLength++; // add 1 for ">" if last attr
- }
- }
-
- if (currentAvailableLineWidth >= textLength) {
- stringBuffer.append(SPACE_CHAR);
- currentAvailableLineWidth--;
- }
- else {
- stringBuffer.append(lineDelimiter + attrIndent);
- currentAvailableLineWidth = getFormatPreferences().getLineWidth() - attrIndent.length();
- }
-
- stringBuffer.append(flatNode.getText(nameRegion));
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(equalRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(equalRegion);
-
- stringBuffer.append(EQUAL_CHAR);
-
- // append undefined regions
- undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, flatNode.getStartOffset(valueRegion) - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
- lastUndefinedRegionOffset = flatNode.getStartOffset(valueRegion);
-
- // Note: trim() should not be needed for valueRegion.getText()
- // Just a workaround for a problem found in valueRegion for now
- stringBuffer.append(flatNode.getText(valueRegion).trim());
-
- currentAvailableLineWidth -= flatNode.getText(nameRegion).length();
- currentAvailableLineWidth--;
- currentAvailableLineWidth -= flatNode.getText(valueRegion).trim().length();
- }
- else {
- if (currentAvailableLineWidth >= 1 + flatNode.getText(nameRegion).length()) {
- stringBuffer.append(SPACE_CHAR);
- currentAvailableLineWidth--;
- }
- else {
- stringBuffer.append(lineDelimiter + attrIndent);
- currentAvailableLineWidth = getFormatPreferences().getLineWidth() - attrIndent.length();
- }
-
- stringBuffer.append(flatNode.getText(nameRegion));
-
- currentAvailableLineWidth -= flatNode.getText(nameRegion).length();
- }
- }
- }
-
- // append undefined regions
- String undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, node.getEndOffset() - lastUndefinedRegionOffset);
- stringBuffer.append(undefinedRegion);
-
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- int offset = node.getStartOffset() + 1 + node.getNodeName().length(); // 1 is for "<"
- int length = node.getFirstStructuredDocumentRegion().getTextLength() - 1 - node.getNodeName().length(); // 1 is for "<"
-
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion firstRegion = regions.get(0);
- ITextRegion lastRegion = regions.get(regions.size() - 1);
-
- if (firstRegion.getType() == XMLRegionContext.XML_END_TAG_OPEN)
- // skip formatting for end tags in this format: </tagName>
- return;
- else {
- if (lastRegion.getType() == XMLRegionContext.XML_TAG_CLOSE || lastRegion.getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE)
- length = length - lastRegion.getLength();
-
- if (lastRegion.getType() == XMLRegionContext.XML_EMPTY_TAG_CLOSE)
- // leave a space before XML_EMPTY_TAG_CLOSE: <tagName />
- stringBuffer.append(SPACE_CHAR);
- }
- }
-
- replace(structuredDocument, offset, length, stringBuffer.toString());
- }
- }
-
- protected String getUndefinedRegions(XMLNode node, int startOffset, int length) {
- String result = new String();
-
- IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
- ITextRegionList regions = flatNode.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- String regionType = region.getType();
- int regionStartOffset = flatNode.getStartOffset(region);
-
- if (regionType.compareTo(XMLRegionContext.UNDEFINED) == 0 && regionStartOffset >= startOffset && regionStartOffset < startOffset + length)
- result = result + flatNode.getFullText(region);
- }
-
- if (result.length() > 0)
- return SPACE + result.trim();
- else
- return result;
- }
-
- protected void formatEndTag(XMLNode node, IStructuredFormatContraints formatContraints) {
- String tagName = node.getNodeName();
-
- if (!isEndTagMissing(node)) {
- // end tag exists
-
- IStructuredDocument structuredDocument = node.getModel().getStructuredDocument();
- String lineDelimiter = structuredDocument.getLineDelimiter();
- String nodeIndentation = getNodeIndent(node);
- XMLNode lastChild = (XMLNode) node.getLastChild();
- if (lastChild != null && lastChild.getNodeType() != Node.TEXT_NODE) {
- if (isEndTagMissing(lastChild)) {
- // find deepest child
- XMLNode deepestChild = (XMLNode) lastChild.getLastChild();
- while (deepestChild != null && deepestChild.getLastChild() != null && isEndTagMissing(deepestChild)) {
- lastChild = deepestChild;
- deepestChild = (XMLNode) deepestChild.getLastChild();
- }
-
- if (deepestChild != null) {
- if (deepestChild.getNodeType() == Node.TEXT_NODE) {
- // special indentation handling if lastChild's end tag is missing
- // and deepestChild is a text node
- String nodeText = deepestChild.getNodeValue();
-
- if (!nodeText.endsWith(lineDelimiter + nodeIndentation)) {
- nodeText = StringUtils.appendIfNotEndWith(nodeText, lineDelimiter);
- nodeText = StringUtils.appendIfNotEndWith(nodeText, nodeIndentation);
- }
-
- replaceNodeWith(deepestChild, nodeText);
- }
- else
- insertAfterNodeWith(lastChild, lineDelimiter + nodeIndentation);
- }
- }
- else
- // indent end tag
- insertAfterNodeWith(lastChild, lineDelimiter + nodeIndentation);
- }
- else if (lastChild == null && firstStructuredDocumentRegionContainsLineDelimiters(node)) {
- // indent end tag
- replace(structuredDocument, node.getFirstStructuredDocumentRegion().getEndOffset(), 0, lineDelimiter + nodeIndentation);
- }
-
- // format end tag name
- IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion();
- if (endTagStructuredDocumentRegion.getRegions().size() >= 3) {
- ITextRegion endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1);
- removeRegionSpaces(node, endTagStructuredDocumentRegion, endTagNameRegion);
- }
- }
- }
-
- protected void formatNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // format start tag
- XMLNode newNode = node;
- int startTagStartOffset = node.getStartOffset();
- XMLModel structuredModel = node.getModel();
-
- formatStartTag(node, formatContraints);
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node
-
- IStructuredDocumentRegion flatNode = newNode.getFirstStructuredDocumentRegion();
- if (flatNode != null) {
- ITextRegionList regions = flatNode.getRegions();
- ITextRegion lastRegion = regions.get(regions.size() - 1);
- // format children and end tag if not empty start tag
- if (lastRegion.getType() != XMLRegionContext.XML_EMPTY_TAG_CLOSE) {
- // format children
- formatChildren(newNode, formatContraints);
-
- newNode = (XMLNode) structuredModel.getIndexedRegion(startTagStartOffset); // save new node
-
- // format end tag
- formatEndTag(newNode, formatContraints);
- }
- }
-
- // format indentation after node
- formatIndentationAfterNode(newNode, formatContraints);
- }
- }
-
- /**
- * @deprecated - use formatStartTag
- */
- protected void formatAttributes(XMLNode node, IStructuredFormatContraints formatContraints) {
- formatStartTag(node, formatContraints);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/FormatProcessorXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/FormatProcessorXML.java
deleted file mode 100644
index 589b922..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/FormatProcessorXML.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.format.AbstractStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences;
-import org.eclipse.wst.sse.core.format.IStructuredFormatter;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.xml.core.XMLModelPlugin;
-import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
-import org.w3c.dom.Node;
-
-
-public class FormatProcessorXML extends AbstractStructuredFormatProcessor {
- protected IStructuredFormatPreferences fFormatPreferences = null;
-
- public IStructuredFormatPreferences getFormatPreferences() {
- if (fFormatPreferences == null) {
- fFormatPreferences = new StructuredFormatPreferencesXML();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH));
- ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
-
- if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS))
- fFormatPreferences.setIndent("\t"); //$NON-NLS-1$
- else {
- int tabWidth = preferences.getInt(CommonModelPreferenceNames.TAB_WIDTH);
- String indent = ""; //$NON-NLS-1$
- for (int i = 0; i < tabWidth; i++) {
- indent += " "; //$NON-NLS-1$
- }
- fFormatPreferences.setIndent(indent);
- }
- }
- }
-
- return fFormatPreferences;
- }
-
- /**
- * @deprecated renamed to getFileExtension()
- * TODO will delete in C5
- */
- protected String getContentType() {
- return "xml"; //$NON-NLS-1$
- }
-
- protected String getFileExtension() {
- return "xml"; //$NON-NLS-1$
- }
-
- protected IStructuredFormatter getFormatter(Node node) {
- // 262135 - NPE during format of empty document
- if (node == null)
- return null;
-
- short nodeType = node.getNodeType();
- IStructuredFormatter formatter = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE :
- {
- formatter = new ElementNodeFormatter();
- break;
- }
- case Node.TEXT_NODE :
- {
- if (node instanceof CDATASectionImpl)
- formatter = new NodeFormatter();
- else
- formatter = new TextNodeFormatter();
- break;
- }
- case Node.COMMENT_NODE :
- {
- formatter = new CommentNodeFormatter();
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE :
- {
- formatter = new NodeFormatter();
- break;
- }
- case Node.DOCUMENT_NODE :
- {
- formatter = new DocumentNodeFormatter();
- break;
- }
- default :
- {
- formatter = new NodeFormatter();
- }
- }
-
- // init fomatter
- formatter.setFormatPreferences(getFormatPreferences());
- formatter.setProgressMonitor(fProgressMonitor);
-
- return formatter;
- }
-
- protected Preferences getModelPreferences() {
- return XMLModelPlugin.getDefault().getPluginPreferences();
- }
-
- protected void refreshFormatPreferences() {
- fFormatPreferences = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/IStructuredFormatPreferencesXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/IStructuredFormatPreferencesXML.java
deleted file mode 100644
index 1992e70..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/IStructuredFormatPreferencesXML.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences;
-
-public interface IStructuredFormatPreferencesXML extends IStructuredFormatPreferences {
- boolean getSplitMultiAttrs();
-
- void setSplitMultiAttrs(boolean splitMultiAttrs);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java
deleted file mode 100644
index 2c3b821..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/NodeFormatter.java
+++ /dev/null
@@ -1,787 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.format.IStructuredFormatPreferences;
-import org.eclipse.wst.sse.core.format.IStructuredFormatter;
-import org.eclipse.wst.sse.core.format.StructuredFormatContraints;
-import org.eclipse.wst.sse.core.internal.parser.ContextRegion;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.XMLModelPlugin;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.internal.document.CDATASectionImpl;
-import org.eclipse.wst.xml.core.internal.parser.regions.TagNameRegion;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Node;
-
-
-public class NodeFormatter implements IStructuredFormatter {
- static protected final String EMPTY_STRING = ""; //$NON-NLS-1$
- static protected final String SPACE = " "; //$NON-NLS-1$
- static protected final String TAB = "\t"; //$NON-NLS-1$
- static protected final String FF = "\f"; //$NON-NLS-1$
- static protected final String CR = "\r"; //$NON-NLS-1$
- static protected final String LF = "\n"; //$NON-NLS-1$
- static protected final String CRLF = "\r\n"; //$NON-NLS-1$
- static protected final String DELIMITERS = " \t\n\r\f"; //$NON-NLS-1$
- static protected final char SPACE_CHAR = ' '; //$NON-NLS-1$
- static protected final char TAB_CHAR = '\t'; //$NON-NLS-1$
- protected IStructuredFormatPreferences fFormatPreferences = null;
- protected IStructuredFormatContraints fFormatContraints = null;
- protected IProgressMonitor fProgressMonitor = null;
-
- protected String compressSpaces(String string, IStructuredFormatContraints formatContraints) {
- /*
- * Note that the StructuredTextEditor supports mixed new line
- * characters (CR, LF, CRLF) in one file. We have to handle that when
- * we try to preserve blank lines.
- */
- String[] stringArray = null;
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if (clearAllBlankLines)
- stringArray = StringUtils.asArray(string);
- else
- stringArray = StringUtils.asArray(string, DELIMITERS, true);
-
- StringBuffer compressedString = new StringBuffer();
- if (stringArray.length > 0) {
- boolean cr = false, lf = false, cr2 = false, nonSpace = true;
-
- if (stringArray[0].compareTo(CR) == 0)
- cr = true;
- else if (stringArray[0].compareTo(LF) == 0)
- lf = true;
- else if ((stringArray[0].compareTo(SPACE) != 0) && (stringArray[0].compareTo(TAB) != 0) && (stringArray[0].compareTo(FF) != 0)) {
- compressedString.append(stringArray[0]);
- nonSpace = true;
- }
-
- for (int i = 1; i < stringArray.length; i++) {
- if (stringArray[i].compareTo(CR) == 0) {
- if (cr && lf) {
- if (nonSpace) {
- compressedString.append(CR + LF);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- cr2 = true;
- }
- else if (cr) {
- if (nonSpace) {
- compressedString.append(CR);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- cr2 = true;
- }
- else
- cr = true;
- }
- else if (stringArray[i].compareTo(LF) == 0) {
- if (cr && lf && cr2) {
- compressedString.append(stringArray[i]);
- }
- else if (lf) {
- if (nonSpace) {
- compressedString.append(LF);
- nonSpace = false;
- }
- compressedString.append(stringArray[i]);
- }
- else
- lf = true;
- }
- else if ((stringArray[i].compareTo(SPACE) != 0) && (stringArray[i].compareTo(TAB) != 0) && (stringArray[i].compareTo(FF) != 0)) {
- if (compressedString.length() > 0)
- compressedString.append(SPACE);
- compressedString.append(stringArray[i]);
-
- cr = false;
- lf = false;
- cr2 = false;
- nonSpace = true;
- }
- }
- }
-
- return compressedString.toString();
- }
-
- public void format(Node node) {
- IStructuredFormatContraints formatContraints = getFormatContraints();
-
- format(node, formatContraints);
- }
-
- public void format(Node node, IStructuredFormatContraints formatContraints) {
- if (formatContraints.getFormatWithSiblingIndent())
- formatContraints.setCurrentIndent(getSiblingIndent(node));
-
- if (node instanceof XMLNode)
- formatNode((XMLNode) node, formatContraints);
- }
-
- public void setFormatPreferences(IStructuredFormatPreferences formatPreferences) {
- fFormatPreferences = formatPreferences;
- }
-
- public IStructuredFormatPreferences getFormatPreferences() {
- if (fFormatPreferences == null) {
- fFormatPreferences = new StructuredFormatPreferencesXML();
-
- Preferences preferences = getModelPreferences();
- if (preferences != null) {
- fFormatPreferences.setLineWidth(preferences.getInt(CommonModelPreferenceNames.LINE_WIDTH));
- ((IStructuredFormatPreferencesXML) fFormatPreferences).setSplitMultiAttrs(preferences.getBoolean(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS));
- fFormatPreferences.setClearAllBlankLines(preferences.getBoolean(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES));
-
- if (preferences.getBoolean(CommonModelPreferenceNames.INDENT_USING_TABS))
- fFormatPreferences.setIndent("\t"); //$NON-NLS-1$
- else {
- int tabWidth = preferences.getInt(CommonModelPreferenceNames.TAB_WIDTH);
- String indent = ""; //$NON-NLS-1$
- for (int i = 0; i < tabWidth; i++) {
- indent += " "; //$NON-NLS-1$
- }
- fFormatPreferences.setIndent(indent);
- }
- }
- }
-
- return fFormatPreferences;
- }
-
- protected Preferences getModelPreferences() {
- return XMLModelPlugin.getDefault().getPluginPreferences();
- }
-
- public IStructuredFormatContraints getFormatContraints() {
- if (fFormatContraints == null) {
- fFormatContraints = new StructuredFormatContraints();
-
- fFormatContraints.setClearAllBlankLines(getFormatPreferences().getClearAllBlankLines());
- }
-
- return fFormatContraints;
- }
-
- protected void formatIndentationBeforeNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- XMLNode previousSibling = (XMLNode) node.getPreviousSibling();
- IStructuredDocument doc = node.getModel().getStructuredDocument();
- int line = doc.getLineOfOffset(node.getStartOffset());
- String lineDelimiter = doc.getLineDelimiter();
- try {
- if (line > 0) {
- lineDelimiter = doc.getLineDelimiter(line - 1);
- if (lineDelimiter == null)
- lineDelimiter = ""; //$NON-NLS-1$
- }
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- String lineIndent = formatContraints.getCurrentIndent();
- String tagName = node.getNodeName();
-
- if (node.getParentNode() != null) {
- if (node.getParentNode().getNodeType() == Node.DOCUMENT_NODE) {
- if (previousSibling != null)
- if (previousSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(previousSibling).format(previousSibling, formatContraints);
- else {
- insertBeforeNodeWith(node, lineDelimiter + lineIndent);
- }
- }
- else {
- if (previousSibling == null || previousSibling.getNodeType() != Node.TEXT_NODE) {
- // 261968 - formatting tag without closing bracket:
- // <t1><t1
- // 265673 - Null ptr in formatIndentationBeforeNode
- int prevEndNodeOffset = -1;
- int prevEndRegionOffset = -1;
- if (previousSibling != null) {
- prevEndNodeOffset = previousSibling.getEndOffset();
- IStructuredDocumentRegion endRegion = previousSibling.getEndStructuredDocumentRegion();
- if (endRegion != null) {
- prevEndRegionOffset = endRegion.getTextEndOffset();
- }
- }
- if ((previousSibling == null) || (prevEndNodeOffset != -1 && prevEndNodeOffset == prevEndRegionOffset)) {
- insertBeforeNodeWith(node, lineDelimiter + lineIndent);
- }
-
- }
- else {
- if (previousSibling.getNodeValue().length() == 0) {
- // replace
- replaceNodeWith(previousSibling, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- if (!previousSibling.getNodeValue().endsWith(lineDelimiter + lineIndent)) {
- if (previousSibling.getNodeValue().endsWith(lineDelimiter)) {
- insertAfterNodeWith(previousSibling, lineIndent);
- }
- else
- getFormatter(previousSibling).format(previousSibling, formatContraints);
- }
- }
- }
- }
- }
- }
- }
-
- protected void formatIndentationAfterNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- XMLNode nextSibling = (XMLNode) node.getNextSibling();
- IStructuredDocument doc = node.getModel().getStructuredDocument();
- int line = doc.getLineOfOffset(node.getEndOffset());
- String lineDelimiter = doc.getLineDelimiter();
- try {
- lineDelimiter = doc.getLineDelimiter(line);
- if (lineDelimiter == null)
- lineDelimiter = ""; //$NON-NLS-1$
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- String tagName = node.getNodeName();
-
- if (node.getParentNode() != null) {
- if (node.getParentNode().getNodeType() == Node.DOCUMENT_NODE)
- if (nextSibling != null)
- if (nextSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(nextSibling).format(nextSibling, formatContraints);
- else if (nextSibling.getNodeType() == Node.COMMENT_NODE) {
- // do nothing
- }
- else {
- String lineIndent = formatContraints.getCurrentIndent();
- insertAfterNodeWith(node, lineDelimiter + lineIndent);
- }
- else {
- }
-
- else if (nextSibling != null)
- if (nextSibling.getNodeType() == Node.TEXT_NODE)
- getFormatter(nextSibling).format(nextSibling, formatContraints);
- else if (nextSibling.getNodeType() == Node.COMMENT_NODE) {
- // do nothing
- }
- else {
- String lineIndent = formatContraints.getCurrentIndent();
- insertAfterNodeWith(node, lineDelimiter + lineIndent);
- }
- else {
- XMLNode indentNode = getParentIndentNode(node);
- String lineIndent = getNodeIndent(indentNode);
- XMLNode lastChild = getDeepestChildNode(node);
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if (lastChild != null) {
- if ((lastChild.getNodeType() == Node.TEXT_NODE) && (lastChild.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((lastChild.getNodeType() == Node.TEXT_NODE) && (lastChild.getNodeValue() != null && lastChild.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines) {
- replaceNodeWith(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- insertAfterNodeWith(lastChild, lineIndent);
- }
- else if (lastChild.getNodeType() == Node.TEXT_NODE)
- if (lastChild.getNodeValue().length() == 0) {
- // replace
- replaceNodeWith(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- insertAfterNodeWith(lastChild, lineDelimiter + lineIndent);
- }
- else {
- // append indentation
- insertAfterNodeWith(lastChild, lineDelimiter + lineIndent);
- }
- }
- }
- }
- }
- }
-
- protected XMLNode getParentIndentNode(XMLNode node) {
- XMLNode result = null;
- XMLNode parentNode = (XMLNode) node.getParentNode();
-
- if (parentNode.getNodeType() == Node.DOCUMENT_NODE)
- result = parentNode;
- else {
- ITextRegion region = parentNode.getLastStructuredDocumentRegion().getFirstRegion();
- if (region.getType() == XMLRegionContext.XML_END_TAG_OPEN)
- result = parentNode;
- else
- result = getParentIndentNode(parentNode);
- }
-
- return result;
- }
-
- protected XMLNode getDeepestChildNode(XMLNode node) {
- XMLNode result = null;
- XMLNode lastChild = (XMLNode) node.getLastChild();
-
- if (lastChild == null)
- result = node;
- else {
- result = getDeepestChildNode(lastChild);
-
- if ((result.getNodeType() == Node.TEXT_NODE || result.getNodeType() == Node.COMMENT_NODE) && !isEndTagMissing(node))
- result = node;
- }
-
- return result;
- }
-
- protected void formatNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null && (fProgressMonitor == null || !fProgressMonitor.isCanceled())) {
- // format indentation before node
- formatIndentationBeforeNode(node, formatContraints);
-
- // format indentation after node
- formatIndentationAfterNode(node, formatContraints);
- }
- }
-
- /**
- * This method will compute the correct indentation after this node
- * depending on the indentations of its sibling nodes and parent node. Not
- * needed anymore?
- */
- protected void formatTrailingText(XMLNode node, IStructuredFormatContraints formatContraints) {
- String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter();
- String lineIndent = formatContraints.getCurrentIndent();
- String parentLineIndent = getNodeIndent(node.getParentNode());
- boolean clearAllBlankLines = formatContraints.getClearAllBlankLines();
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE)) {
- XMLNode nextSibling = (XMLNode) node.getNextSibling();
- if ((nextSibling != null) && (nextSibling.getNodeType() == Node.TEXT_NODE)) {
- String nextSiblingText = nextSibling.getNodeValue();
- if (nextSibling.getNextSibling() == null)
- if ((nextSibling.getParentNode().getNodeType() == Node.DOCUMENT_NODE) && (nextSiblingText.trim().length() == 0))
- // delete spaces at the end of the document
- replaceNodeWith(nextSibling, EMPTY_STRING);
- else
- // replace the text node with parent indentation
- replaceNodeWith(nextSibling, lineDelimiter + parentLineIndent);
- else
- // replace the text node with indentation
- replaceNodeWith(nextSibling, lineDelimiter + lineIndent);
- }
- else {
- if (nextSibling == null) {
- lineIndent = parentLineIndent;
-
- if (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)
- if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines)
- replaceNodeWith(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNodeWith(node, lineIndent);
- else if (node.getNodeType() == Node.TEXT_NODE)
- if (node.getNodeValue().length() == 0)
- // replace
- replaceNodeWith(node, lineDelimiter + lineIndent);
- else
- // append indentation
- if (!node.getNodeValue().endsWith(lineDelimiter + lineIndent))
- if (node.getNodeValue().endsWith(lineDelimiter))
- insertAfterNodeWith(node, lineIndent);
- else
- insertAfterNodeWith(node, lineDelimiter + lineIndent);
- else
- replaceNodeWith(node, lineDelimiter + lineIndent);
- }
- else {
- if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter + lineIndent))) {
- // this text node already ends with the requested
- // indentation
- }
-
- else if ((node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().endsWith(lineDelimiter)))
- if (clearAllBlankLines)
- replaceNodeWith(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNodeWith(node, lineIndent);
- else if (node.getNodeType() == Node.TEXT_NODE)
- if (node.getNodeValue().length() == 0)
- // replace
- replaceNodeWith(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNodeWith(node, lineDelimiter + lineIndent);
- else
- // append indentation
- insertAfterNodeWith(node, lineDelimiter + lineIndent);
- }
- }
- }
- }
-
- protected String getCompressedNodeText(XMLNode node, IStructuredFormatContraints formatContraints) {
- return compressSpaces(getNodeText(node), formatContraints);
- }
-
- protected int getIndentationLength(String indent) {
- // TODO Kit : The calculation of IndentationLength is not correct
- // here.
- // nodeIndentation may contain tabs. Multiply by 4 temporarily to get
- // approx. width.
- // Need to re-work.
-
- int indentationLength = 0;
-
- for (int i = 0; i < indent.length(); i++) {
- if (indent.substring(i, i + 1).compareTo(TAB) == 0)
- indentationLength += 4;
- else
- indentationLength++;
- }
-
- return indentationLength;
- }
-
- /**
- * This method will find the indentation for this node. It will search
- * backwards starting from the beginning of the node until a character
- * other than a space or a tab is found. If this node is null or it's a
- * document node or it's a first level node (node's parent is a document
- * node) the default empty string will be returned as the indentation.
- */
- protected String getNodeIndent(Node node) {
- String result = EMPTY_STRING;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && (node.getParentNode() != null) && (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)) {
- XMLNode siblingTextNode = (XMLNode) node.getPreviousSibling();
- if ((siblingTextNode != null) && (siblingTextNode.getNodeType() == Node.TEXT_NODE)) {
- // find the indentation
- String siblingText = siblingTextNode.getNodeValue();
- int siblingTextLength = siblingText.length();
- if ((siblingText != null) && (siblingTextLength > 0) && ((siblingText.charAt(siblingTextLength - 1) == SPACE_CHAR) || (siblingText.charAt(siblingTextLength - 1) == TAB_CHAR))) {
- int searchIndex = siblingTextLength - 1;
- while ((searchIndex >= 0) && ((siblingText.charAt(searchIndex) == SPACE_CHAR) || (siblingText.charAt(searchIndex) == TAB_CHAR)))
- searchIndex--;
-
- if (searchIndex < siblingTextLength)
- result = siblingText.substring(searchIndex + 1, siblingTextLength);
- }
- }
- }
-
- return result;
- }
-
- protected String getNodeName(XMLNode node) {
- return node.getNodeName();
- }
-
- protected String getNodeText(XMLNode node) {
- String text = null;
-
- if ((node instanceof org.eclipse.wst.xml.core.internal.document.CharacterDataImpl) && !(node instanceof org.eclipse.wst.xml.core.internal.document.CommentImpl) && !(node instanceof org.eclipse.wst.xml.core.internal.document.CDATASectionImpl) && !isJSPTag(node))
- text = ((org.eclipse.wst.xml.core.internal.document.CharacterDataImpl) node).getSource();
- else
- text = node.getFirstStructuredDocumentRegion().getText();
-
- return text;
- }
-
- protected IStructuredFormatter getFormatter(XMLNode node) {
- // 262135 - NPE during format of empty document
- if (node == null)
- return null;
-
- short nodeType = ((Node) node).getNodeType();
- IStructuredFormatter formatter = null;
- switch (nodeType) {
- case Node.ELEMENT_NODE : {
- formatter = new ElementNodeFormatter();
- break;
- }
- case Node.TEXT_NODE : {
- if (node instanceof CDATASectionImpl)
- formatter = new NodeFormatter();
- else
- formatter = new TextNodeFormatter();
- break;
- }
- case Node.COMMENT_NODE : {
- formatter = new CommentNodeFormatter();
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- formatter = new NodeFormatter();
- break;
- }
- case Node.DOCUMENT_NODE : {
- formatter = new DocumentNodeFormatter();
- break;
- }
- default : {
- formatter = new NodeFormatter();
- }
- }
-
- // init fomatter
- formatter.setFormatPreferences(getFormatPreferences());
- formatter.setProgressMonitor(fProgressMonitor);
-
- return formatter;
- }
-
- /**
- * This method will find the indentation for a node sibling to this node.
- * It will try to find a sibling node before this node first. If there is
- * no sibling node before this node, it will try to find a sibling node
- * after this node. If still not found, we will check if this node is
- * already indented from its parent. If yes, this node's indentation will
- * be used. Otherwise, the parent node's indentation plus one indentation
- * will be used. If this node is null or it's a document node or it's a
- * first level node (node's parent is a document node) the default empty
- * string will be returned as the indentation.
- */
- protected String getSiblingIndent(Node node) {
- String result = EMPTY_STRING;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && (node.getParentNode() != null) && (node.getParentNode().getNodeType() != Node.DOCUMENT_NODE)) {
- // find the text node before the previous non-text sibling
- // if that's not found, we will try the text node before the next
- // non-text sibling
- XMLNode sibling = (XMLNode) node.getPreviousSibling();
- while ((sibling != null) && (sibling.getNodeType() == Node.TEXT_NODE || sibling.getNodeType() == Node.COMMENT_NODE)) {
- if (sibling.getNodeType() == Node.COMMENT_NODE && sibling.getPreviousSibling() != null && sibling.getPreviousSibling().getNodeType() == Node.TEXT_NODE && StringUtils.containsLineDelimiter(sibling.getPreviousSibling().getNodeValue()))
- break;
- sibling = (XMLNode) sibling.getPreviousSibling();
- }
- if (sibling == null) {
- sibling = (XMLNode) node.getNextSibling();
- while ((sibling != null) && (sibling.getNodeType() == Node.TEXT_NODE))
- sibling = (XMLNode) sibling.getNextSibling();
- }
- String singleIndent = getFormatPreferences().getIndent();
- String parentLineIndent = getNodeIndent(node.getParentNode());
-
- if (sibling != null) {
- String siblingIndent = getNodeIndent(sibling);
- if (siblingIndent.length() > 0)
- result = siblingIndent;
- else {
- String nodeIndent = getNodeIndent(node);
- if (nodeIndent.length() > parentLineIndent.length())
- // this node is indented from its parent, its
- // indentation will be used
- result = nodeIndent;
- else
- result = parentLineIndent + singleIndent;
- }
- }
- else {
- String nodeIndent = getNodeIndent(node);
- if (nodeIndent.length() > parentLineIndent.length())
- // this node is indented from its parent, its indentation
- // will be used
- result = nodeIndent;
- else
- result = parentLineIndent + singleIndent;
- }
- }
-
- return result;
- }
-
- protected void insertAfterNodeWith(XMLNode node, String string) {
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- int offset = node.getEndOffset();
- int length = 0;
-
- // 261968 - formatting tag without closing bracket: <t1><t1
- if (node.getEndStructuredDocumentRegion() != null) {
- offset = node.getEndStructuredDocumentRegion().getTextEndOffset();
- length = node.getEndOffset() - offset;
- }
- replace(structuredDocument, offset, length, string);
- }
-
- protected void insertBeforeNodeWith(XMLNode node, String string) {
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- replace(structuredDocument, node.getStartOffset(), 0, string);
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(IStructuredFormatter.class);
- }
-
- protected boolean isEndTagMissing(XMLNode node) {
- boolean result = false;
-
- if ((node != null) && (node.getNodeType() != Node.DOCUMENT_NODE) && !isJSPTag(node)) {
- IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getFirstStructuredDocumentRegion();
- IStructuredDocumentRegion endTagStructuredDocumentRegion = node.getLastStructuredDocumentRegion();
-
- ITextRegion startTagNameRegion = null;
- if (startTagStructuredDocumentRegion.getRegions().size() > 1)
- startTagNameRegion = startTagStructuredDocumentRegion.getRegions().get(1);
- ITextRegion endTagNameRegion = null;
- if (endTagStructuredDocumentRegion.getRegions().size() > 1)
- endTagNameRegion = endTagStructuredDocumentRegion.getRegions().get(1);
-
- ITextRegionList startTagRegions = startTagStructuredDocumentRegion.getRegions();
- if (startTagNameRegion == endTagNameRegion && startTagNameRegion != null && (startTagRegions.get(0)).getType() != XMLRegionContext.XML_END_TAG_OPEN && (startTagRegions.get(startTagRegions.size() - 1).getType()) != XMLRegionContext.XML_EMPTY_TAG_CLOSE)
- // end tag missing
- result = true;
- }
-
- return result;
- }
-
- protected boolean isJSPTag(XMLNode node) {
- boolean result = false;
-
- IStructuredDocumentRegion flatNode = node.getFirstStructuredDocumentRegion();
- // in some cases, the nodes exists, but hasn't been associated with
- // a flatnode yet (the screen updates can be initiated on a different
- // thread,
- // so the request for a flatnode can come in before the node is fully
- // formed.
- // if the flatnode is null, we'll just allow the defaults to apply.
- // (html adapter in this case).
- if (flatNode != null) {
- String flatNodeType = flatNode.getType();
- if ((flatNodeType == XMLJSPRegionContexts.JSP_CONTENT) || (flatNodeType == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DECLARATION_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_NAME) || (flatNodeType == XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN) || (flatNodeType == XMLJSPRegionContexts.JSP_CLOSE)) {
- result = true;
- }
- }
-
- return result;
- }
-
- protected boolean nodeHasSiblings(XMLNode node) {
- return (node.getPreviousSibling() != null) || (node.getNextSibling() != null);
- }
-
- protected boolean firstStructuredDocumentRegionContainsLineDelimiters(XMLNode node) {
- boolean result = false;
-
- if (node != null) {
- IStructuredDocumentRegion firstStructuredDocumentRegion = node.getFirstStructuredDocumentRegion();
- if (firstStructuredDocumentRegion != null && firstStructuredDocumentRegion.getText() != null) {
- String firstStructuredDocumentRegionText = firstStructuredDocumentRegion.getText();
- result = StringUtils.containsLineDelimiter(firstStructuredDocumentRegionText);
- }
- }
-
- return result;
- }
-
- /**
- * Node changed. No format should be performed automatically.
- */
- public void notifyChanged(org.eclipse.wst.sse.core.INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- protected void removeRegionSpaces(XMLNode node, IStructuredDocumentRegion flatNode, ITextRegion region) {
- if ((region != null) && (region instanceof ContextRegion || region instanceof TagNameRegion) && (flatNode.getEndOffset(region) > flatNode.getTextEndOffset(region))) {
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
-
- replace(structuredDocument, flatNode.getTextEndOffset(region), flatNode.getEndOffset(region) - flatNode.getTextEndOffset(region), EMPTY_STRING);
- }
- }
-
- /**
- * This method will replace the string at offset and length with a new
- * string. If the string to be replaced is the same as the new string, the
- * string will not be replaced.
- */
- protected void replace(IStructuredDocument structuredDocument, int offset, int length, String string) {
- try {
- String structuredDocumentString = structuredDocument.get(offset, length);
- if (structuredDocumentString.compareTo(string) != 0)
- structuredDocument.replaceText(structuredDocument, offset, length, string);
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- }
-
- /**
- * This method will replace the node value with a new string. If the node
- * value to be replaced is the same as the new string, the node value will
- * not be replaced.
- */
- protected void replaceNodeWith(XMLNode node, String string) {
- XMLModel structuredModel = node.getModel();
- IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
- int offset = node.getStartOffset();
- int length = node.getEndOffset() - node.getStartOffset();
-
- try {
- String structuredDocumentString = structuredDocument.get(offset, length);
- if (structuredDocumentString.compareTo(string) != 0)
- replace(structuredDocument, offset, length, string);
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/StructuredFormatPreferencesXML.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/StructuredFormatPreferencesXML.java
deleted file mode 100644
index b4f4b5f..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/StructuredFormatPreferencesXML.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import org.eclipse.wst.sse.core.format.StructuredFormatPreferences;
-
-public class StructuredFormatPreferencesXML extends StructuredFormatPreferences implements IStructuredFormatPreferencesXML {
- private boolean fSplitMultiAttrs;
-
- public boolean getSplitMultiAttrs() {
- return fSplitMultiAttrs;
- }
-
- public void setSplitMultiAttrs(boolean splitMultiAttrs) {
- fSplitMultiAttrs = splitMultiAttrs;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/TextNodeFormatter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/TextNodeFormatter.java
deleted file mode 100644
index 165fd96..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/format/TextNodeFormatter.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.format;
-
-import java.util.Vector;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.format.IStructuredFormatContraints;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.w3c.dom.Node;
-
-
-public class TextNodeFormatter extends NodeFormatter {
- protected void formatNode(XMLNode node, IStructuredFormatContraints formatContraints) {
- if (node != null) {
- IStructuredDocument doc = node.getModel().getStructuredDocument();
- int line = doc.getLineOfOffset(node.getStartOffset());
- String lineDelimiter = doc.getLineDelimiter();
- try {
- lineDelimiter = doc.getLineDelimiter(line);
- if (lineDelimiter == null)
- lineDelimiter = ""; //$NON-NLS-1$
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- int lineWidth = getFormatPreferences().getLineWidth();
- XMLNode parentNode = (XMLNode) node.getParentNode();
- XMLNode nextSibling = (XMLNode) node.getNextSibling();
- String nodeIndentation = formatContraints.getCurrentIndent();
-
- // compute current available line width
- int currentAvailableLineWidth = 0;
- try {
- int nodeNameOffset = node.getStartOffset();
- int lineOffset = node.getStructuredDocument().getLineInformationOfOffset(nodeNameOffset).getOffset();
- String text = node.getStructuredDocument().get(lineOffset, nodeNameOffset - lineOffset);
- int usedWidth = getIndentationLength(text);
- currentAvailableLineWidth = getFormatPreferences().getLineWidth() - usedWidth;
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
-
- String compressedText = getCompressedNodeText(node, formatContraints);
-
- if (((compressedText.length() <= (currentAvailableLineWidth - node.getParentNode().getNodeName().length() - 3) && !StringUtils.containsLineDelimiter(compressedText)) && (!nodeHasSiblings(node) || (!StringUtils.containsLineDelimiter(node.getNodeValue()) && node.getNextSibling() != null && node.getNextSibling().getNodeType() == Node.COMMENT_NODE && !StringUtils.containsLineDelimiter(node.getNextSibling().getNodeValue()))) && !firstStructuredDocumentRegionContainsLineDelimiters((XMLNode) node.getParentNode())) || node.getStartStructuredDocumentRegion().getStartOffset() == 0) {
- // enough space
- // and text has no line delimiters
- // and (node has no siblings or followed by inline comment)
- // and
- // parentFirstStructuredDocumentRegionContainsLineDelimiters
-
- if (isEndTagMissing(parentNode)) {
- parentNode = (XMLNode) parentNode.getParentNode();
- while (isEndTagMissing(parentNode))
- parentNode = (XMLNode) parentNode.getParentNode();
-
- // add parent's indentation to end
- nodeIndentation = getNodeIndent(parentNode);
-
- if (!compressedText.endsWith(lineDelimiter + nodeIndentation)) {
- compressedText = StringUtils.appendIfNotEndWith(compressedText, lineDelimiter);
- compressedText = StringUtils.appendIfNotEndWith(compressedText, nodeIndentation);
- }
- }
-
- if ((parentNode != null) && (parentNode.getNodeType() == Node.DOCUMENT_NODE) && (node.getNodeValue().length() > 0) && (node.getNodeValue().trim().length() == 0) && ((node.getPreviousSibling() == null) || (node.getNextSibling() == null)))
- // delete spaces at the beginning or end of the document
- compressedText = EMPTY_STRING;
-
- replaceNodeWith(node, compressedText);
- }
- else {
- // not enough space, need to reflow text
-
- currentAvailableLineWidth = lineWidth - getIndentationLength(nodeIndentation);
- Vector vector = reflowText(compressedText, currentAvailableLineWidth);
- int vectorSize = vector.size();
- String reflowedText = new String();
-
- for (int i = 0; i < vectorSize; i++) {
- if (((String) vector.elementAt(i)).trim().length() > 0)
- reflowedText = reflowedText + lineDelimiter + nodeIndentation + (String) vector.elementAt(i);
- else
- reflowedText = reflowedText + lineDelimiter;
- }
-
- if (node.getNextSibling() == null) {
- if (isEndTagMissing(parentNode)) {
- // don't add indentation to end if parent end tag is
- // missing
- }
-
- else {
- // add parent's indentation to end
- nodeIndentation = getNodeIndent(parentNode);
-
- if (!reflowedText.endsWith(lineDelimiter + nodeIndentation)) {
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- }
- else {
- if (!reflowedText.endsWith(lineDelimiter + nodeIndentation)) {
- // not already ended with the expected indentation
-
- if (node.getNextSibling().getNodeType() == Node.COMMENT_NODE) {
- // add indentation to end if
- // currentTextEndsWithLineDelimiter
- // or followed by multiLineComment
-
- String nodeText = getNodeText(node);
- int indexOfLastLineDelimiter = StringUtils.indexOfLastLineDelimiter(nodeText);
- boolean currentTextEndsWithLineDelimiter = indexOfLastLineDelimiter != -1;
- if (currentTextEndsWithLineDelimiter) {
- // no more non blank character after the last
- // line delimiter
- currentTextEndsWithLineDelimiter = StringUtils.indexOfNonblank(nodeText, indexOfLastLineDelimiter) == -1;
- }
-
- String nodeValue = node.getNextSibling().getNodeValue();
- boolean multiLineComment = StringUtils.containsLineDelimiter(nodeValue);
-
- if (currentTextEndsWithLineDelimiter || multiLineComment) {
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- else {
- // not a comment, just add add indentation to end
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, lineDelimiter);
- reflowedText = StringUtils.appendIfNotEndWith(reflowedText, nodeIndentation);
- }
- }
- }
-
- replaceNodeWith(node, reflowedText);
- }
-
- }
- }
-
- protected Vector reflowText(String text, int availableWidth) {
- String[] stringArray = null;
- boolean clearAllBlankLines = getFormatPreferences().getClearAllBlankLines();
-
- if (clearAllBlankLines)
- stringArray = StringUtils.asArray(text);
- else
- stringArray = StringUtils.asArray(text, DELIMITERS, true);
-
- Vector output = new Vector();
- if ((stringArray != null) && (stringArray.length > 0)) {
- StringBuffer buffer = new StringBuffer();
- if (stringArray[0].compareTo(CR) != 0)
- buffer.append(stringArray[0]);
- int bufferLength = stringArray[0].toString().length();
- boolean cr = stringArray[0].compareTo(CR) == 0;
-
- for (int i = 1; i < stringArray.length; i++) {
- String eachString = stringArray[i];
- if ((eachString.compareTo(SPACE) != 0) && (eachString.compareTo(TAB) != 0) && (eachString.compareTo(FF) != 0)) {
- if ((bufferLength + 1 + eachString.length() > availableWidth) || (eachString.compareTo(CR) == 0) || (eachString.compareTo(LF) == 0)) {
- if ((eachString.compareTo(LF) == 0) && cr) {
- // do nothing
- }
- else {
- output.add(buffer.toString());
- buffer = new StringBuffer();
- bufferLength = 0;
- }
- cr = eachString.compareTo(CR) == 0;
- }
- else if (buffer.toString().trim().length() > 0) {
- buffer.append(SPACE);
- bufferLength++;
- }
- if ((eachString.compareTo(CR) != 0) && (eachString.compareTo(LF) != 0)) {
- buffer.append(eachString);
- bufferLength = bufferLength + eachString.length();
- }
- }
- }
- output.add(buffer.toString());
- }
- else
- output.add(text);
-
- return output;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java
deleted file mode 100644
index 8479291..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/ByteReader.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-/**
- * This is an "adapter" class, simply to get in input stream
- * to act like a reader. We could not use InputStreamReader directly
- * because its internal buffers are not controllable, and it sometimes
- * pulls too much out of input stream (even when it wasn't needed for
- * our purposes).
- *
- * The use of this class is highly specialized and by not means
- * meant to be general purpose. Its use is restricted to
- * those cases where the input stream can be regarded as
- * ascii just long enough to determine what the real encoding
- * should be.
- */
-
-public class ByteReader extends Reader {
-
- /** Default byte buffer size (2048). */
- public static final int DEFAULT_BUFFER_SIZE = 2048;
-
- protected byte[] fBuffer;
-
- protected InputStream fInputStream;
-
- protected ByteReader() {
- super();
- }
-
- public ByteReader(InputStream inputStream) {
- this(inputStream, DEFAULT_BUFFER_SIZE);
- if (!inputStream.markSupported()) {
- throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
- }
- }
-
- public ByteReader(InputStream inputStream, int size) {
- fInputStream = inputStream;
- if (!inputStream.markSupported()) {
- throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$
- }
- fBuffer = new byte[size];
-
- }
-
- public void close() throws IOException {
- fInputStream.close();
- }
-
- public void mark(int readAheadLimit) throws IOException {
- fInputStream.mark(readAheadLimit);
- }
-
- public boolean markSupported() {
- return true;
- }
-
- public int read() throws IOException {
- int b0 = fInputStream.read();
- return (b0 & 0x00FF);
- }
-
- public int read(char ch[], int offset, int length) throws IOException {
- if (length > fBuffer.length) {
- length = fBuffer.length;
- }
-
- int count = fInputStream.read(fBuffer, 0, length);
-
- for (int i = 0; i < count; i++) {
- int b0 = fBuffer[i];
- // the 0x00FF is to "lose" the negative bits filled in the byte to int conversion
- // (and which would be there if cast directly from byte to char).
- char c0 = (char) (b0 & 0x00FF);
- ch[i] = c0;
- }
- return count;
- }
-
- public boolean ready() throws IOException {
- return fInputStream.available() > 0;
- }
-
- public void reset() throws IOException {
- fInputStream.reset();
- }
-
- public long skip(long n) throws IOException {
- return fInputStream.skip(n);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java
deleted file mode 100644
index d791f78..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/EncodingParserConstants.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-
-public interface EncodingParserConstants {
-
- final String EOF = "EOF"; //$NON-NLS-1$
- final String StringValue = "strval"; //$NON-NLS-1$
- final String MAX_CHARS_REACHED = "MAX_CHARS_REACHED"; //$NON-NLS-1$
- final String UnDelimitedStringValue = "UnDelimitedStringValue"; //$NON-NLS-1$
- final String InvalidTermintatedUnDelimitedStringValue = "InvalidTermintatedUnDelimitedStringValue"; //$NON-NLS-1$
- final String InvalidTerminatedStringValue = "InvalidTerminatedStringValue"; //$NON-NLS-1$
-
-
- String UTF83ByteBOM = "UTF83ByteBOM"; //$NON-NLS-1$
- String UTF16LE = "UTF16LE"; //$NON-NLS-1$
- String UTF16BE = "UTF16BE"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java
deleted file mode 100644
index b5c35d2..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/HeadParserToken.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-public class HeadParserToken {
-
- private String fText;
- private String fType;
- private int fStart;
-
- public String getText() {
- return fText;
- }
-
- public String getType() {
- return fType;
- }
-
- protected HeadParserToken() {
- super();
- }
-
- public HeadParserToken(String type, int start, String text) {
- this();
- fType = type;
- fStart = start;
- fText = text;
-
- }
-
- public String toString() {
- return ("text: " + fText + " offset: " + fStart + " type: " + fType); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java
deleted file mode 100644
index ede644b..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/IntStack.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-/*
- *
- * A non-resizable class implementing the behavior of java.util.Stack, but
- * directly for the <code> integer </code> primitive.
- */
-import java.util.EmptyStackException;
-
-public class IntStack {
-
- private int size = 0;
- private int[] list = null;
-
- public IntStack() {
- this(100);
- }
-
- public IntStack(int maxdepth) {
- super();
- list = new int[maxdepth];
- initialize();
- }
-
- public boolean empty() {
- return size == 0;
- }
-
- public int get(int slot) {
- return list[slot];
- }
-
- private void initialize() {
- for (int i = 0; i < list.length; i++)
- list[i] = -1;
- }
-
- /**
- * Returns the int at the top of the stack without removing it
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int peek() {
- if (size == 0)
- throw new EmptyStackException();
- return list[size - 1];
- }
-
- /**
- * Removes and returns the int at the top of the stack
- *
- * @return int at the top of this stack.
- * @exception EmptyStackException
- * when empty.
- */
- public int pop() {
- int value = peek();
- list[size - 1] = -1;
- size--;
- return value;
- }
-
- /**
- * Pushes an item onto the top of this stack.
- *
- * @param newValue -
- * the int to be pushed onto this stack.
- * @return the <code>newValue</code> argument.
- */
- public int push(int newValue) {
- if (size == list.length) {
- throw new StackOverflowError();
- }
- list[size++] = newValue;
- return newValue;
- }
-
- public int size() {
- return list.length;
- }
-
- public void clear() {
- initialize();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java
deleted file mode 100644
index e9be229..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLDeclDetector.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-public class XMLDeclDetector {
- private boolean DEBUG = false;
- private XMLHeadTokenizer fTokenizer;
- protected boolean fHeaderParsed;
- protected Reader fReader;
- private boolean fIsXML;
- private static final int MAX_MARK_SIZE = 1024 * 2;
- private static final int MAX_BUF_SIZE = 1024 * 2;
- private String fUnicode;
-
- /**
- * @return Returns the tokenizer.
- */
- private XMLHeadTokenizer getTokenizer() {
- if (fTokenizer == null) {
- fTokenizer = new XMLHeadTokenizer();
- }
- return fTokenizer;
- }
-
- private boolean canHandleAsUnicodeStream(String tokenType) {
- boolean canHandleAsUnicodeStream = false;
- if (tokenType == EncodingParserConstants.UTF83ByteBOM) {
- canHandleAsUnicodeStream = true;
- fUnicode = "UTF-8"; //$NON-NLS-1$
- }
- else if (tokenType == EncodingParserConstants.UTF16BE) {
- canHandleAsUnicodeStream = true;
- fUnicode = "UTF-16BE"; //$NON-NLS-1$
- }
- else if (tokenType == EncodingParserConstants.UTF16LE) {
- canHandleAsUnicodeStream = true;
- fUnicode = "UTF-16"; //$NON-NLS-1$
- }
- return canHandleAsUnicodeStream;
- }
-
- private void parseInput() throws IOException {
- XMLHeadTokenizer tokenizer = getTokenizer();
- tokenizer.reset(fReader);
- HeadParserToken token = null;
- String tokenType = null;
- do {
- token = tokenizer.getNextToken();
- tokenType = token.getType();
- if (canHandleAsUnicodeStream(tokenType)) {
- fReader.reset();
- // this is (obviously) not always true.
- // TODO: need to fix so we "remember" original iFile or
- // inputstream, and
- // create appropriate InputStreamReader.
- // I'm not sure what to do for the set(reader) case ... if its
- // even relevent.
- // plus, ensure against infinite loops!
- fIsXML = true;
- //fReader = new InputStreamReader(fReader, fUnicode);
- // parseInput();
- }
- else {
- if (tokenType == XMLHeadTokenizerConstants.XMLDelEncoding) {
- fIsXML = true;
- }
- }
- }
- while (tokenizer.hasMoreTokens());
-
- }
-
- final private void ensureInputSet() {
- if (fReader == null) {
- throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$
- }
- }
-
- private void resetAll() {
- fReader = null;
- fHeaderParsed = false;
- fIsXML = false;
- fUnicode = null;
-
- }
-
- public void set(IFile iFile) throws CoreException {
- resetAll();
- InputStream inputStream = iFile.getContents(true);
- InputStream resettableStream = new BufferedInputStream(inputStream, MAX_BUF_SIZE);
- resettableStream.mark(MAX_MARK_SIZE);
- set(resettableStream);
- }
-
- public void set(InputStream inputStream) {
- resetAll();
- fReader = new ByteReader(inputStream);
- try {
- fReader.mark(MAX_MARK_SIZE);
- }
- catch (IOException e) {
- // impossible, since we know ByteReader supports marking
- throw new Error(e);
- }
- }
-
- /**
- * Note: this is not part of interface to help avoid confusion ... it
- * expected this Reader is a well formed character reader ... that is, its
- * all ready been determined to not be a unicode marked input stream. And,
- * its assumed to be in the correct position, at position zero, ready to
- * read first character.
- */
- public void set(Reader reader) {
- resetAll();
- fReader = reader;
- if (!fReader.markSupported()) {
- fReader = new BufferedReader(fReader);
- }
-
- try {
- fReader.mark(MAX_MARK_SIZE);
- }
- catch (IOException e) {
- // impossble, since we just checked if markable
- throw new Error(e);
- }
-
- }
-
- /**
- * @return Returns the isXML.
- */
- public boolean isXML() throws IOException {
- ensureInputSet();
- if (!fHeaderParsed) {
- parseInput();
- }
- return fIsXML;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java
deleted file mode 100644
index ee6652a..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizer.java
+++ /dev/null
@@ -1,1231 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-/* The following code was generated by JFlex 1.2.2 on 4/6/04 11:13 PM */
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-import java.io.IOException;
-import java.io.Reader;
-
-
-
-/**
- * This class is a scanner generated by
- * <a href="http://www.informatik.tu-muenchen.de/~kleing/jflex/">JFlex</a> 1.2.2
- * on 4/6/04 11:13 PM from the specification file
- * <tt>file:/D:/DevTimeSupport/HeadParsers/XMLHeadTokenizer/XMLHeadTokenizer.jflex</tt>
- */
-public class XMLHeadTokenizer {
-
- /** this character denotes the end of file */
- final public static int YYEOF = -1;
-
- /** lexical states */
- final public static int YYINITIAL = 0;
- final public static int UnDelimitedString = 10;
- final public static int DQ_STRING = 6;
- final public static int SQ_STRING = 8;
- final public static int ST_XMLDecl = 2;
- final public static int QuotedAttributeValue = 4;
-
- /**
- * YY_LEXSTATE[l] is the state in the DFA for the lexical state l
- * YY_LEXSTATE[l+1] is the state in the DFA for the lexical state l
- * at the beginning of a line
- * l is of the form l = 2*k, k a non negative integer
- */
- private final static int YY_LEXSTATE[] = {0, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6};
-
- /**
- * Translates characters to character classes
- */
- final private static String yycmap_packed = "\11\0\1\6\1\7\2\0\1\11\22\0\1\6\1\0\1\27\2\0" + "\1\31\1\0\1\30\24\0\1\12\1\10\1\26\1\13\3\0\1\21" + "\1\23\1\17\1\0\1\25\1\0\1\24\2\0\1\16\1\15\1\20" + "\1\22\10\0\1\14\12\0\1\21\1\23\1\17\1\0\1\25\1\0" + "\1\24\2\0\1\16\1\15\1\20\1\22\10\0\1\14\102\0\1\4" + "\3\0\1\5\17\0\1\3\16\0\1\1\20\0\1\3\16\0\1\1" + "\1\2\170\0\1\2\ufe87\0";
-
- /**
- * Translates characters to character classes
- */
- final private static char[] yycmap = yy_unpack_cmap(yycmap_packed);
-
-
- /* error codes */
- final private static int YY_UNKNOWN_ERROR = 0;
- final private static int YY_ILLEGAL_STATE = 1;
- final private static int YY_NO_MATCH = 2;
- final private static int YY_PUSHBACK_2BIG = 3;
-
- /* error messages for the codes above */
- final private static String YY_ERROR_MSG[] = {"Unkown internal scanner error", "Internal error: unknown state", "Error: could not match input", "Error: pushback value was too large"};
-
- /** the input device */
- private java.io.Reader yy_reader;
-
- /** the current state of the DFA */
- private int yy_state;
-
- /** the current lexical state */
- private int yy_lexical_state = YYINITIAL;
-
- /** this buffer contains the current text to be matched and is
- the source of the yytext() string */
- private char yy_buffer[] = new char[16384];
-
- /** the textposition at the last accepting state */
- private int yy_markedPos;
-
- /** the textposition at the last state to be included in yytext */
- private int yy_pushbackPos;
-
- /** the current text position in the buffer */
- private int yy_currentPos;
-
- /** startRead marks the beginning of the yytext() string in the buffer */
- private int yy_startRead;
-
- /** endRead marks the last character in the buffer, that has been read
- from input */
- private int yy_endRead;
-
- /** number of newlines encountered up to the start of the matched text */
- private int yyline;
-
- /** the number of characters up to the start of the matched text */
- private int yychar;
-
- /**
- * the number of characters from the last newline up to the start of the
- * matched text
- */
- private int yycolumn;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning of a line
- */
- private boolean yy_atBOL;
-
- /** yy_atEOF == true <=> the scanner has returned a value for EOF */
- private boolean yy_atEOF;
-
- /** denotes if the user-EOF-code has already been executed */
- private boolean yy_eof_done;
-
- /* user code: */
-
-
- private boolean hasMore = true;
- private final static int MAX_TO_SCAN = 1000;
- StringBuffer string = new StringBuffer();
- // state stack for easier state handling
- private IntStack fStateStack = new IntStack();
- private String valueText = null;
-
-
- public XMLHeadTokenizer() {
- super();
- }
-
- public void reset(Reader in) {
- /* the input device */
- yy_reader = in;
-
- /* the current state of the DFA */
- yy_state = 0;
-
- /* the current lexical state */
- yy_lexical_state = YYINITIAL;
-
- /* this buffer contains the current text to be matched and is
- the source of the yytext() string */
- java.util.Arrays.fill(yy_buffer, (char) 0);
-
- /* the textposition at the last accepting state */
- yy_markedPos = 0;
-
- /* the textposition at the last state to be included in yytext */
- yy_pushbackPos = 0;
-
- /* the current text position in the buffer */
- yy_currentPos = 0;
-
- /* startRead marks the beginning of the yytext() string in the buffer */
- yy_startRead = 0;
-
- /**
- * endRead marks the last character in the buffer, that has been read
- * from input
- */
- yy_endRead = 0;
-
- /* number of newlines encountered up to the start of the matched text */
- yyline = 0;
-
- /* the number of characters up to the start of the matched text */
- yychar = 0;
-
- /**
- * the number of characters from the last newline up to the start
- * of the matched text
- */
- yycolumn = 0;
-
- /**
- * yy_atBOL == true <=> the scanner is currently at the beginning
- * of a line
- */
- yy_atBOL = false;
-
- /* yy_atEOF == true <=> the scanner has returned a value for EOF */
- yy_atEOF = false;
-
- /* denotes if the user-EOF-code has already been executed */
- yy_eof_done = false;
-
-
- fStateStack.clear();
-
- hasMore = true;
-
- // its a little wasteful to "throw away" first char array generated
- // by class init (via auto generated code), but we really do want
- // a small buffer for our head parsers.
- if (yy_buffer.length != MAX_TO_SCAN) {
- yy_buffer = new char[MAX_TO_SCAN];
- }
-
-
- }
-
-
- public final HeadParserToken getNextToken() throws IOException {
- String context = null;
- context = primGetNextToken();
- HeadParserToken result = null;
- if (valueText != null) {
- result = createToken(context, yychar, valueText);
- valueText = null;
- }
- else {
- result = createToken(context, yychar, yytext());
- }
- return result;
- }
-
- public final boolean hasMoreTokens() {
- return hasMore && yychar < MAX_TO_SCAN;
- }
-
- private void pushCurrentState() {
- fStateStack.push(yystate());
-
- }
-
- private void popState() {
- yybegin(fStateStack.pop());
- }
-
- private HeadParserToken createToken(String context, int start, String text) {
- return new HeadParserToken(context, start, text);
- }
-
-
-
- /**
- * Creates a new scanner
- * There is also a java.io.InputStream version of this constructor.
- *
- * @param in the java.io.Reader to read input from.
- */
- public XMLHeadTokenizer(java.io.Reader in) {
- this.yy_reader = in;
- }
-
- /**
- * Creates a new scanner.
- * There is also java.io.Reader version of this constructor.
- *
- * @param in the java.io.Inputstream to read input from.
- */
- public XMLHeadTokenizer(java.io.InputStream in) {
- this(new java.io.InputStreamReader(in));
- }
-
- /**
- * Unpacks the compressed character translation table.
- *
- * @param packed the packed character translation table
- * @return the unpacked character translation table
- */
- private static char[] yy_unpack_cmap(String packed) {
- char[] map = new char[0x10000];
- int i = 0; /* index in packed string */
- int j = 0; /* index in unpacked array */
- while (i < 128) {
- int count = packed.charAt(i++);
- char value = packed.charAt(i++);
- do
- map[j++] = value;
- while (--count > 0);
- }
- return map;
- }
-
-
- /**
- * Gets the next input character.
- *
- * @return the next character of the input stream, EOF if the
- * end of the stream is reached.
- * @exception IOException if any I/O-Error occurs
- */
- private int yy_advance() throws java.io.IOException {
-
- /* standard case */
- if (yy_currentPos < yy_endRead)
- return yy_buffer[yy_currentPos++];
-
- /* if the eof is reached, we don't need to work hard */
- if (yy_atEOF)
- return YYEOF;
-
- /* otherwise: need to refill the buffer */
-
- /* first: make room (if you can) */
- if (yy_startRead > 0) {
- System.arraycopy(yy_buffer, yy_startRead, yy_buffer, 0, yy_endRead - yy_startRead);
-
- /* translate stored positions */
- yy_endRead -= yy_startRead;
- yy_currentPos -= yy_startRead;
- yy_markedPos -= yy_startRead;
- yy_pushbackPos -= yy_startRead;
- yy_startRead = 0;
- }
-
- /* is the buffer big enough? */
- if (yy_currentPos >= yy_buffer.length) {
- /* if not: blow it up */
- char newBuffer[] = new char[yy_currentPos * 2];
- System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length);
- yy_buffer = newBuffer;
- }
-
- /* finally: fill the buffer with new input */
- int numRead = yy_reader.read(yy_buffer, yy_endRead, yy_buffer.length - yy_endRead);
-
- if (numRead == -1)
- return YYEOF;
-
- yy_endRead += numRead;
-
- return yy_buffer[yy_currentPos++];
- }
-
-
- /**
- * Closes the input stream.
- */
- final public void yyclose() throws java.io.IOException {
- yy_atEOF = true; /* indicate end of file */
- yy_endRead = yy_startRead; /* invalidate buffer */
- yy_reader.close();
- }
-
-
- /**
- * Returns the current lexical state.
- */
- final public int yystate() {
- return yy_lexical_state;
- }
-
- /**
- * Enters a new lexical state
- *
- * @param newState the new lexical state
- */
- final public void yybegin(int newState) {
- yy_lexical_state = newState;
- }
-
-
- /**
- * Returns the text matched by the current regular expression.
- */
- final public String yytext() {
- return new String(yy_buffer, yy_startRead, yy_markedPos - yy_startRead);
- }
-
- /**
- * Returns the length of the matched text region.
- */
- final public int yylength() {
- return yy_markedPos - yy_startRead;
- }
-
-
- /**
- * Reports an error that occured while scanning.
- *
- * @param errorCode the code of the errormessage to display
- */
- private void yy_ScanError(int errorCode) {
- try {
- System.out.println(YY_ERROR_MSG[errorCode]);
- }
- catch (ArrayIndexOutOfBoundsException e) {
- System.out.println(YY_ERROR_MSG[YY_UNKNOWN_ERROR]);
- }
-
- // System.exit(1);
- }
-
-
- /**
- * Pushes the specified amount of characters back into the input stream.
- *
- * They will be read again by then next call of the scanning method
- *
- * @param number the number of characters to be read again.
- * This number must not be greater than yylength()!
- */
- private void yypushback(int number) {
- if (number > yylength())
- yy_ScanError(YY_PUSHBACK_2BIG);
-
- yy_markedPos -= number;
- }
-
-
- /**
- * Contains user EOF-code, which will be executed exactly once,
- * when the end of file is reached
- */
- private void yy_do_eof() {
- if (!yy_eof_done) {
- yy_eof_done = true;
- hasMore = false;
-
- }
- }
-
-
- /**
- * Resumes scanning until the next regular expression is matched,
- * the end of input is encountered or an I/O-Error occurs.
- *
- * @return the next token
- * @exception IOException if any I/O-Error occurs
- */
- public String primGetNextToken() throws java.io.IOException {
- int yy_input;
- int yy_action;
-
-
- while (true) {
-
- yychar += yylength();
-
- yy_atBOL = yy_markedPos <= 0 || yy_buffer[yy_markedPos - 1] == '\n';
- if (!yy_atBOL && yy_buffer[yy_markedPos - 1] == '\r') {
- yy_atBOL = yy_advance() != '\n';
- if (!yy_atEOF)
- yy_currentPos--;
- }
-
- yy_action = -1;
-
- yy_currentPos = yy_startRead = yy_markedPos;
-
- if (yy_atBOL)
- yy_state = YY_LEXSTATE[yy_lexical_state + 1];
- else
- yy_state = YY_LEXSTATE[yy_lexical_state];
-
-
- yy_forAction : {
- while (true) {
-
- yy_input = yy_advance();
-
- if (yy_input == YYEOF)
- break yy_forAction;
-
- yy_input = yycmap[yy_input];
-
- boolean yy_isFinal = false;
- boolean yy_noLookAhead = false;
-
- yy_forNext : {
- switch (yy_state) {
- case 0 :
- switch (yy_input) {
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 1 :
- switch (yy_input) {
- case 1 :
- yy_isFinal = true;
- yy_state = 8;
- break yy_forNext;
- case 2 :
- yy_isFinal = true;
- yy_state = 9;
- break yy_forNext;
- case 3 :
- yy_isFinal = true;
- yy_state = 10;
- break yy_forNext;
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 11;
- break yy_forNext;
- case 10 :
- yy_isFinal = true;
- yy_state = 12;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 2 :
- switch (yy_input) {
- case 11 :
- yy_isFinal = true;
- yy_state = 13;
- break yy_forNext;
- case 15 :
- yy_isFinal = true;
- yy_state = 14;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 7;
- break yy_forNext;
- }
-
- case 3 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_isFinal = true;
- yy_state = 17;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 18;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 19;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 4 :
- switch (yy_input) {
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- case 11 :
- yy_isFinal = true;
- yy_state = 22;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 23;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 24;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 5 :
- switch (yy_input) {
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 25;
- break yy_forNext;
- case 25 :
- yy_isFinal = true;
- yy_state = 26;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 6 :
- switch (yy_input) {
- case 11 :
- yy_isFinal = true;
- yy_state = 26;
- break yy_forNext;
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 27;
- break yy_forNext;
- case 23 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 28;
- break yy_forNext;
- case 24 :
- yy_isFinal = true;
- yy_state = 29;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 20;
- break yy_forNext;
- }
-
- case 8 :
- switch (yy_input) {
- case 2 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 30;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 9 :
- switch (yy_input) {
- case 1 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 31;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 10 :
- switch (yy_input) {
- case 4 :
- yy_state = 32;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 11 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 33;
- break yy_forNext;
- case 10 :
- yy_state = 34;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 12 :
- switch (yy_input) {
- case 11 :
- yy_state = 35;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 13 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 36;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 14 :
- switch (yy_input) {
- case 16 :
- yy_state = 37;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 16 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 17 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 22 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 39;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 24 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 25 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 26 :
- switch (yy_input) {
- case 22 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 41;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 29 :
- switch (yy_input) {
- case 10 :
- yy_state = 40;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 32 :
- switch (yy_input) {
- case 5 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 42;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 33 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 33;
- break yy_forNext;
- case 10 :
- yy_state = 34;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 34 :
- switch (yy_input) {
- case 11 :
- yy_state = 35;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 35 :
- switch (yy_input) {
- case 12 :
- yy_state = 43;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 37 :
- switch (yy_input) {
- case 17 :
- yy_state = 44;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 38 :
- switch (yy_input) {
- case 6 :
- case 9 :
- yy_isFinal = true;
- yy_state = 16;
- break yy_forNext;
- case 7 :
- yy_state = 38;
- break yy_forNext;
- default :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 15;
- break yy_forNext;
- }
-
- case 40 :
- switch (yy_input) {
- case 24 :
- yy_isFinal = true;
- yy_noLookAhead = true;
- yy_state = 21;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 43 :
- switch (yy_input) {
- case 13 :
- yy_state = 45;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 44 :
- switch (yy_input) {
- case 18 :
- yy_state = 46;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 45 :
- switch (yy_input) {
- case 14 :
- yy_state = 47;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 46 :
- switch (yy_input) {
- case 19 :
- yy_state = 48;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 47 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 49;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 48 :
- switch (yy_input) {
- case 20 :
- yy_state = 50;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 49 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 49;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 50 :
- switch (yy_input) {
- case 16 :
- yy_state = 51;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 51 :
- switch (yy_input) {
- case 21 :
- yy_state = 52;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 52 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_state = 52;
- break yy_forNext;
- case 8 :
- yy_isFinal = true;
- yy_state = 53;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- case 53 :
- switch (yy_input) {
- case 6 :
- case 7 :
- case 9 :
- yy_isFinal = true;
- yy_state = 53;
- break yy_forNext;
- default :
- break yy_forAction;
- }
-
- default :
- yy_ScanError(YY_ILLEGAL_STATE);
- break;
- }
- }
-
- if (yy_isFinal) {
- yy_action = yy_state;
- yy_markedPos = yy_currentPos;
- if (yy_noLookAhead)
- break yy_forAction;
- }
-
- }
- }
-
-
- switch (yy_action) {
-
- case 25 :
- {
- popState();
- valueText = string.toString();
- return EncodingParserConstants.StringValue;
- }
- case 55 :
- break;
- case 21 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 56 :
- break;
- case 15 :
- case 16 :
- {
- yypushback(1);
- yybegin(UnDelimitedString);
- string.setLength(0);
- }
- case 57 :
- break;
- case 28 :
- case 29 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTermintatedUnDelimitedStringValue;
- }
- case 58 :
- break;
- case 39 :
- {
- yypushback(2);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 59 :
- break;
- case 41 :
- {
- yypushback(2);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.InvalidTerminatedStringValue;
- }
- case 60 :
- break;
- case 7 :
- case 8 :
- case 9 :
- case 10 :
- case 11 :
- case 12 :
- case 13 :
- case 14 :
- case 17 :
- {
- if (yychar > MAX_TO_SCAN) {
- hasMore = false;
- return EncodingParserConstants.MAX_CHARS_REACHED;
- }
- }
- case 61 :
- break;
- case 30 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF16BE;
- }
- }
- case 62 :
- break;
- case 31 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF16LE;
- }
- }
- case 63 :
- break;
- case 42 :
- {
- if (yychar == 0) {
- hasMore = false;
- return EncodingParserConstants.UTF83ByteBOM;
- }
- }
- case 64 :
- break;
- case 49 :
- {
- if (yychar == 0) {
- yybegin(ST_XMLDecl);
- return XMLHeadTokenizerConstants.XMLDeclStart;
- }
- }
- case 65 :
- break;
- case 36 :
- {
- yybegin(YYINITIAL);
- hasMore = false;
- return XMLHeadTokenizerConstants.XMLDeclEnd;
- }
- case 66 :
- break;
- case 53 :
- {
- pushCurrentState();
- yybegin(QuotedAttributeValue);
- return XMLHeadTokenizerConstants.XMLDelEncoding;
- }
- case 67 :
- break;
- case 23 :
- {
- popState();
- valueText = string.toString();
- return EncodingParserConstants.StringValue;
- }
- case 68 :
- break;
- case 20 :
- case 22 :
- case 24 :
- case 26 :
- {
- string.append(yytext());
- }
- case 69 :
- break;
- case 19 :
- {
- yybegin(SQ_STRING);
- string.setLength(0);
- }
- case 70 :
- break;
- case 18 :
- {
- yybegin(DQ_STRING);
- string.setLength(0);
- }
- case 71 :
- break;
- case 27 :
- {
- yypushback(1);
- popState();
- valueText = string.toString();
- return EncodingParserConstants.UnDelimitedStringValue;
- }
- case 72 :
- break;
- default :
- if (yy_input == YYEOF && yy_startRead == yy_currentPos) {
- yy_atEOF = true;
- yy_do_eof();
- {
- hasMore = false;
- return EncodingParserConstants.EOF;
- }
- }
- else {
- yy_ScanError(YY_NO_MATCH);
- }
- }
- }
- }
-
- /**
- * Runs the scanner on input files.
- *
- * This main method is the debugging routine for the scanner.
- * It prints each returned token to System.out until the end of
- * file is reached, or an error occured.
- *
- * @param argv the command line, contains the filenames to run
- * the scanner on.
- */
- public static void main(String argv[]) {
- for (int i = 0; i < argv.length; i++) {
- XMLHeadTokenizer scanner = null;
- try {
- scanner = new XMLHeadTokenizer(new java.io.FileReader(argv[i]));
- }
- catch (java.io.FileNotFoundException e) {
- System.out.println("File not found : \"" + argv[i] + "\"");
- System.exit(1);
- }
-// catch (java.io.IOException e) {
-// System.out.println("Error opening file \"" + argv[i] + "\"");
-// System.exit(1);
-// }
- catch (ArrayIndexOutOfBoundsException e) {
- System.out.println("Usage : java XMLHeadTokenizer <inputfile>");
- System.exit(1);
- }
-
- try {
- do {
- System.out.println(scanner.primGetNextToken());
- }
- while (!scanner.yy_atEOF);
-
- }
- catch (java.io.IOException e) {
- System.out.println("An I/O error occured while scanning :");
- System.out.println(e);
- System.exit(1);
- }
- catch (Exception e) {
- e.printStackTrace();
- System.exit(1);
- }
- }
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java
deleted file mode 100644
index 9ed8e5e..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/contenttype/XMLHeadTokenizerConstants.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.contenttype;
-
-
-public interface XMLHeadTokenizerConstants extends EncodingParserConstants {
-
- final String XMLDeclEnd = "XMLDeclEnd"; //$NON-NLS-1$
- final String XMLDeclStart = "XMLDeclStart"; //$NON-NLS-1$
- final String XMLDelEncoding = "XMLDelEncoding"; //$NON-NLS-1$
- // final String XMLDeclVersion = "XMLDeclVersion";
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
deleted file mode 100644
index 13f6778..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/AttrImpl.java
+++ /dev/null
@@ -1,696 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.document.XMLAttr;
-import org.eclipse.wst.xml.core.document.XMLCharEntity;
-import org.eclipse.wst.xml.core.document.XMLNamespace;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * AttrImpl class
- */
-public class AttrImpl extends NodeImpl implements XMLAttr {
-
- private String name = null;
- private String valueSource = null;
- private ElementImpl ownerElement = null;
- private ITextRegion nameRegion = null;
- private ITextRegion valueRegion = null;
- private ITextRegion equalRegion = null;
- private String namespaceURI = null;
-
- /**
- * AttrImpl constructor
- */
- protected AttrImpl() {
- super();
- }
-
- /**
- * AttrImpl constructor
- * @param that AttrImpl
- */
- protected AttrImpl(AttrImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- this.valueSource = that.getValueSource();
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- */
- public Node cloneNode(boolean deep) {
- AttrImpl cloned = new AttrImpl(this);
- return cloned;
- }
-
- /**
- */
- protected CMAttributeDeclaration getDeclaration() {
- ElementImpl element = (ElementImpl) getOwnerElement();
- if (element == null)
- return null;
- CMElementDeclaration elementDecl = element.getDeclaration();
- if (elementDecl == null)
- return null;
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- if (attributes == null)
- return null;
- return (CMAttributeDeclaration) attributes.getNamedItem(getName());
- }
-
- /**
- * getEndOffset method
- * @return int
- */
- public int getEndOffset() {
- if (this.ownerElement == null)
- return 0;
- int offset = this.ownerElement.getStartOffset();
- if (this.valueRegion != null) {
- return (offset + this.valueRegion.getEnd());
- }
- if (this.equalRegion != null) {
- return (offset + this.equalRegion.getEnd());
- }
- if (this.nameRegion != null) {
- return (offset + this.nameRegion.getEnd());
- }
- return 0;
- }
-
- /**
- * getEqualRegion method
- */
- public ITextRegion getEqualRegion() {
- return this.equalRegion;
- }
-
- /**
- */
- public String getLocalName() {
- if (this.name == null)
- return null;
- int index = this.name.indexOf(':');
- if (index < 0)
- return this.name;
- return this.name.substring(index + 1);
- }
-
- /**
- * getName method
- * @return java.lang.String
- */
- public String getName() {
- if (this.name == null)
- return new String();
- return this.name;
- }
-
- /**
- * getNameRegion method
- */
- public ITextRegion getNameRegion() {
- return this.nameRegion;
- }
-
- public String getNameRegionText() {
- if (this.ownerElement == null)
- return null;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- return flatNode.getText(this.nameRegion);
- }
-
- public int getNameRegionStartOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getStartOffset(this.nameRegion);
- }
-
- public int getNameRegionEndOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getEndOffset(this.nameRegion);
- }
-
- public int getNameRegionTextEndOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getTextEndOffset(this.nameRegion);
- }
-
- /**
- */
- public String getNamespaceURI() {
- String nsAttrName = null;
- String prefix = getPrefix();
- if (prefix != null && prefix.length() > 0) {
- if (prefix.equals(XMLNamespace.XMLNS)) {
- // fixed URI
- return XMLNamespace.XMLNS_URI;
- }
- nsAttrName = XMLNamespace.XMLNS_PREFIX + prefix;
- }
- else {
- String name = getName();
- if (name != null && name.equals(XMLNamespace.XMLNS)) {
- // fixed URI
- return XMLNamespace.XMLNS_URI;
- }
- // does not inherit namespace from owner element
- // if (this.ownerElement != null) return this.ownerElement.getNamespaceURI();
- return this.namespaceURI;
- }
-
- for (Node node = this.ownerElement; node != null; node = node.getParentNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- break;
- Element element = (Element) node;
- Attr attr = element.getAttributeNode(nsAttrName);
- if (attr != null)
- return attr.getValue();
- }
-
- return this.namespaceURI;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- return getName();
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return ATTRIBUTE_NODE;
- }
-
- /**
- * getNodeValue method
- * @return java.lang.String
- */
- public String getNodeValue() {
- return getValue();
- }
-
- /**
- * getOwnerElement method
- * @return org.w3c.dom.Element
- */
- public Element getOwnerElement() {
- return this.ownerElement;
- }
-
- /**
- */
- public String getPrefix() {
- if (this.name == null)
- return null;
- int index = this.name.indexOf(':');
- if (index <= 0)
- return null;
- // exclude JSP tag in name
- if (this.name.charAt(0) == '<')
- return null;
- return this.name.substring(0, index);
- }
-
- /**
- * getSpecified method
- * @return boolean
- */
- public boolean getSpecified() {
- return true;
- }
-
- /**
- * getStartOffset method
- * @return int
- */
- public int getStartOffset() {
- if (this.ownerElement == null)
- return 0;
- int offset = this.ownerElement.getStartOffset();
- if (this.nameRegion != null) {
- return (offset + this.nameRegion.getStart());
- }
- if (this.equalRegion != null) {
- return (offset + this.equalRegion.getStart());
- }
- if (this.valueRegion != null) {
- return (offset + this.valueRegion.getStart());
- }
- return 0;
- }
-
- /**
- * getValue method
- * @return java.lang.String
- */
- public String getValue() {
- return getValue(getValueSource());
- }
-
- /**
- * Returns value for the source
- */
- private String getValue(String source) {
- if (source == null)
- return new String();
- if (source.length() == 0)
- return source;
- StringBuffer buffer = null;
- int offset = 0;
- int length = source.length();
- int ref = source.indexOf('&');
- while (ref >= 0) {
- int end = source.indexOf(';', ref + 1);
- if (end > ref + 1) {
- String name = source.substring(ref + 1, end);
- String value = getCharValue(name);
- if (value != null) {
- if (buffer == null)
- buffer = new StringBuffer(length);
- if (ref > offset)
- buffer.append(source.substring(offset, ref));
- buffer.append(value);
- offset = end + 1;
- ref = end;
- }
- }
- ref = source.indexOf('&', ref + 1);
- }
- if (buffer == null)
- return source;
- if (length > offset)
- buffer.append(source.substring(offset));
- return buffer.toString();
- }
-
- /**
- * getValueRegion method
- */
- public ITextRegion getValueRegion() {
- return this.valueRegion;
- }
-
- public String getValueRegionText() {
- if (this.ownerElement == null)
- return null;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- if (this.valueRegion == null)
- return null;
- return flatNode.getText(this.valueRegion);
- }
-
- public int getValueRegionStartOffset() {
- if (this.ownerElement == null)
- return 0;
- // assuming the firstStructuredDocumentRegion is the one that contains attributes
- IStructuredDocumentRegion flatNode = this.ownerElement.getFirstStructuredDocumentRegion();
- if (flatNode == null)
- return 0;
- return flatNode.getStartOffset(this.valueRegion);
- }
-
- /**
- */
- public String getValueSource() {
- if (this.valueSource != null)
- return this.valueSource;
- // DW: 4/16/2003 due to change in structuredDocument ... we need a flatnode to
- // get at region values. For now I'll assume this is always the first
- // flatnode .. may need to make smarter later (e.g. to search for
- // the flatnode that this.valueRegion belongs to.
- // DW: 4/30/2003 For some reason, this method is getting called a lot
- // Not sure if its a threading problem, or a fundamental error elsewhere.
- // It needs more investigation, but in the use cases I've seen, doesn't
- // seem to hurt to simply return null in those cases. I saw this null case,
- // when tryint go format an XML file.
- if (this.ownerElement == null)
- return null;
- IStructuredDocumentRegion ownerRegion = this.ownerElement.getFirstStructuredDocumentRegion();
- if (ownerRegion == null)
- return null;
- if (this.valueRegion != null)
- return StructuredDocumentRegionUtil.getAttrValue(ownerRegion, this.valueRegion);
- return new String();
- }
-
- private String getValueSource(ElementImpl ownerElement) {
- if (this.valueSource != null)
- return this.valueSource;
- // DW: 4/16/2003 due to change in structuredDocument ... we need a flatnode to
- // get at region values. For now I'll assume this is always the first
- // flatnode .. may need to make smarter later (e.g. to search for
- // the flatnode that this.valueRegion belongs to.
- if (this.valueRegion != null)
- return StructuredDocumentRegionUtil.getAttrValue(ownerElement.getStructuredDocumentRegion(), this.valueRegion);
- return new String();
- }
-
- /**
- */
- private String getValueSource(String value) {
- if (value == null)
- return null;
- if (value.length() == 0)
- return value;
- StringBuffer buffer = null;
- int offset = 0;
- int length = value.length();
- int amp = value.indexOf('&');
- while (amp >= 0) {
- if (buffer == null)
- buffer = new StringBuffer(length + 4);
- if (amp > offset)
- buffer.append(value.substring(offset, amp));
- buffer.append(XMLCharEntity.AMP_REF);
- offset = amp + 1;
- amp = value.indexOf('&', offset);
- }
- if (buffer == null)
- return value;
- if (length > offset)
- buffer.append(value.substring(offset));
- return buffer.toString();
- }
-
- /**
- * Check if Attr has JSP in value
- */
- public boolean hasJSPValue() {
- if (this.valueRegion == null)
- return false;
- if (!(this.valueRegion instanceof ITextRegionContainer))
- return false;
- ITextRegionList regions = ((ITextRegionContainer) this.valueRegion).getRegions();
- if (regions == null)
- return false;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- if (region == null)
- continue;
- String regionType = region.getType();
- if (regionType == XMLRegionContext.XML_TAG_OPEN || regionType == XMLJSPRegionContexts.JSP_SCRIPTLET_OPEN || regionType == XMLJSPRegionContexts.JSP_EXPRESSION_OPEN || regionType == XMLJSPRegionContexts.JSP_DECLARATION_OPEN || regionType == XMLJSPRegionContexts.JSP_DIRECTIVE_OPEN)
- return true;
- }
- return false;
- }
-
- /**
- * Check if Attr has only name but not equal sign nor value
- */
- public boolean hasNameOnly() {
- return (this.nameRegion != null && this.equalRegion == null && this.valueRegion == null);
- }
-
- /**
- */
- protected final boolean hasPrefix() {
- if (this.name == null)
- return false;
- if (this.name.indexOf(':') <= 0)
- return false;
- // exclude JSP tag in name
- if (this.name.charAt(0) == '<')
- return false;
- return true;
- }
-
- /**
- */
- protected final boolean ignoreCase() {
- if (this.ownerElement != null) {
- if (this.ownerElement.ignoreCase()) {
- return !hasPrefix();
- }
- }
- else {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && document.ignoreCase()) {
- // even in case insensitive document, if having prefix, it's case sensitive
- return !hasPrefix();
- }
- }
- return false;
- }
-
- /**
- */
- public boolean isGlobalAttr() {
- if (hasPrefix())
- return false;
- if (this.ownerElement == null)
- return false;
- return this.ownerElement.isGlobalTag();
- }
-
- /**
- */
- public final boolean isXMLAttr() {
- if (this.ownerElement != null) {
- if (!this.ownerElement.isXMLTag()) {
- return hasPrefix();
- }
- }
- else {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && !document.isXMLType()) {
- // even in non-XML document, if having prefix, it's XML tag
- return hasPrefix();
- }
- }
- return true;
- }
-
- /**
- * matchName method
- * @return boolean
- * @param name java.lang.String
- */
- protected boolean matchName(String name) {
- if (name == null)
- return (this.name == null);
- if (this.name == null)
- return false;
- if (!ignoreCase())
- return this.name.equals(name);
- return this.name.equalsIgnoreCase(name);
- }
-
- /**
- * notifyValueChanged method
- */
- protected void notifyNameChanged() {
- if (this.ownerElement == null)
- return;
- DocumentImpl document = (DocumentImpl) this.ownerElement.getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.nameChanged(this);
- }
-
- /**
- * notifyValueChanged method
- */
- protected void notifyValueChanged() {
- if (this.ownerElement == null)
- return;
- DocumentImpl document = (DocumentImpl) this.ownerElement.getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.valueChanged(this);
- }
-
- /**
- * removeRegions method
- */
- void removeRegions() {
- this.nameRegion = null;
- this.valueRegion = null;
- this.equalRegion = null;
- }
-
- /**
- */
- void resetRegions() {
- this.valueSource = getValueSource();
- removeRegions();
- }
-
- /**
- */
- void resetRegions(ElementImpl ownerElement) {
- this.valueSource = getValueSource(ownerElement);
- removeRegions();
- }
-
- /**
- * setEqualRegion method
- */
- void setEqualRegion(ITextRegion equalRegion) {
- this.equalRegion = equalRegion;
- }
-
- /**
- * setName method
- * @param name java.lang.String
- */
- protected void setName(String name) {
- String value = null;
- int startOffset = 0;
- if (this.ownerElement != null) {
- value = getValue();
- startOffset = this.ownerElement.getStartOffset();
- this.ownerElement.notify(CHANGE, this, value, null, startOffset);
- }
- this.name = name;
- if (this.ownerElement != null) {
- this.ownerElement.notify(CHANGE, this, null, value, startOffset);
- }
- }
-
- /**
- * setNameRegion method
- */
- void setNameRegion(ITextRegion nameRegion) {
- this.nameRegion = nameRegion;
- }
-
- /**
- */
- protected void setNamespaceURI(String namespaceURI) {
- this.namespaceURI = namespaceURI;
- }
-
- /**
- * setNodeValue method
- * @param nodeValue java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- setValue(nodeValue);
- }
-
- /**
- * setOwnerElement method
- * @param ownerElement org.w3c.dom.Element
- */
- protected void setOwnerElement(Element ownerElement) {
- this.ownerElement = (ElementImpl) ownerElement;
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- if (this.ownerElement != null && !this.ownerElement.isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
- int prefixLength = (prefix != null ? prefix.length() : 0);
- String localName = getLocalName();
- if (prefixLength == 0) {
- setName(localName);
- return;
- }
- if (localName == null)
- localName = new String();
- int localLength = localName.length();
- StringBuffer buffer = new StringBuffer(prefixLength + 1 + localLength);
- buffer.append(prefix);
- buffer.append(':');
- buffer.append(localName);
- setName(buffer.toString());
-
- notifyNameChanged();
- }
-
- /**
- * setValue method
- * @param value java.lang.String
- */
- public void setValue(String value) {
- setValueSource(getValueSource(value));
- }
-
- /**
- * setValueRegion method
- */
- void setValueRegion(ITextRegion valueRegion) {
- this.valueRegion = valueRegion;
- if (valueRegion != null)
- this.valueSource = null;
- }
-
- /**
- */
- public void setValueSource(String source) {
- if (this.ownerElement != null && !this.ownerElement.isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
- this.valueSource = source;
-
- notifyValueChanged();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java
deleted file mode 100644
index 3a3372d..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CDATASectionImpl.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-
-
-/**
- * CDATASectionImpl class
- */
-public class CDATASectionImpl extends TextImpl implements CDATASection {
-
- /**
- * CDATASectionImpl constructor
- */
- protected CDATASectionImpl() {
- super();
- }
-
- /**
- * CDATASectionImpl constructor
- * @param that CDATASectionImpl
- */
- protected CDATASectionImpl(CDATASectionImpl that) {
- super(that);
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- CDATASectionImpl cloned = new CDATASectionImpl(this);
- return cloned;
- }
-
- /**
- * getData method
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- // instead of super(TextImpl).getData(), call getCharacterData()
- String data = getCharacterData();
- if (data == null) {
- data = getData(getStructuredDocumentRegion());
- if (data == null)
- data = new String();
- }
- return data;
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return null;
-
- ITextRegion contentRegion = null;
- StringBuffer buffer = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == XMLRegionContext.XML_CDATA_OPEN || regionType == XMLRegionContext.XML_CDATA_CLOSE) {
- continue;
- }
- if (contentRegion == null) { // first content
- contentRegion = region;
- }
- else { // multiple contents
- if (buffer == null) {
- buffer = new StringBuffer(flatNode.getText(contentRegion));
- }
- buffer.append(flatNode.getText(region));
- }
- }
-
- if (buffer != null)
- return buffer.toString();
- if (contentRegion != null)
- return flatNode.getText(contentRegion);
- return null;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#cdata-section";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return CDATA_SECTION_NODE;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == XMLRegionContext.XML_CDATA_CLOSE);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java
deleted file mode 100644
index 8174127..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CMNodeUtil.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-/**
- */
-public class CMNodeUtil {
-
- /**
- */
- public static CMAttributeDeclaration getAttributeDeclaration(Attr attr) {
- if (attr == null)
- return null;
- return ((AttrImpl) attr).getDeclaration();
- }
-
- /**
- */
- public static CMElementDeclaration getElementDeclaration(Element element) {
- if (element == null)
- return null;
- return ((ElementImpl) element).getDeclaration();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java
deleted file mode 100644
index cb0478c..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CharacterDataImpl.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.w3c.dom.CharacterData;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-
-
-/**
- * CharacterDataImpl class
- */
-public abstract class CharacterDataImpl extends NodeImpl implements XMLJSPRegionContexts, CharacterData {
-
- private String data = null;
-
- /**
- * CharacterDataImpl constructor
- */
- protected CharacterDataImpl() {
- super();
- }
-
- /**
- * CharacterDataImpl constructor
- * @param that CharacterDataImpl
- */
- protected CharacterDataImpl(CharacterDataImpl that) {
- super(that);
-
- if (that != null) {
- this.data = that.getData();
- }
- }
-
- /**
- * appendData method
- * @param arg java.lang.String
- */
- public void appendData(String arg) throws DOMException {
- if (arg == null)
- return;
-
- String data = getData();
- if (data == null)
- data = arg;
- else
- data += arg;
- setData(data);
- }
-
- /**
- * deleteData method
- * @param offset int
- * @param count int
- */
- public void deleteData(int offset, int count) throws DOMException {
- if (count == 0)
- return;
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (count < 0 || offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- int length = data.length();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (offset == 0) {
- if (count > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (count == length)
- data = new String();
- else
- data = data.substring(count);
- }
- else {
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (end == length)
- data = data.substring(0, offset);
- else
- data = data.substring(0, offset) + data.substring(end);
- }
- setData(data);
- }
-
- /**
- */
- protected final String getCharacterData() {
- return this.data;
- }
-
- /**
- * getData method
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- return getCharacterData();
- }
-
- /**
- * getLength method
- * @return int
- */
- public int getLength() {
- String data = getData();
- if (data == null)
- return 0;
- return data.length();
- }
-
- /**
- * getNodeValue method
- * @return java.lang.String
- */
- public String getNodeValue() {
- return getData();
- }
-
- /**
- * insertData method
- * @param offset int
- * @param arg java.lang.String
- */
- public void insertData(int offset, String arg) throws DOMException {
- if (arg == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (offset < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
-
- String data = getData();
- if (data == null) {
- if (offset > 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- data = arg;
- }
- else if (offset == 0) {
- data = arg + data;
- }
- else {
- int length = data.length();
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (offset == length)
- data += arg;
- else
- data = data.substring(0, offset) + arg + data.substring(offset);
- }
- setData(data);
- }
-
- /**
- * isJSPContent method
- * @return boolean
- */
- public boolean isJSPContent() {
- Node parent = getParentNode();
- if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE)
- return false;
- ElementImpl element = (ElementImpl) parent;
- return element.isJSPContainer();
- }
-
- /**
- * replaceData method
- * @param offset int
- * @param count int
- * @param arg java.lang.String
- */
- public void replaceData(int offset, int count, String arg) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (arg == null) {
- deleteData(offset, count);
- return;
- }
- if (count == 0) {
- insertData(offset, arg);
- return;
- }
- if (offset < 0 || count < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- else if (offset == 0) {
- int length = data.length();
- if (count > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (count == length)
- data = arg;
- else
- data = arg + data.substring(count);
- }
- else {
- int length = data.length();
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- if (end == length)
- data = data.substring(0, offset) + arg;
- else
- data = data.substring(0, offset) + arg + data.substring(end);
- }
- setData(data);
- }
-
- /**
- */
- void resetStructuredDocumentRegions() {
- this.data = getData();
- setStructuredDocumentRegion(null);
- }
-
- /**
- * setData method
- * @param data java.lang.String
- */
- public void setData(String data) throws DOMException {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.data = data;
-
- notifyValueChanged();
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- super.setStructuredDocumentRegion(flatNode);
- if (flatNode != null)
- this.data = null;
- }
-
- /**
- * setNodeValue method
- * @param nodeValue java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- setData(nodeValue);
- }
-
- /**
- * substringData method
- * @return java.lang.String
- * @param offset int
- * @param count int
- */
- public String substringData(int offset, int count) throws DOMException {
- if (count == 0)
- return new String();
- if (offset < 0 || count < 0) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
-
- String data = getData();
- if (data == null) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- int length = data.length();
- if (offset == 0 && count == length)
- return data;
- if (offset > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- int end = offset + count;
- if (end > length) {
- throw new DOMException(DOMException.INDEX_SIZE_ERR, new String());
- }
- return data.substring(offset, end);
- }
-
- /**
- * toString method
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getNodeName());
- buffer.append('(');
- buffer.append(getData());
- buffer.append(')');
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null) {
- buffer.append('@');
- buffer.append(flatNode.toString());
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java
deleted file mode 100644
index 2933b83..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/CommentImpl.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-
-
-/**
- * CommentImpl class
- */
-public class CommentImpl extends CharacterDataImpl implements Comment {
-
- private boolean isJSPTag = false;
-
- /**
- * CommentImpl constructor
- */
- protected CommentImpl() {
- super();
- }
-
- /**
- * CommentImpl constructor
- * @param that CommentImpl
- */
- protected CommentImpl(CommentImpl that) {
- super(that);
-
- if (that != null) {
- this.isJSPTag = that.isJSPTag;
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- CommentImpl cloned = new CommentImpl(this);
- return cloned;
- }
-
- /**
- * getData method
- * @return java.lang.String
- */
- public String getData() throws DOMException {
- String data = getCharacterData();
- if (data == null) {
- data = getData(getStructuredDocumentRegion());
- if (data == null)
- data = new String();
- }
- return data;
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return null;
-
- ITextRegion contentRegion = null;
- StringBuffer buffer = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == XMLRegionContext.XML_COMMENT_OPEN || regionType == JSP_COMMENT_OPEN || regionType == XMLRegionContext.XML_COMMENT_CLOSE || regionType == JSP_COMMENT_CLOSE) {
- continue;
- }
- if (contentRegion == null) { // first content
- contentRegion = region;
- }
- else { // multiple contents
- if (buffer == null) {
- buffer = new StringBuffer(flatNode.getText(contentRegion));
- }
- buffer.append(flatNode.getText(region));
- }
- }
-
- if (buffer != null)
- return buffer.toString();
- if (contentRegion != null)
- return flatNode.getText(contentRegion);
- return null;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#comment";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return COMMENT_NODE;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == XMLRegionContext.XML_COMMENT_CLOSE || regionType == XMLJSPRegionContexts.JSP_COMMENT_CLOSE);
- }
-
- /**
- * isJSP method
- * @return boolean
- */
- public boolean isJSPTag() {
- return this.isJSPTag;
- }
-
- /**
- * setJSPTag method
- * @param isJSPTag boolean
- */
- public void setJSPTag(boolean isJSPTag) {
- if (isJSPTag == this.isJSPTag)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (isJSPTag) {
- if (document == null || !document.isJSPType())
- return;
- }
-
- this.isJSPTag = isJSPTag;
-
- if (getContainerDocument() != null) {
- // already in the tree, update IStructuredDocument
- setData(getData()); // calls notifyValueChanged();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java
deleted file mode 100644
index 8227055..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentFragmentImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-
-
-/**
- * DocumentFragmentImpl class
- */
-public class DocumentFragmentImpl extends NodeContainer implements DocumentFragment {
-
- /**
- * DocumentFragmentImpl constructor
- */
- protected DocumentFragmentImpl() {
- super();
- }
-
- /**
- * DocumentFragmentImpl constructor
- * @param that DocumentFragmentImpl
- */
- protected DocumentFragmentImpl(DocumentFragmentImpl that) {
- super(that);
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentFragmentImpl cloned = new DocumentFragmentImpl(this);
- if (deep)
- cloneChildNodes(cloned, deep);
- return cloned;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#document-fragment";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_FRAGMENT_NODE;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java
deleted file mode 100644
index d167898..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentImpl.java
+++ /dev/null
@@ -1,1076 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-// for org.apache.xerces 3.2.1
-// import org.apache.xerces.utils.XMLCharacterProperties;
-// DMW modified for XML4J 4.0.1
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.wst.contentmodel.CMDocument;
-import org.eclipse.wst.contentmodel.CMEntityDeclaration;
-import org.eclipse.wst.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.encoding.content.IContentTypeIdentifier;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.xml.core.NameValidator;
-import org.eclipse.wst.xml.core.commentelement.impl.CommentElementRegistry;
-import org.eclipse.wst.xml.core.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.document.JSPTag;
-import org.eclipse.wst.xml.core.document.XMLCharEntity;
-import org.eclipse.wst.xml.core.document.XMLDocument;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil;
-import org.w3c.dom.Attr;
-import org.w3c.dom.CDATASection;
-import org.w3c.dom.Comment;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Entity;
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Notation;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-import org.w3c.dom.ranges.Range;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-import org.w3c.dom.traversal.TreeWalker;
-
-
-/**
- * DocumentImpl class
- */
-public class DocumentImpl extends NodeContainer implements XMLDocument {
-
- /**
- * Internal-use only class. This class was added to better able to handle
- * repetetive request for getElementsByTagName. The cache is cleared when
- * ever the document changes at all, so still not real efficient,
- */
- class TagNameCache {
-
- private boolean active = true;
-
- private Map cache;
-
- public TagNameCache() {
- super();
- cache = new HashMap();
- }
-
- public void addItem(String tagname, NodeListImpl nodelist) {
- if (tagname == null || nodelist == null)
- return;
- cache.put(tagname, nodelist);
- }
-
- public NodeListImpl getItem(String tagName) {
- NodeListImpl result = null;
- if (active) {
- result = (NodeListImpl) cache.get(tagName);
- // if (result != null) {
- // System.out.println("getElementsByTagname from cache: " +
- // tagName);
- // }
- }
- return result;
- }
-
- public void clear() {
- cache.clear();
- }
-
- /**
- * @param b
- */
- public void activate(boolean b) {
- active = b;
- if (!b)
- clear();
- }
-
- }
-
- private XMLModelImpl model = null;
- private DocumentTypeAdapter documentTypeAdapter = null;
- private TagNameCache tagNameCache;
- // this is a constant just to give compile-time control over
- // whether or not to use the cache. If, in future, its found that
- // there are no (or few) "duplicate requests" ... then this cache
- // is not needed.
- private static final boolean usetagnamecache = true;
-
- /**
- * DocumentImpl constructor
- */
- protected DocumentImpl() {
- super();
- if (usetagnamecache) {
- tagNameCache = new TagNameCache();
- }
- }
-
- /**
- * DocumentImpl constructor
- *
- * @param that
- * DocumentImpl
- */
- protected DocumentImpl(DocumentImpl that) {
- super(that);
- if (usetagnamecache) {
- tagNameCache = new TagNameCache();
- }
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * Changes the <code>ownerDocument</code> of a node, its children, as
- * well as the attached attribute nodes if there are any. If the node has
- * a parent it is first removed from its parent child list. This
- * effectively allows moving a subtree from one document to another. The
- * following list describes the specifics for each type of node.
- * <dl>
- * <dt>ATTRIBUTE_NODE</dt>
- * <dd>The <code>ownerElement</code> attribute is set to
- * <code>null</code> and the <code>specified</code> flag is set to
- * <code>true</code> on the adopted <code>Attr</code>. The
- * descendants of the source <code>Attr</code> are recursively adopted.
- * </dd>
- * <dt>DOCUMENT_FRAGMENT_NODE</dt>
- * <dd>The descendants of the source node are recursively adopted.</dd>
- * <dt>DOCUMENT_NODE</dt>
- * <dd><code>Document</code> nodes cannot be adopted.</dd>
- * <dt>DOCUMENT_TYPE_NODE</dt>
- * <dd><code>DocumentType</code> nodes cannot be adopted.</dd>
- * <dt>ELEMENT_NODE</dt>
- * <dd>Specified attribute nodes of the source element are adopted, and
- * the generated <code>Attr</code> nodes. Default attributes are
- * discarded, though if the document being adopted into defines default
- * attributes for this element name, those are assigned. The descendants
- * of the source element are recursively adopted.</dd>
- * <dt>ENTITY_NODE</dt>
- * <dd><code>Entity</code> nodes cannot be adopted.</dd>
- * <dt>ENTITY_REFERENCE_NODE</dt>
- * <dd>Only the <code>EntityReference</code> node itself is adopted,
- * the descendants are discarded, since the source and destination
- * documents might have defined the entity differently. If the document
- * being imported into provides a definition for this entity name, its
- * value is assigned.</dd>
- * <dt>NOTATION_NODE</dt>
- * <dd><code>Notation</code> nodes cannot be adopted.</dd>
- * <dt>PROCESSING_INSTRUCTION_NODE, TEXT_NODE, CDATA_SECTION_NODE,
- * COMMENT_NODE</dt>
- * <dd>These nodes can all be adopted. No specifics.</dd>
- * Should this method simply return null when it fails? How "exceptional"
- * is failure for this method?Stick with raising exceptions only in
- * exceptional circumstances, return null on failure (F2F 19 Jun 2000).Can
- * an entity node really be adopted?No, neither can Notation nodes (Telcon
- * 13 Dec 2000).Does this affect keys and hashCode's of the adopted
- * subtree nodes?If so, what about readonly-ness of key and hashCode?if
- * not, would appendChild affect keys/hashCodes or would it generate
- * exceptions if key's are duplicate? Update: Hashcodes have been dropped.
- * Given that the key is only unique within a document an adopted node
- * needs to be given a new key, but what does it mean for the application?
- *
- * @param source
- * The node to move into this document.
- * @return The adopted node, or <code>null</code> if this operation
- * fails, such as when the source node comes from a different
- * implementation.
- * @exception DOMException
- * NOT_SUPPORTED_ERR: Raised if the source node is of type
- * <code>DOCUMENT</code>,<code>DOCUMENT_TYPE</code>.
- * <br>
- * NO_MODIFICATION_ALLOWED_ERR: Raised when the source node
- * is readonly.
- * @since DOM Level 3
- */
- public org.w3c.dom.Node adoptNode(org.w3c.dom.Node source) throws org.w3c.dom.DOMException {
- return null;
- }
-
- /**
- * cloneNode method
- *
- * @return org.w3c.dom.Node
- * @param deep
- * boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentImpl cloned = new DocumentImpl(this);
- if (deep)
- cloned.importChildNodes(this, true);
- return cloned;
- }
-
- /**
- * createAttribute method
- *
- * @return org.w3c.dom.Attr
- * @param name
- * java.lang.String
- */
- public Attr createAttribute(String name) throws DOMException {
- AttrImpl attr = new AttrImpl();
- attr.setOwnerDocument(this);
- attr.setName(name);
- return attr;
- }
-
- /**
- */
- public Attr createAttributeNS(String uri, String name) throws DOMException {
- AttrImpl attr = new AttrImpl();
- attr.setOwnerDocument(this);
- attr.setName(name);
- attr.setNamespaceURI(uri);
- return attr;
- }
-
- /**
- * createCDATASection method
- *
- * @return org.w3c.dom.CDATASection
- * @param data
- * java.lang.String
- */
- public CDATASection createCDATASection(String data) throws DOMException {
- // allow CDATA section
- // if (!isXMLType()) {
- // throw new DOMException(DOMException.NOT_SUPPORTED_ERR, new
- // String());
- // }
- CDATASectionImpl cdata = new CDATASectionImpl();
- cdata.setOwnerDocument(this);
- if (data != null)
- cdata.setData(data);
- return cdata;
- }
-
- /**
- * createComment method
- *
- * @return org.w3c.dom.Comment
- * @param data
- * java.lang.String
- */
- public Comment createComment(String data) {
- CommentImpl comment = new CommentImpl();
- comment.setOwnerDocument(this);
- if (data != null)
- comment.setData(data);
- return comment;
- }
-
- /**
- * createDoctype method
- *
- * @return org.w3c.dom.DocumentType
- * @param name
- * java.lang.String
- */
- public DocumentType createDoctype(String name) {
- DocumentTypeImpl docType = new DocumentTypeImpl();
- docType.setOwnerDocument(this);
- docType.setName(name);
- return docType;
- }
-
- /**
- * createDocumentFragment method
- *
- * @return org.w3c.dom.DocumentFragment
- */
- public DocumentFragment createDocumentFragment() {
- DocumentFragmentImpl fragment = new DocumentFragmentImpl();
- fragment.setOwnerDocument(this);
- return fragment;
- }
-
- /**
- * createElement method
- *
- * @return org.w3c.dom.Element
- * @param tagName
- * java.lang.String
- */
- public Element createElement(String tagName) throws DOMException {
- checkTagNameValidity(tagName);
-
- ElementImpl element = new ElementImpl();
- element.setOwnerDocument(this);
- element.setTagName(tagName);
- return element;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public Element createCommentElement(String tagName, boolean isJSPTag) throws DOMException {
- if (!isJSPType() && isJSPTag) {
- throw new DOMException(DOMException.INVALID_MODIFICATION_ERR, new String());
- }
- ElementImpl element = (ElementImpl) createElement(tagName);
- element.setJSPTag(isJSPTag);
- CommentElementRegistry registry = CommentElementRegistry.getInstance();
- if (registry.setupCommentElement(element)) {
- return element;
- }
- else {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, new String());
- }
- }
-
- /**
- */
- public Element createElementNS(String uri, String tagName) throws DOMException {
- if (!isValidName(tagName)) {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, new String());
- }
-
- ElementImpl element = new ElementImpl();
- element.setOwnerDocument(this);
- element.setTagName(tagName);
- element.setNamespaceURI(uri);
- return element;
- }
-
- /**
- * createEntity method
- *
- * @return org.w3c.dom.Entity
- * @param name
- * java.lang.String
- */
- public Entity createEntity(String name) {
- EntityImpl entity = new EntityImpl();
- entity.setOwnerDocument(this);
- entity.setName(name);
- return entity;
- }
-
- /**
- * createEntityReference method
- *
- * @return org.w3c.dom.EntityReference
- * @param name
- * java.lang.String
- */
- public EntityReference createEntityReference(String name) throws DOMException {
- if (!isXMLType()) {
- throw new DOMException(DOMException.NOT_SUPPORTED_ERR, new String());
- }
-
- EntityReferenceImpl ref = new EntityReferenceImpl();
- ref.setOwnerDocument(this);
- ref.setName(name);
- return ref;
- }
-
- /**
- */
- public NodeIterator createNodeIterator(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) {
- if (root == null)
- root = this;
- return new NodeIteratorImpl(root, whatToShow, filter);
- }
-
- /**
- * createNotation method
- *
- * @return org.w3c.dom.Notation
- * @param name
- * java.lang.String
- */
- public Notation createNotation(String name) {
- NotationImpl notation = new NotationImpl();
- notation.setOwnerDocument(this);
- notation.setName(name);
- return notation;
- }
-
- /**
- * createProcessingInstruction method
- *
- * @return org.w3c.dom.ProcessingInstruction
- * @param target
- * java.lang.String
- * @param data
- * java.lang.String
- */
- public ProcessingInstruction createProcessingInstruction(String target, String data) throws DOMException {
- ProcessingInstructionImpl pi = new ProcessingInstructionImpl();
- pi.setOwnerDocument(this);
- pi.setTarget(target);
- if (data != null)
- pi.setData(data);
- return pi;
- }
-
- /**
- */
- public Range createRange() {
- return new RangeImpl();
- }
-
- /**
- * createTextNode method
- *
- * @return org.w3c.dom.Text
- * @param data
- * java.lang.String
- */
- public Text createTextNode(String data) {
- TextImpl text = new TextImpl();
- text.setOwnerDocument(this);
- text.setData(data);
- return text;
- }
-
- /**
- */
- public TreeWalker createTreeWalker(Node root, int whatToShow, NodeFilter filter, boolean entityReferenceExpansion) {
- // not suppoerted
- return null;
- }
-
- /**
- * getCharValue method
- *
- * @return java.lang.String
- * @param name
- * java.lang.String
- */
- protected String getCharValue(String name) {
- if (name == null)
- return null;
- int length = name.length();
- if (length == 0)
- return null;
-
- if (name.charAt(0) == '#') { // character reference
- if (length == 1)
- return null;
- int radix = 10;
- String s = null;
- // now allow hexadecimal also for non XML document
- if (name.charAt(1) == 'x') { // hexadecimal
- radix = 16;
- s = name.substring(2);
- }
- else { // decimal
- s = name.substring(1);
- }
- if (s == null || s.length() == 0)
- return null;
- if (s.charAt(0) == '-')
- return null; // no minus accepted
- char c = 0;
- try {
- c = (char) Integer.parseInt(s, radix);
- }
- catch (NumberFormatException ex) {
- }
- if (c == 0)
- return null;
- return String.valueOf(c);
- }
-
- // implicit character entities for XML
- if (name.equals(XMLCharEntity.LT_NAME))
- return XMLCharEntity.LT_VALUE;
- if (name.equals(XMLCharEntity.GT_NAME))
- return XMLCharEntity.GT_VALUE;
- if (name.equals(XMLCharEntity.AMP_NAME))
- return XMLCharEntity.AMP_VALUE;
- if (name.equals(XMLCharEntity.QUOT_NAME))
- return XMLCharEntity.QUOT_VALUE;
- if (isXMLType()) {
- if (name.equals(XMLCharEntity.APOS_NAME))
- return XMLCharEntity.APOS_VALUE;
- }
-
- CMDocument cm = getCMDocument();
- if (cm != null) {
- CMNamedNodeMap map = cm.getEntities();
- if (map != null) {
- CMEntityDeclaration decl = (CMEntityDeclaration) map.getNamedItem(name);
- if (decl != null) {
- String value = decl.getValue();
- if (value == null)
- return null;
- int valueLength = value.length();
- if (valueLength > 1 && value.charAt(0) == '&' && value.charAt(1) == '#' && value.charAt(valueLength - 1) == ';') {
- // character reference
- return getCharValue(value.substring(1, valueLength - 1));
- }
- return value;
- }
- }
- }
-
- return null;
- }
-
- /**
- */
- protected CMDocument getCMDocument() {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(this);
- if (modelQuery == null)
- return null;
- return modelQuery.getCorrespondingCMDocument(this);
- }
-
- /**
- * getDoctype method
- *
- * @return org.w3c.dom.DocumentType
- */
- public DocumentType getDoctype() {
- return findDoctype(this);
- }
-
- private DocumentType findDoctype(Node node) {
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == DOCUMENT_TYPE_NODE && child instanceof DocumentType) {
- return (DocumentType) child;
- }
- else if (child.getNodeType() == ELEMENT_NODE && ((XMLElement) child).isCommentTag()) {
- // search DOCTYPE inside of generic comment element
- DocumentType docType = findDoctype(child);
- if (docType != null) {
- return docType;
- }
- }
- }
-
- return null;
- }
-
- /**
- * getDocumentElement
- *
- * @return org.w3c.dom.Element From DOM 2 Spec: documentElement of type
- * Element [p.62] , readonly This is a convenience [p.119]
- * attribute that allows direct access to the child node that is
- * the root element of the document. For HTML documents, this is
- * the element with the tagName "HTML". Note: we differ from this
- * definition a little in that we don't necessarily take the first
- * child but also look to match the name. In a well formed
- * document, of course, the result is the same, but not
- * necessarily the same in an ill-formed document.
- */
- public Element getDocumentElement() {
- String name = null;
- DocumentType docType = getDocumentType();
- if (docType != null) {
- name = docType.getName();
- }
-
- Element first[] = new Element[1];
- Element docElement = findDocumentElement(name, this, first);
- if (docElement == null) {
- docElement = first[0];
- }
-
- return docElement;
- }
-
- private Element findDocumentElement(String docName, Node node, Node[] firstFound) {
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) child;
- if (element.isCommentTag()) {
- Element docElement = findDocumentElement(docName, element, firstFound);
- if (docElement != null) {
- return docElement;
- }
- else {
- // added 'else continue' to better handle cases where
- // there is "more than one root" element
- // especially complicated by CommentElements, which are
- // sometimes treated as elements, but should
- // be treated as comments in this context.
- continue;
- }
- }
- // note: the "name" won't match in the event of a jsp tag ... but
- // incase
- // the name is null, we do not want the jsp element returned as
- // documentElement
- if (element.isJSPTag())
- continue;
- if (docName == null)
- return element;
- // use local name for namespace
- String localName = element.getLocalName();
- if (localName == null)
- continue;
- if (isXMLType()) {
- if (localName.equals(docName))
- return element;
- }
- else {
- if (localName.equalsIgnoreCase(docName))
- return element;
- }
- if (firstFound[0] == null)
- firstFound[0] = element;
- }
- return null;
- }
-
- /**
- */
- protected DocumentTypeAdapter getDocumentTypeAdapter() {
- if (this.documentTypeAdapter == null) {
- this.documentTypeAdapter = (DocumentTypeAdapter) getAdapterFor(DocumentTypeAdapter.class);
- if (this.documentTypeAdapter == null) {
- // add default adapter
- this.documentTypeAdapter = new DocumentTypeAdapterImpl(this);
- addAdapter(this.documentTypeAdapter);
- }
- }
- return this.documentTypeAdapter;
- }
-
- /**
- */
- protected DocumentType getDocumentType() {
- DocumentTypeAdapter adapter = getDocumentTypeAdapter();
- if (adapter == null)
- return getDoctype();
- return adapter.getDocumentType();
- }
-
- /**
- */
- public String getDocumentTypeId() {
- DocumentType docType = getDocumentType();
- if (docType == null)
- return null;
- String id = docType.getPublicId();
- if (id == null)
- id = docType.getSystemId();
- return id;
- }
-
- /**
- */
- public Element getElementById(String id) {
- if (id == null)
- return null;
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return null;
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- String value = element.getAttribute("id");//$NON-NLS-1$
- if (value != null && value.equals(id))
- return element;
- }
-
- return null;
- }
-
- /**
- * getElementsByTagName method
- *
- * @return org.w3c.dom.NodeList
- * @param tagName
- * java.lang.String
- */
- public NodeList getElementsByTagName(String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- NodeListImpl elements = null;
-
- if (usetagnamecache) {
- elements = tagNameCache.getItem(tagName);
- }
-
- if (elements == null) {
- elements = internalGetElementsByTagName(tagName);
-
- }
-
- return elements;
- }
-
- private NodeListImpl internalGetElementsByTagName(String tagName) {
- //System.out.println("getElementsByTagname: " + tagName);
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- if (tagName != null) {
- ElementImpl element = (ElementImpl) node;
- if (!element.matchTagName(tagName))
- continue;
- }
- elements.appendNode(node);
- }
- if (usetagnamecache) {
- tagNameCache.addItem(tagName, elements);
- }
- return elements;
- }
-
- /**
- */
- public NodeList getElementsByTagNameNS(String uri, String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- NodeIterator it = createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
- uri = null; // do not care
- }
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- if (tagName != null) {
- String localName = element.getLocalName();
- if (localName == null || !localName.equals(tagName))
- continue;
- }
- if (uri != null) {
- String nsURI = element.getNamespaceURI();
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
- elements.appendNode(element);
- }
-
- return elements;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the encoding
- * of this document. This is <code>null</code> when unspecified.
- *
- * @since DOM Level 3
- */
- public java.lang.String getEncoding() {
- return null;
- }
-
- /**
- */
- public DOMImplementation getImplementation() {
- return model;
- }
-
- /**
- * other nodes will be referring to this one to get the owning model
- */
- public XMLModel getModel() {
- return model;
- }
-
- /**
- * getNodeName method
- *
- * @return java.lang.String
- */
- public String getNodeName() {
- return "#document";//$NON-NLS-1$
- }
-
- /**
- * getNodeType method
- *
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_NODE;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, whether this
- * document is standalone.
- *
- * @since DOM Level 3
- */
- public boolean getStandalone() {
- return false;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying whether errors checking is enforced or not.
- * When set to <code>false</code>, the implementation is free to not
- * test every possible error case normally defined on DOM operations, and
- * not raise any <code>DOMException</code>. In case of error, the
- * behavior is undefined. This attribute is <code>true</code> by
- * defaults.
- *
- * @since DOM Level 3
- */
- public boolean getStrictErrorChecking() {
- return false;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the version
- * number of this document. This is <code>null</code> when unspecified.
- *
- * @since DOM Level 3
- */
- public String getVersion() {
- return null;
- }
-
- /**
- */
- protected boolean ignoreCase() {
- DocumentTypeAdapter adapter = getDocumentTypeAdapter();
- if (adapter == null)
- return false;
- return (adapter.getTagNameCase() != DocumentTypeAdapter.STRICT_CASE);
- }
-
- /**
- */
- protected boolean isValidName(String name) {
- if (name == null || name.length() == 0)
- return false;
- // // DMW: modified for XML4J 4.0.1
- // if (XMLChar.isValidName(name)) return true;
- if (NameValidator.isValid(name))
- return true;
- // special for invalid declaration
- if (name.length() == 1 && name.charAt(0) == '!')
- return true;
- // special for JSP tag in tag name
- if (name.startsWith(JSPTag.TAG_OPEN))
- return true;
- return false;
- }
-
- /**
- */
- public boolean isJSPDocument() {
- Element element = getDocumentElement();
- if (element == null)
- return false;
- String tagName = element.getTagName();
- if (tagName == null)
- return false;
- return tagName.equals(JSPTag.JSP_ROOT);
- }
-
- /**
- */
- public boolean isJSPType() {
- if (this.model == null)
- return false;
- IModelHandler handler = this.model.getModelHandler();
- if (handler == null)
- return false;
- String id = handler.getAssociatedContentTypeId();
- if (id == null)
- return false;
- // TODO: -- avoid this semi hardcoded string
- return id.equals(IContentTypeIdentifier.ContentTypeID_JSP);
- }
-
- /**
- */
- public boolean isXMLType() {
- DocumentTypeAdapter adapter = getDocumentTypeAdapter();
- if (adapter == null)
- return true;
- return adapter.isXMLType();
- }
-
- /**
- */
- protected void importChildNodes(Node parent, boolean deep) {
- if (parent == null)
- return;
-
- removeChildNodes();
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- Node imported = importNode(child, deep);
- if (imported == null)
- continue;
- appendChild(imported);
- }
- }
-
- /**
- */
- public Node importNode(Node node, boolean deep) throws DOMException {
- if (node == null)
- return null;
- NodeImpl imported = (NodeImpl) node.cloneNode(deep);
- if (imported == null)
- return null;
- imported.setOwnerDocument(this, deep);
- return imported;
- }
-
- /**
- */
- protected void releaseDocumentType() {
- if (this.documentTypeAdapter == null)
- return;
- this.documentTypeAdapter.release();
- this.documentTypeAdapter = null;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the encoding
- * of this document. This is <code>null</code> when unspecified.
- *
- * @since DOM Level 3
- */
- public void setEncoding(java.lang.String encoding) {
- }
-
- /**
- * setModel method
- *
- * @param model
- * XMLModel
- */
-
- protected void setModel(XMLModel model) {
- this.model = (XMLModelImpl) model;
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, whether this
- * document is standalone.
- *
- * @since DOM Level 3
- */
- public void setStandalone(boolean standalone) {
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying whether errors checking is enforced or not.
- * When set to <code>false</code>, the implementation is free to not
- * test every possible error case normally defined on DOM operations, and
- * not raise any <code>DOMException</code>. In case of error, the
- * behavior is undefined. This attribute is <code>true</code> by
- * defaults.
- *
- * @since DOM Level 3
- */
- public void setStrictErrorChecking(boolean strictErrorChecking) {
- }
-
- /**
- * <p>
- * EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001. </a>.
- * <p>
- * An attribute specifying, as part of the XML declaration, the version
- * number of this document. This is <code>null</code> when unspecified.
- *
- * @since DOM Level 3
- */
- public void setVersion(java.lang.String version) {
- }
-
- /**
- * @param b
- */
- void activateTagNameCache(boolean b) {
- tagNameCache.activate(b);
- }
-
- /**
- * @param tagName
- */
- protected void checkTagNameValidity(String tagName) {
- if (!isValidName(tagName)) {
- throw new DOMException(DOMException.INVALID_CHARACTER_ERR, createDOMExceptionMessage(DOMException.INVALID_CHARACTER_ERR, tagName));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java
deleted file mode 100644
index e2a0930..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeAdapterImpl.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.xml.core.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.document.XMLDocument;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.w3c.dom.DocumentType;
-
-
-/**
- */
-public class DocumentTypeAdapterImpl implements DocumentTypeAdapter {
-
- private XMLDocument document = null;
- private DocumentType documentType = null;
-
- /**
- */
- protected DocumentTypeAdapterImpl() {
- super();
- }
-
- /**
- */
- protected DocumentTypeAdapterImpl(XMLDocument document) {
- this.document = document;
- if (document != null) {
- this.documentType = document.getDoctype();
- }
- }
-
- /**
- */
- protected XMLDocument getDocument() {
- return this.document;
- }
-
- /**
- */
- public DocumentType getDocumentType() {
- return this.documentType;
- }
-
- /**
- */
- public int getTagNameCase() {
- return STRICT_CASE;
- }
-
- /**
- */
- public int getAttrNameCase() {
- return STRICT_CASE;
- }
-
- /**
- */
- public boolean hasFeature(String feature) {
- return false;
- }
-
- /**
- */
- public boolean isXMLType() {
- return true;
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == DocumentTypeAdapter.class);
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (eventType != INodeNotifier.STRUCTURE_CHANGED)
- return;
- if (notifier == null || !(notifier instanceof XMLDocument))
- return;
- this.documentType = ((XMLDocument) notifier).getDoctype();
- }
-
- /**
- */
- protected void notifyDocumentTypeChanged() {
- if (this.document == null)
- return;
- XMLModel model = this.document.getModel();
- if (model == null)
- return;
- ((XMLModelImpl) model).documentTypeChanged();
- }
-
- /**
- */
- public void release() {
- // nothing to do
- }
-
- /**
- */
- protected void setDocumentType(DocumentType documentType) {
- this.documentType = documentType;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java
deleted file mode 100644
index 8be8b38..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/DocumentTypeImpl.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.document.XMLDocumentType;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-/**
- * DocumentType class
- */
-public class DocumentTypeImpl extends NodeImpl implements XMLDocumentType {
-
- private String name = null;
- private String publicId = null;
- private String systemId = null;
- private String internalSubset = null;
-
- /**
- * DocumentTypeImpl constructor
- */
- protected DocumentTypeImpl() {
- super();
- }
-
- /**
- * DocumentTypeImpl constructor
- * @param that DocumentTypeImpl
- */
- protected DocumentTypeImpl(DocumentTypeImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentTypeImpl cloned = new DocumentTypeImpl(this);
- return cloned;
- }
-
- /**
- * getEntities method
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getEntities() {
- return null;
- }
-
- /**
- */
- public String getInternalSubset() {
- return this.internalSubset;
- }
-
- /**
- * getName method
- * @return java.lang.String
- */
- public String getName() {
- if (this.name == null)
- return new String();
- return this.name;
- }
-
- /**
- * getNodeName
- * @return java.lang.String
- */
- public String getNodeName() {
- return getName();
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return DOCUMENT_TYPE_NODE;
- }
-
- /**
- * getNotations method
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getNotations() {
- return null;
- }
-
- /**
- * getPublicId method
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- return (regionType == XMLRegionContext.XML_DOCTYPE_DECLARATION_CLOSE || regionType == XMLRegionContext.XML_DECLARATION_CLOSE);
- }
-
- /**
- */
- public void setInternalSubset(String internalSubset) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.internalSubset = internalSubset;
- }
-
- /**
- * setName method
- * @param name java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setPublicId method
- * @param publicId java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.publicId = publicId;
-
- notifyValueChanged();
- }
-
- /**
- * setSystemId method
- * @param systemId java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.systemId = systemId;
-
- notifyValueChanged();
- }
-
- /**
- * toString method
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- buffer.append(getName());
- buffer.append('(');
- buffer.append(getPublicId());
- buffer.append(')');
- buffer.append('(');
- buffer.append(getSystemId());
- buffer.append(')');
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null) {
- buffer.append('@');
- buffer.append(flatNode.toString());
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java
deleted file mode 100644
index 7471804..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ElementImpl.java
+++ /dev/null
@@ -1,1356 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.document.JSPTag;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNamespace;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.eclipse.wst.xml.core.internal.parser.XMLSourceParser;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.eclipse.wst.xml.core.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-
-/**
- * ElementImpl class
- */
-public class ElementImpl extends NodeContainer implements XMLElement {
-
- private class Attributes implements NamedNodeMap {
- Attributes() {
- super();
- }
-
- public int getLength() {
- if (attrNodes == null)
- return 0;
- return attrNodes.getLength();
- }
-
- public Node item(int index) {
- if (attrNodes == null)
- return null;
- return attrNodes.item(index);
- }
-
- public Node getNamedItem(String name) {
- return getAttributeNode(name);
- }
-
- public Node getNamedItemNS(String uri, String name) {
- return getAttributeNodeNS(uri, name);
- }
-
- public Node setNamedItem(Node arg) throws DOMException {
- return setAttributeNode((AttrImpl) arg);
- }
-
- public Node setNamedItemNS(Node arg) throws DOMException {
- return setAttributeNodeNS((AttrImpl) arg);
- }
-
- public Node removeNamedItem(String name) throws DOMException {
- return removeAttributeNode(name);
- }
-
- public Node removeNamedItemNS(String uri, String name) throws DOMException {
- return removeAttributeNodeNS(uri, name);
- }
- }
-
- private String tagName = null;
- private boolean isEmptyTag = false;
- private NodeListImpl attrNodes = null;
- private IStructuredDocumentRegion endStructuredDocumentRegion = null;
- private boolean isJSPTag = false;
- private boolean isCommentTag = false;
- private String namespaceURI = null;
-
- /**
- * ElementImpl constructor
- */
- protected ElementImpl() {
- super();
- }
-
- /**
- * ElementImpl constructor
- * @param that ElementImpl
- */
- protected ElementImpl(ElementImpl that) {
- super(that);
-
- if (that != null) {
- this.tagName = that.tagName;
- this.isEmptyTag = that.isEmptyTag;
- this.isJSPTag = that.isJSPTag;
- this.isCommentTag = that.isCommentTag;
-
- // clone attributes
- that.cloneAttributes(this);
- }
- }
-
- /**
- * addEndTag method
- * @param end org.w3c.dom.Element
- */
- protected void addEndTag(Element endTag) {
- if (endTag == null)
- return;
- if (hasEndTag())
- return;
- ElementImpl end = (ElementImpl) endTag;
-
- // move the end flat node from the end tag
- IStructuredDocumentRegion flatNode = end.getEndStructuredDocumentRegion();
- if (flatNode == null)
- return;
- end.setEndStructuredDocumentRegion(null);
- setEndStructuredDocumentRegion(flatNode);
- }
-
- /**
- * appendAttibuteNode method
- * @return org.w3c.dom.Attr
- * @param newAttr org.w3c.dom.Attr
- */
- public Attr appendAttributeNode(Attr newAttr) {
- if (newAttr == null)
- return null;
- AttrImpl attr = (AttrImpl) newAttr;
- if (attr.getOwnerElement() != null)
- return null;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (this.attrNodes == null)
- this.attrNodes = new NodeListImpl();
- this.attrNodes.appendNode(attr);
- attr.setOwnerElement(this);
-
- notifyAttrReplaced(attr, null);
- return attr;
- }
-
- /**
- * cloneAttributes method
- * @param newOwner org.w3c.dom.Element
- */
- protected void cloneAttributes(Element newOwner) {
- if (newOwner == null || newOwner == this)
- return;
-
- ElementImpl element = (ElementImpl) newOwner;
- element.removeAttributes();
-
- if (this.attrNodes == null)
- return;
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- Node node = this.attrNodes.item(i);
- if (node == null)
- continue;
- Attr cloned = (Attr) node.cloneNode(false);
- if (cloned != null)
- element.appendAttributeNode(cloned);
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- ElementImpl cloned = new ElementImpl(this);
- if (deep)
- cloneChildNodes(cloned, deep);
- return cloned;
- }
-
- /**
- * getAttribute method
- * @return java.lang.String
- * @param name java.lang.String
- */
- public String getAttribute(String name) {
- Attr attr = getAttributeNode(name);
- if (attr == null)
- return null;
- return attr.getValue();
- }
-
- /**
- * getAttributeNode method
- * @return org.w3c.dom.Attr
- * @param name java.lang.String
- */
- public Attr getAttributeNode(String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- if (attr.matchName(name))
- return attr; // found
- }
-
- return null; // not found
- }
-
- /**
- */
- public Attr getAttributeNodeNS(String uri, String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- String localName = attr.getLocalName();
- if (localName == null || !localName.equals(name))
- continue;
- String nsURI = attr.getNamespaceURI();
- if (uri == null) {
- if (nsURI != null)
- continue;
- }
- else {
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
-
- // found
- return attr;
- }
-
- return null; // not found
- }
-
- /**
- */
- public String getAttributeNS(String uri, String name) {
- Attr attr = getAttributeNodeNS(uri, name);
- if (attr == null)
- return null;
- return attr.getValue();
- }
-
- /**
- * getAttributes method
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getAttributes() {
- return new Attributes();
- }
-
- /**
- */
- protected CMElementDeclaration getDeclaration() {
- Document document = getOwnerDocument();
- if (document == null)
- return null;
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery == null)
- return null;
- return modelQuery.getCMElementDeclaration(this);
- }
-
- /**
- * getElementsByTagName method
- * @return org.w3c.dom.NodeList
- * @param tagName java.lang.String
- */
- public NodeList getElementsByTagName(String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return new NodeListImpl();
- NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- if (tagName != null) {
- ElementImpl element = (ElementImpl) node;
- if (!element.matchTagName(tagName))
- continue;
- }
- elements.appendNode(node);
- }
-
- return elements;
- }
-
- /**
- */
- public NodeList getElementsByTagNameNS(String uri, String tagName) {
- if (tagName == null)
- return new NodeListImpl();
-
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return new NodeListImpl();
- NodeIterator it = document.createNodeIterator(this, NodeFilter.SHOW_ALL, null, false);
- if (it == null)
- return new NodeListImpl();
- NodeListImpl elements = new NodeListImpl();
-
- if (uri != null && uri.length() == 1 && uri.charAt(0) == '*') {
- uri = null; // do not care
- }
- if (tagName.length() == 1 && tagName.charAt(0) == '*') {
- tagName = null; // do not care
- }
-
- for (Node node = it.nextNode(); node != null; node = it.nextNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- continue;
- ElementImpl element = (ElementImpl) node;
- if (tagName != null) {
- String localName = element.getLocalName();
- if (localName == null || !localName.equals(tagName))
- continue;
- }
- if (uri != null) {
- String nsURI = element.getNamespaceURI();
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
- elements.appendNode(element);
- }
-
- return elements;
- }
-
- /**
- * getEndStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getEndStructuredDocumentRegion() {
- return this.endStructuredDocumentRegion;
- }
-
- /**
- * getEndOffset method
- * @return int
- */
- public int getEndOffset() {
- if (this.endStructuredDocumentRegion != null)
- return this.endStructuredDocumentRegion.getEnd();
- return super.getEndOffset();
- }
-
- /**
- * getEndStartOffset method
- * @return int
- */
- public int getEndStartOffset() {
- if (this.endStructuredDocumentRegion != null)
- return this.endStructuredDocumentRegion.getStart();
- return super.getEndOffset();
- }
-
- /**
- */
- public String getEndTagName() {
- if (this.endStructuredDocumentRegion == null)
- return null;
-
- ITextRegionList regions = this.endStructuredDocumentRegion.getRegions();
- if (regions == null)
- return null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (regionType == XMLRegionContext.XML_TAG_NAME || regionType == XMLJSPRegionContexts.JSP_ROOT_TAG_NAME || regionType == XMLJSPRegionContexts.JSP_DIRECTIVE_NAME) {
- return this.endStructuredDocumentRegion.getText(region);
- }
- }
-
- return null;
- }
-
- /**
- * getFirstStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null)
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(flatNode);
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.endStructuredDocumentRegion);
- }
-
- /**
- * getLastStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- if (this.endStructuredDocumentRegion != null)
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.endStructuredDocumentRegion);
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(getStructuredDocumentRegion());
- }
-
- /**
- */
- public String getLocalName() {
- if (this.tagName == null)
- return null;
- int index = this.tagName.indexOf(':');
- if (index < 0)
- return this.tagName;
- return this.tagName.substring(index + 1);
- }
-
- /**
- */
- public String getNamespaceURI() {
- String nsAttrName = null;
- String prefix = getPrefix();
- if (prefix != null && prefix.length() > 0) {
- nsAttrName = XMLNamespace.XMLNS_PREFIX + prefix;
- }
- else {
- nsAttrName = XMLNamespace.XMLNS;
- }
-
- for (Node node = this; node != null; node = node.getParentNode()) {
- if (node.getNodeType() != ELEMENT_NODE)
- break;
- Element element = (Element) node;
- Attr attr = element.getAttributeNode(nsAttrName);
- if (attr != null)
- return attr.getValue();
- }
-
- return this.namespaceURI;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- return getTagName();
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return ELEMENT_NODE;
- }
-
- /**
- */
- public String getPrefix() {
- if (this.tagName == null)
- return null;
- int index = this.tagName.indexOf(':');
- if (index <= 0)
- return null;
- // exclude JSP tag in tag name
- if (this.tagName.charAt(0) == '<')
- return null;
- return this.tagName.substring(0, index);
- }
-
- /**
- * getStartEndOffset method
- * @return int
- */
- public int getStartEndOffset() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode != null)
- return flatNode.getEnd();
- return super.getStartOffset();
- }
-
- /**
- * getStartStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getStartStructuredDocumentRegion() {
- return getStructuredDocumentRegion();
- }
-
- /**
- * getStartOffset method
- * @return int
- */
- public int getStartOffset() {
- if (getStartStructuredDocumentRegion() == null && this.endStructuredDocumentRegion != null && !hasChildNodes()) {
- return this.endStructuredDocumentRegion.getStart();
- }
- return super.getStartOffset();
- }
-
- /**
- * getTagName method
- * @return java.lang.String
- */
- public String getTagName() {
- if (this.tagName == null)
- return new String();
- return this.tagName;
- }
-
- /**
- */
- public boolean hasAttribute(String name) {
- return (getAttributeNode(name) != null);
- }
-
- /**
- */
- public boolean hasAttributeNS(String uri, String name) {
- return (getAttributeNodeNS(uri, name) != null);
- }
-
- /**
- */
- public boolean hasAttributes() {
- return (this.attrNodes != null && this.attrNodes.getLength() > 0);
- }
-
- /**
- * hasEndTag method
- * @return boolean
- */
- public boolean hasEndTag() {
- return (this.endStructuredDocumentRegion != null);
- }
-
- /**
- */
- protected final boolean hasPrefix() {
- if (this.tagName == null)
- return false;
- if (this.tagName.indexOf(':') <= 0)
- return false;
- // exclude JSP tag in tag name
- if (this.tagName.charAt(0) == '<')
- return false;
- return true;
- }
-
- /**
- * hasStartTag method
- * @return boolean
- */
- public boolean hasStartTag() {
- return (getStructuredDocumentRegion() != null);
- }
-
- /**
- */
- protected final boolean ignoreCase() {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && document.ignoreCase()) {
- // even in case insensitive document, if having prefix, it's case sensitive tag
- return !hasPrefix();
- }
- return false;
- }
-
- /**
- */
- protected Attr insertAttributeNode(Attr newAttr, int index) {
- if (newAttr == null)
- return null;
- AttrImpl attr = (AttrImpl) newAttr;
- if (attr.getOwnerElement() != null)
- return null;
-
- if (this.attrNodes == null)
- this.attrNodes = new NodeListImpl();
- this.attrNodes.insertNode(attr, index);
- attr.setOwnerElement(this);
-
- notifyAttrReplaced(attr, null);
- return attr;
- }
-
- /**
- * insertBefore method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param refChild org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- // should throw DOMException instead of return null?
- if (newChild == null)
- return null;
- if (!isContainer()) { // never be container
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String());
- }
- if (newChild.getNodeType() != TEXT_NODE) {
- if (isJSPContainer() || isCDATAContainer()) { // accepts only Text child
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String());
- }
- }
- return super.insertBefore(newChild, refChild);
- }
-
- /**
- */
- protected boolean isCDATAContainer() {
- // use BlockMaker instead of CMElementDeclaration
- // because <style> and <script> in XHTML is not CDATA content type
- XMLModel model = getModel();
- if (model == null)
- return false; // error
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument == null)
- return false; // eror
- RegionParser parser = structuredDocument.getParser();
- if (parser == null || !(parser instanceof XMLSourceParser))
- return false;
- return (((XMLSourceParser) parser).getBlockMarker(this.tagName) != null);
- /*
- CMElementDeclaration decl = getDeclaration();
- if (decl == null) return false;
- if (decl instanceof CMNodeWrapper) {
- decl = (CMElementDeclaration)((CMNodeWrapper)decl).getOriginNode();
- if (decl == null) return false;
- }
- if (decl instanceof TLDElementDeclaration) {
- String content = ((TLDElementDeclaration)decl).getBodycontent();
- if (content == null) return false;
- return content.equals(JSP11TLDNames.CONTENT_TAGDEPENDENT);
- }
- if (!isGlobalTag()) return false;
- return (decl.getContentType() == CMElementDeclaration.CDATA);
- */
- }
-
- /**
- */
- public boolean isClosed() {
- IStructuredDocumentRegion flatNode = null;
- if (isEmptyTag() || !isContainer()) {
- flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- }
- else {
- flatNode = getEndStructuredDocumentRegion();
- if (flatNode == null)
- return false; // must be generated
- }
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- if (isCommentTag()) {
- return (regionType == XMLJSPRegionContexts.JSP_COMMENT_CLOSE || regionType == XMLRegionContext.XML_COMMENT_CLOSE);
- }
- if (isJSPTag()) {
- return (regionType == XMLJSPRegionContexts.JSP_CLOSE || regionType == XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE);
- }
- return (regionType == XMLRegionContext.XML_TAG_CLOSE || regionType == XMLRegionContext.XML_EMPTY_TAG_CLOSE || regionType == XMLRegionContext.XML_DECLARATION_CLOSE);
- }
-
- /**
- */
- public final boolean isCommentTag() {
- return this.isCommentTag;
- }
-
- /**
- * isContainer method
- * @return boolean
- */
- public boolean isContainer() {
- if (isCommentTag()) {
- CommentElementAdapter adapter = (CommentElementAdapter) getAdapterFor(CommentElementAdapter.class);
- if (adapter != null) {
- return (adapter.isContainer());
- }
- return (getDeclaration() == null);
- }
- if (isJSPTag()) {
- // exclude JSP directive
- return (matchTagName(JSPTag.JSP_SCRIPTLET) || matchTagName(JSPTag.JSP_DECLARATION) || matchTagName(JSPTag.JSP_EXPRESSION));
- }
- if (!isXMLTag()) { // non-XML tag
- CMElementDeclaration decl = getDeclaration();
- if (decl == null)
- return false; // undefined tag
- return (decl.getContentType() != CMElementDeclaration.EMPTY);
- }
- return true;
- }
-
- /**
- * isEmptyTag method
- * @return boolean
- */
- public boolean isEmptyTag() {
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- if (!isXMLTag())
- return false;
- return this.isEmptyTag;
- }
-
- /**
- */
- public boolean isEndTag() {
- return (hasEndTag() && !hasStartTag() && !hasChildNodes());
- }
-
- /**
- */
- public boolean isJSPContainer() {
- return (isJSPTag() && !isCommentTag() && isContainer());
- }
-
- /**
- */
- public boolean isGlobalTag() {
- return !hasPrefix();
- }
-
- /**
- */
- public boolean isImplicitTag() {
- if (hasStartTag() || hasEndTag())
- return false;
- // make sure this is in the document tree
- // because if not in the document tree, no tags are generated yet
- return (getContainerDocument() != null);
- }
-
- /**
- * isJSPTag method
- * @return boolean
- */
- public final boolean isJSPTag() {
- return this.isJSPTag;
- }
-
- /**
- */
- public boolean isStartTagClosed() {
- IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
- if (flatNode == null)
- return true; // will be generated
- String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
- if (isCommentTag()) {
- return (regionType == XMLJSPRegionContexts.JSP_COMMENT_CLOSE || regionType == XMLRegionContext.XML_COMMENT_CLOSE);
- }
- if (isJSPTag()) {
- if (isContainer())
- return true; // start tag always has a single region
- return (regionType == XMLJSPRegionContexts.JSP_DIRECTIVE_CLOSE);
- }
- return (regionType == XMLRegionContext.XML_TAG_CLOSE || regionType == XMLRegionContext.XML_EMPTY_TAG_CLOSE || regionType == XMLRegionContext.XML_DECLARATION_CLOSE);
- }
-
- /**
- */
- public final boolean isXMLTag() {
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document != null && !document.isXMLType()) {
- // even in non-XML document, if having prefix, it's XML tag
- return hasPrefix();
- }
- return true;
- }
-
- /**
- */
- protected boolean matchEndTag(Element element) {
- if (element == null)
- return false;
- ElementImpl impl = (ElementImpl) element;
- if (isJSPTag() && !isCommentTag()) {
- return (impl.isJSPTag() && !impl.isCommentTag());
- }
- return matchTagName(element.getTagName());
- }
-
- /**
- * matchTagName method
- * @return boolean
- * @param tagName java.lang.String
- */
- public boolean matchTagName(String tagName) {
- if (tagName == null)
- return (this.tagName == null);
- if (this.tagName == null)
- return false;
- if (!ignoreCase())
- return this.tagName.equals(tagName);
- return this.tagName.equalsIgnoreCase(tagName);
- }
-
- /**
- * notifyAttrReplaced method
- * @param newAttr org.w3c.dom.Attr
- * @param oldAttr org.w3c.dom.Attr
- */
- protected void notifyAttrReplaced(Attr newAttr, Attr oldAttr) {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.attrReplaced(this, newAttr, oldAttr);
- }
-
- /**
- * notifyValueChanged method
- */
- public void notifyEndTagChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.endTagChanged(this);
- }
-
- /**
- */
- public void notifyStartTagChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.startTagChanged(this);
- }
-
- /**
- */
- public boolean preferEmptyTag() {
- if (hasChildNodes())
- return false;
- if (isJSPTag())
- return false;
- if (isCommentTag())
- return false;
- if (!isXMLTag())
- return false;
- CMElementDeclaration decl = getDeclaration();
- if (decl == null)
- return false;
- return (decl.getContentType() == CMElementDeclaration.EMPTY);
- }
-
- /**
- * removeAttribute method
- * @param name java.lang.String
- */
- public void removeAttribute(String name) throws DOMException {
- removeAttributeNode(name);
- }
-
- /**
- * removeAttributeNode method
- * @return org.w3c.dom.Attr
- * @param name java.lang.String
- */
- public Attr removeAttributeNode(String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- if (!attr.matchName(name))
- continue;
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- return null; // not found
- }
-
- /**
- * removeAttributeNode method
- * @return org.w3c.dom.Attr
- * @param oldAttr org.w3c.dom.Attr
- */
- public Attr removeAttributeNode(Attr oldAttr) throws DOMException {
- if (oldAttr == null)
- return null; // invalid parameter
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (this.attrNodes == null) { // no attribute
- throw new DOMException(DOMException.NOT_FOUND_ERR, new String());
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr != oldAttr)
- continue;
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- // not found
- throw new DOMException(DOMException.NOT_FOUND_ERR, new String());
- }
-
- /**
- */
- public Attr removeAttributeNodeNS(String uri, String name) {
- if (name == null)
- return null; // invalid parameter
- if (this.attrNodes == null)
- return null; // no attribute
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- String localName = attr.getLocalName();
- if (localName == null || !localName.equals(name))
- continue;
- String nsURI = attr.getNamespaceURI();
- if (uri == null) {
- if (nsURI != null)
- continue;
- }
- else {
- if (nsURI == null || !nsURI.equals(uri))
- continue;
- }
-
- // found
- this.attrNodes.removeNode(i);
- attr.setOwnerElement(null);
-
- notifyAttrReplaced(null, attr);
- return attr;
- }
-
- return null; // not found
- }
-
- /**
- */
- public void removeAttributeNS(String uri, String name) throws DOMException {
- removeAttributeNodeNS(uri, name);
- }
-
- /**
- * removeAttributes method
- */
- public void removeAttributes() {
- if (this.attrNodes == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr != null) {
- attr.setOwnerElement(null);
- notifyAttrReplaced(null, attr);
- }
- }
-
- this.attrNodes = null;
- }
-
- /**
- * removeEndTag method
- * @return org.w3c.dom.Element
- */
- protected Element removeEndTag() {
- if (!hasEndTag())
- return null;
- NodeListImpl attrNodes = this.attrNodes;
- this.attrNodes = null; // not to copy attributes
- ElementImpl end = (ElementImpl) cloneNode(false);
- this.attrNodes = attrNodes;
- if (end == null)
- return null;
-
- // move the end flat node to the end tag
- IStructuredDocumentRegion flatNode = getEndStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- setEndStructuredDocumentRegion(null);
- end.setEndStructuredDocumentRegion(flatNode);
- return end;
- }
-
- /**
- */
- protected void removeStartTag() {
- removeAttributes();
- }
-
- /**
- * Resets attribute values from IStructuredDocumentRegion.
- */
- void resetStructuredDocumentRegions() {
- if (this.attrNodes != null) {
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- attr.resetRegions();
- }
- }
-
- super.resetStructuredDocumentRegions(); // for children
-
- this.endStructuredDocumentRegion = null;
- }
-
- /**
- */
- public void setCommentTag(boolean isCommentTag) {
- XMLNode parent = (XMLNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.isCommentTag = isCommentTag;
- }
-
- /**
- * setAttribute method
- * @param name java.lang.String
- * @param value java.lang.String
- */
- public void setAttribute(String name, String value) throws DOMException {
- if (name == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- Attr attr = getAttributeNode(name);
- if (attr != null) {
- attr.setValue(value); // change value
- return;
- }
-
- // new attribute
- Document doc = getOwnerDocument();
- if (doc == null)
- return;
- attr = doc.createAttribute(name);
- if (attr == null)
- return;
- attr.setValue(value);
- appendAttributeNode(attr);
- }
-
- /**
- * setAttributeNode method
- * @return org.w3c.dom.Attr
- * @param newAttr org.w3c.dom.Attr
- */
- public Attr setAttributeNode(Attr newAttr) throws DOMException {
- if (newAttr == null)
- return null; // nothing to do
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- AttrImpl attr = (AttrImpl) newAttr;
- Element owner = attr.getOwnerElement();
- if (owner != null) {
- if (owner == this)
- return null; // nothing to do
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, new String());
- }
-
- Attr oldAttr = removeAttributeNode(newAttr.getName());
- appendAttributeNode(attr);
- return oldAttr;
- }
-
- /**
- */
- public Attr setAttributeNodeNS(Attr newAttr) throws DOMException {
- if (newAttr == null)
- return null; // nothing to do
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- AttrImpl attr = (AttrImpl) newAttr;
- Element owner = attr.getOwnerElement();
- if (owner != null) {
- if (owner == this)
- return null; // nothing to do
- throw new DOMException(DOMException.INUSE_ATTRIBUTE_ERR, new String());
- }
-
- String name = newAttr.getLocalName();
- String uri = newAttr.getNamespaceURI();
- Attr oldAttr = removeAttributeNodeNS(uri, name);
- appendAttributeNode(attr);
- return oldAttr;
- }
-
- /**
- */
- public void setAttributeNS(String uri, String name, String value) throws DOMException {
- if (name == null)
- return;
-
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- Attr attr = getAttributeNodeNS(uri, name);
- if (attr != null) {
- attr.setValue(value); // change value
- return;
- }
-
- // new attribute
- Document doc = getOwnerDocument();
- if (doc == null)
- return;
- attr = doc.createAttributeNS(uri, name);
- if (attr == null)
- return;
- attr.setValue(value);
- appendAttributeNode(attr);
- }
-
- /**
- * setEmptyTag method
- * @param isEmptyTag boolean
- */
- public void setEmptyTag(boolean isEmptyTag) {
- XMLNode parent = (XMLNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.isEmptyTag = isEmptyTag;
- }
-
- /**
- * setEndStructuredDocumentRegion method
- */
- void setEndStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- this.endStructuredDocumentRegion = flatNode;
-
- NodeContainer parent = (NodeContainer) getParentNode();
- if (parent != null) {
- parent.syncChildEditableState(this);
- }
- }
-
- /**
- * setJSPTag method
- * @param isJSPTag boolean
- */
- public void setJSPTag(boolean isJSPTag) {
- XMLNode parent = (XMLNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.isJSPTag = isJSPTag;
- }
-
- /**
- */
- protected void setNamespaceURI(String namespaceURI) {
- this.namespaceURI = namespaceURI;
- }
-
- /**
- */
- protected void setOwnerDocument(Document ownerDocument, boolean deep) {
- super.setOwnerDocument(ownerDocument, deep);
-
- if (this.attrNodes == null)
- return;
-
- int length = this.attrNodes.getLength();
- for (int i = 0; i < length; i++) {
- AttrImpl attr = (AttrImpl) this.attrNodes.item(i);
- if (attr == null)
- continue;
- attr.setOwnerDocument(ownerDocument);
- }
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- XMLNode parent = (XMLNode) getParentNode();
- if (parent != null && !parent.isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- int prefixLength = (prefix != null ? prefix.length() : 0);
- String localName = getLocalName();
- if (prefixLength == 0) {
- if (localName == null || localName.length() == 0) {
- // invalid local name
- return;
- }
- setTagName(localName);
- }
- else {
- int localLength = (localName != null ? localName.length() : 0);
- StringBuffer buffer = new StringBuffer(prefixLength + 1 + localLength);
- buffer.append(prefix);
- buffer.append(':');
- if (localName != null)
- buffer.append(localName);
- setTagName(buffer.toString());
- }
-
- boolean changeEndTag = hasEndTag();
- notifyStartTagChanged();
- if (changeEndTag)
- notifyEndTagChanged();
- }
-
- /**
- * setStartStructuredDocumentRegion method
- */
- void setStartStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- setStructuredDocumentRegion(flatNode);
- }
-
- /**
- * setTagName method
- * @param tagName java.lang.String
- */
- protected void setTagName(String tagName) {
- this.tagName = tagName;
- }
-
- /**
- * toString method
- * @return java.lang.String
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
- String tagName = getTagName();
- if (hasStartTag())
- buffer.append(tagName);
- if (isEmptyTag())
- buffer.append('/');
- if (hasEndTag()) {
- buffer.append('/');
- buffer.append(tagName);
- }
- if (buffer.length() == 0)
- buffer.append(tagName);
-
- IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- buffer.append('@');
- buffer.append(startStructuredDocumentRegion.toString());
- }
- IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- buffer.append('@');
- buffer.append(endStructuredDocumentRegion.toString());
- }
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java
deleted file mode 100644
index 7d5abc0..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityImpl.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Entity;
-import org.w3c.dom.Node;
-
-/**
- * EntityImpl class
- */
-public class EntityImpl extends NodeImpl implements Entity {
-
- private String name = null;
- private String publicId = null;
- private String systemId = null;
- private String notationName = null;
-
- /**
- * EntityImpl constructor
- */
- protected EntityImpl() {
- super();
- }
-
- /**
- * EntityImpl constructor
- * @param that EntityImpl
- */
- protected EntityImpl(EntityImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- this.publicId = that.publicId;
- this.systemId = that.systemId;
- this.notationName = that.notationName;
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- EntityImpl cloned = new EntityImpl(this);
- return cloned;
- }
-
- /**
- * <p>EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the encoding
- * of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- * @since DOM Level 3
- */
- public java.lang.String getEncoding() {
- return null;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return new String();
- return this.name;
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return ENTITY_NODE;
- }
-
- /**
- * getNotationName method
- * @return java.lang.String
- */
- public String getNotationName() {
- return this.notationName;
- }
-
- /**
- * getPublicId method
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- * <p>EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the version
- * number of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- * @since DOM Level 3
- */
- public java.lang.String getVersion() {
- return null;
- }
-
- /**
- * <p>EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the encoding
- * of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- * @since DOM Level 3
- */
- public void setEncoding(java.lang.String encoding) {
- }
-
- /**
- * setName method
- * @param name java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setNotationName method
- * @param notationName java.lang.String
- */
- public void setNotationName(String notationName) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.notationName = notationName;
- }
-
- /**
- * setPublicId method
- * @param publicId java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.publicId = publicId;
- }
-
- /**
- * setSystemId method
- * @param systemId java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.systemId = systemId;
- }
-
- /**
- * <p>EXPERIMENTAL! Based on the <a
- * href='http://www.w3.org/TR/2001/WD-DOM-Level-3-Core-20010605'>Document
- * Object Model (DOM) Level 3 Core Working Draft of 5 June 2001.</a>.
- * <p>
- * An attribute specifying, as part of the text declaration, the version
- * number of this entity, when it is an external parsed entity. This is
- * <code>null</code> otherwise.
- * @since DOM Level 3
- */
- public void setVersion(java.lang.String version) {
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java
deleted file mode 100644
index 919d78d..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/EntityReferenceImpl.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.EntityReference;
-import org.w3c.dom.Node;
-
-/**
- * EntityReference class
- */
-public class EntityReferenceImpl extends NodeImpl implements EntityReference {
-
- private String name = null;
-
- /**
- * EntityReferenceImpl constructor
- */
- protected EntityReferenceImpl() {
- super();
- }
-
- /**
- * EntityReferenceImpl constructor
- * @param that EntityReferenceImpl
- */
- protected EntityReferenceImpl(EntityReferenceImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- EntityReferenceImpl cloned = new EntityReferenceImpl(this);
- return cloned;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return new String();
- return this.name;
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return ENTITY_REFERENCE_NODE;
- }
-
- /**
- * setName method
- * @param name java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java
deleted file mode 100644
index 46fe247..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ModelParserAdapter.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.xml.core.document.XMLElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- */
-public interface ModelParserAdapter extends INodeAdapter {
-
- /**
- */
- public boolean canContain(Element element, Node child);
-
- /**
- */
- public boolean canBeImplicitTag(Element element);
-
- /**
- */
- public boolean canBeImplicitTag(Element element, Node child);
-
- /**
- */
- public Element createCommentElement(Document document, String data, boolean isJSPTag);
-
- /**
- */
- public Element createImplicitElement(Document document, Node parent, Node child);
-
- /**
- */
- public String getFindRootName(String tagName);
-
- /**
- */
- public boolean isEndTag(XMLElement element);
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java
deleted file mode 100644
index 28a2b15..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeContainer.java
+++ /dev/null
@@ -1,469 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * NodeContainer class
- */
-public abstract class NodeContainer extends NodeImpl implements Node, NodeList {
-
- private NodeImpl firstChild = null;
- private NodeImpl lastChild = null;
- private NodeList childNodesCache = null;
-
- /**
- */
- private class ChildNodesCache implements NodeList {
- private int length = 0;
- private int curIndex = -1;
- private Node curChild = null;
-
- ChildNodesCache() {
- for (Node child = firstChild; child != null; child = child.getNextSibling()) {
- this.length++;
- }
- }
-
- public int getLength() {
- return this.length;
- }
-
- public Node item(int index) {
- if (this.length == 0)
- return null;
- if (index < 0)
- return null;
- if (index >= this.length)
- return null;
-
- if (this.curIndex < 0) { // first time
- if (index * 2 >= this.length) { // search from the last
- this.curIndex = this.length - 1;
- this.curChild = lastChild;
- }
- else { // search from the first
- this.curIndex = 0;
- this.curChild = firstChild;
- }
- }
-
- if (index == this.curIndex)
- return this.curChild;
-
- if (index > this.curIndex) {
- while (index > this.curIndex) {
- this.curIndex++;
- this.curChild = this.curChild.getNextSibling();
- }
- }
- else { // index < this.curIndex
- while (index < this.curIndex) {
- this.curIndex--;
- this.curChild = this.curChild.getPreviousSibling();
- }
- }
-
- return this.curChild;
- }
- }
-
- /**
- * NodeContainer constructor
- */
- protected NodeContainer() {
- super();
- }
-
- /**
- * NodeContainer constructor
- * @param that NodeContainer
- */
- protected NodeContainer(NodeContainer that) {
- super(that);
- }
-
- /**
- * appendChild method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- */
- public Node appendChild(Node newChild) throws DOMException {
- return insertBefore(newChild, null);
- }
-
- /**
- * cloneChildNodes method
- * @param container org.w3c.dom.Node
- * @param deep boolean
- */
- protected void cloneChildNodes(Node newParent, boolean deep) {
- if (newParent == null || newParent == this)
- return;
- if (!(newParent instanceof NodeContainer))
- return;
-
- NodeContainer container = (NodeContainer) newParent;
- container.removeChildNodes();
-
- for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) {
- Node cloned = child.cloneNode(deep);
- if (cloned != null)
- container.appendChild(cloned);
- }
- }
-
- /**
- * getChildNodes method
- * @return org.w3c.dom.NodeList
- */
- public NodeList getChildNodes() {
- return this;
- }
-
- /**
- * getFirstChild method
- * @return org.w3c.dom.Node
- */
- public Node getFirstChild() {
- return this.firstChild;
- }
-
- /**
- * getLastChild method
- * @return org.w3c.dom.Node
- */
- public Node getLastChild() {
- return this.lastChild;
- }
-
- /**
- * getLength method
- * @return int
- */
- public int getLength() {
- if (this.firstChild == null)
- return 0;
- if (this.childNodesCache == null)
- this.childNodesCache = new ChildNodesCache();
- return this.childNodesCache.getLength();
- }
-
- /**
- */
- public String getSource() {
- StringBuffer buffer = new StringBuffer();
-
- IStructuredDocumentRegion startStructuredDocumentRegion = getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- String source = startStructuredDocumentRegion.getText();
- if (source != null)
- buffer.append(source);
- }
-
- for (NodeImpl child = firstChild; child != null; child = (NodeImpl) child.getNextSibling()) {
- String source = child.getSource();
- if (source != null)
- buffer.append(source);
- }
-
- IStructuredDocumentRegion endStructuredDocumentRegion = getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null) {
- String source = endStructuredDocumentRegion.getText();
- if (source != null)
- buffer.append(source);
- }
-
- return buffer.toString();
- }
-
- /**
- * hasChildNodes method
- * @return boolean
- */
- public boolean hasChildNodes() {
- return (this.firstChild != null);
- }
-
- /**
- * insertBefore method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param refChild org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- if (newChild == null)
- return null; // nothing to do
- if (refChild != null && refChild.getParentNode() != this) {
- throw new DOMException(DOMException.NOT_FOUND_ERR, new String());
- }
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
- if (newChild == refChild)
- return newChild; // nothing to do
-
- if (newChild.getNodeType() == DOCUMENT_FRAGMENT_NODE) {
- // insert child nodes instead
- for (Node child = newChild.getFirstChild(); child != null; child = newChild.getFirstChild()) {
- newChild.removeChild(child);
- insertBefore(child, refChild);
- }
- return newChild;
- }
-
- this.childNodesCache = null; // invalidate child nodes cache
-
- NodeImpl child = (NodeImpl) newChild;
- NodeImpl next = (NodeImpl) refChild;
- NodeImpl prev = null;
- Node oldParent = child.getParentNode();
- if (oldParent != null)
- oldParent.removeChild(child);
- if (next == null) {
- prev = this.lastChild;
- this.lastChild = child;
- }
- else {
- prev = (NodeImpl) next.getPreviousSibling();
- next.setPreviousSibling(child);
- }
- if (prev == null)
- this.firstChild = child;
- else
- prev.setNextSibling(child);
- child.setPreviousSibling(prev);
- child.setNextSibling(next);
- child.setParentNode(this);
- // make sure having the same owner document
- if (child.getOwnerDocument() == null) {
- if (getNodeType() == DOCUMENT_NODE) {
- child.setOwnerDocument((Document) this);
- }
- else {
- child.setOwnerDocument(getOwnerDocument());
- }
- }
-
- notifyChildReplaced(child, null);
-
- return child;
- }
-
- /**
- * isContainer method
- * @return boolean
- */
- public boolean isContainer() {
- return true;
- }
-
- /**
- * item method
- * @return org.w3c.dom.Node
- * @param index int
- */
- public Node item(int index) {
- if (this.firstChild == null)
- return null;
- if (this.childNodesCache == null)
- this.childNodesCache = new ChildNodesCache();
- return this.childNodesCache.item(index);
- }
-
- /**
- * notifyChildReplaced method
- * @param newChild org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- protected void notifyChildReplaced(Node newChild, Node oldChild) {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
-
- syncChildEditableState(newChild);
-
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.childReplaced(this, newChild, oldChild);
- }
-
- protected void syncChildEditableState(Node child) {
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (fChildEditable) {
- roc.unlockNode((NodeImpl) child);
- }
- else {
- roc.lockNode((NodeImpl) child);
- }
- }
-
- /**
- * removeChild method
- * @return org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- public Node removeChild(Node oldChild) throws DOMException {
- if (oldChild == null)
- return null;
- if (oldChild.getParentNode() != this) {
- throw new DOMException(DOMException.NOT_FOUND_ERR, new String());
- }
-
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- this.childNodesCache = null; // invalidate child nodes cache
-
- NodeImpl child = (NodeImpl) oldChild;
- NodeImpl prev = (NodeImpl) child.getPreviousSibling();
- NodeImpl next = (NodeImpl) child.getNextSibling();
-
- child.setEditable(true, true); // clear ReadOnly flags
-
- if (prev == null)
- this.firstChild = next;
- else
- prev.setNextSibling(next);
- if (next == null)
- this.lastChild = prev;
- else
- next.setPreviousSibling(prev);
- child.setPreviousSibling(null);
- child.setNextSibling(null);
- child.setParentNode(null);
-
- notifyChildReplaced(null, child);
-
- return child;
- }
-
- /**
- * removeChildNodes method
- */
- public void removeChildNodes() {
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- Node nextChild = null;
- for (Node child = getFirstChild(); child != null; child = nextChild) {
- nextChild = child.getNextSibling();
- removeChild(child);
- }
- }
-
- /**
- * removeChildNodes method
- * @return org.w3c.dom.DocumentFragment
- * @param firstChild org.w3c.dom.Node
- * @param lastChild org.w3c.dom.Node
- */
- public DocumentFragment removeChildNodes(Node firstChild, Node lastChild) {
- if (!hasChildNodes())
- return null;
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- Document document = null;
- if (getNodeType() == DOCUMENT_NODE)
- document = (Document) this;
- else
- document = getOwnerDocument();
- if (document == null)
- return null;
- DocumentFragment fragment = document.createDocumentFragment();
- if (fragment == null)
- return null;
-
- if (firstChild == null)
- firstChild = getFirstChild();
- if (lastChild == null)
- lastChild = getLastChild();
- Node nextChild = null;
- for (Node child = firstChild; child != null; child = nextChild) {
- nextChild = child.getNextSibling();
- removeChild(child);
- fragment.appendChild(child);
- if (child == lastChild)
- break;
- }
-
- return fragment;
- }
-
- /**
- * replaceChild method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- if (!isChildEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
-
- if (oldChild == null)
- return newChild;
- if (newChild != null)
- insertBefore(newChild, oldChild);
- return removeChild(oldChild);
- }
-
- public boolean isChildEditable() {
- if (!fChildEditable) {
- XMLModelImpl model = (XMLModelImpl) getModel();
- if (model != null && model.isReparsing()) {
- return true;
- }
- }
- return fChildEditable;
- }
-
- public void setChildEditable(boolean editable) {
- if (fChildEditable == editable) {
- return;
- }
-
- ReadOnlyController roc = ReadOnlyController.getInstance();
- Node node;
- if (editable) {
- for (node = getFirstChild(); node != null; node = node.getNextSibling()) {
- roc.unlockNode((XMLNode) node);
- }
- }
- else {
- for (node = getFirstChild(); node != null; node = node.getNextSibling()) {
- roc.lockNode((XMLNode) node);
- }
- }
-
- fChildEditable = editable;
- notifyEditableChanged();
- }
-
- private boolean fChildEditable = true;
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java
deleted file mode 100644
index 8f16ce1..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeImpl.java
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.AbstractNotifier;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.xml.core.document.InvalidCharacterException;
-import org.eclipse.wst.xml.core.document.XMLModel;
-import org.eclipse.wst.xml.core.document.XMLNode;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentFragment;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.Text;
-
-
-/**
- * NodeImpl class
- */
-public abstract class NodeImpl extends AbstractNotifier implements XMLNode {
-
- private DocumentImpl ownerDocument = null;
- private NodeImpl parentNode = null;
- private NodeImpl nextSibling = null;
- private NodeImpl previousSibling = null;
- private IStructuredDocumentRegion flatNode = null;
- // define one empty nodelist, for repeated use
- private final static NodeList EMPTY_NODE_LIST = new NodeListImpl();
-
- /**
- * NodeImpl constructor
- */
- protected NodeImpl() {
- super();
- }
-
- /**
- * NodeImpl constructor
- * @param that NodeImpl
- */
- protected NodeImpl(NodeImpl that) {
- if (that != null) {
- this.ownerDocument = that.ownerDocument;
- }
- }
-
- /**
- * appendChild method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- */
- public Node appendChild(Node newChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String());
- }
-
- /**
- * contains method
- * @return boolean
- * @param offset int
- */
- public boolean contains(int offset) {
- return (offset >= getStartOffset() && offset < getEndOffset());
- }
-
- /**
- * getAttributes method
- * @return org.w3c.dom.NamedNodeMap
- */
- public NamedNodeMap getAttributes() {
- return null;
- }
-
- /**
- */
- protected String getCharValue(String name) {
- DocumentImpl document = (DocumentImpl) getOwnerDocument();
- if (document == null)
- return null;
- return document.getCharValue(name);
- }
-
- /**
- * getChildNodes method
- * @return org.w3c.dom.NodeList
- */
- public NodeList getChildNodes() {
- // As per DOM spec, correct behavior for getChildNodes is to return a
- // zero length NodeList, not null, when there are no children.
- // We'll use a common instance of an empty node list, just to prevent
- // creating a trival object many many times.
-
- return EMPTY_NODE_LIST;
- }
-
- /**
- * getCommonAncestor method
- * @return org.w3c.dom.Node
- * @param node org.w3c.dom.Node
- */
- public Node getCommonAncestor(Node node) {
- if (node == null)
- return null;
-
- for (Node na = node; na != null; na = na.getParentNode()) {
- for (Node ta = this; ta != null; ta = ta.getParentNode()) {
- if (ta == na)
- return ta;
- }
- }
-
- return null; // not found
- }
-
- /**
- * getContainerDocument method
- * @return org.w3c.dom.Document
- */
- public Document getContainerDocument() {
- for (Node node = this; node != null; node = node.getParentNode()) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return (Document) node;
- }
- }
- return null;
- }
-
- public IStructuredDocumentRegion getEndStructuredDocumentRegion() {
- return null;
- }
-
- /**
- * getEndOffset method
- * @return int
- */
- public int getEndOffset() {
- Node node = this;
- while (node != null) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) node;
- IStructuredDocumentRegion endStructuredDocumentRegion = element.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null)
- return endStructuredDocumentRegion.getEnd();
- }
-
- Node last = node.getLastChild();
- if (last != null) { // dig into the last
- node = last;
- continue;
- }
-
- IStructuredDocumentRegion lastStructuredDocumentRegion = ((NodeImpl) node).getStructuredDocumentRegion();
- if (lastStructuredDocumentRegion != null)
- return lastStructuredDocumentRegion.getEnd();
-
- Node prev = node.getPreviousSibling();
- if (prev != null) { // move to the previous
- node = prev;
- continue;
- }
-
- Node parent = node.getParentNode();
- node = null;
- while (parent != null) {
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- IStructuredDocumentRegion startStructuredDocumentRegion = element.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null)
- return startStructuredDocumentRegion.getEnd();
- }
- Node parentPrev = parent.getPreviousSibling();
- if (parentPrev != null) { // move to the previous
- node = parentPrev;
- break;
- }
- parent = parent.getParentNode();
- }
- }
- return 0;
- }
-
- /**
- */
- public IFactoryRegistry getFactoryRegistry() {
- XMLModel model = getModel();
- if (model != null) {
- IFactoryRegistry reg = model.getFactoryRegistry();
- if (reg != null)
- return reg;
- }
- return null;
- }
-
- /**
- * getFirstChild method
- * @return org.w3c.dom.Node
- */
- public Node getFirstChild() {
- return null;
- }
-
- /**
- * getFirstStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.flatNode);
- }
-
- /**
- * Every node (indirectly) knows its structuredDocument
- */
- public IStructuredDocument getStructuredDocument() {
- return getModel().getStructuredDocument();
- }
-
- /**
- */
- IStructuredDocumentRegion getStructuredDocumentRegion() {
- return this.flatNode;
- }
-
- /**
- */
- public int getIndex() {
- Node parent = getParentNode();
- if (parent == null)
- return -1; // error
- int index = 0;
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child == this)
- return index;
- index++;
- }
- return -1; // error
- }
-
- /**
- * getLastChild method
- * @return org.w3c.dom.Node
- */
- public Node getLastChild() {
- return null;
- }
-
- /**
- * getLastStructuredDocumentRegion method
- */
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- return StructuredDocumentRegionUtil.getStructuredDocumentRegion(this.flatNode);
- }
-
- /**
- */
- public String getLocalName() {
- return null;
- }
-
- /**
- * the default implementation can just refer to the owning document
- */
- public XMLModel getModel() {
- if (this.ownerDocument == null)
- return null;
- return this.ownerDocument.getModel();
- }
-
- /**
- * all but attr return null
- */
- public ITextRegion getNameRegion() {
- return null;
- }
-
- /**
- */
- public String getNamespaceURI() {
- return null;
- }
-
- /**
- * getNextSibling method
- * @return org.w3c.dom.Node
- */
- public Node getNextSibling() {
- return this.nextSibling;
- }
-
- /**
- * getNodeAt method
- * @return org.w3c.dom.Node
- * @param offset int
- */
- Node getNodeAt(int offset) {
- XMLNode parent = this;
- XMLNode child = (XMLNode) getFirstChild();
- while (child != null) {
- if (child.getEndOffset() <= offset) {
- child = (XMLNode) child.getNextSibling();
- continue;
- }
- if (child.getStartOffset() > offset) {
- break;
- }
-
- IStructuredDocumentRegion startStructuredDocumentRegion = child.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null) {
- if (startStructuredDocumentRegion.getEnd() > offset)
- return child;
- }
-
- // dig more
- parent = child;
- child = (XMLNode) parent.getFirstChild();
- }
-
- return parent;
- }
-
- /**
- * getNodeValue method
- * @return java.lang.String
- */
- public String getNodeValue() throws DOMException {
- return null;
- }
-
- /**
- * getOwnerDocument method
- * @return org.w3c.dom.Document
- */
- public Document getOwnerDocument() {
- return this.ownerDocument;
- }
-
- /**
- * getParentNode method
- * @return org.w3c.dom.Node
- */
- public Node getParentNode() {
- return this.parentNode;
- }
-
- /**
- */
- public String getPrefix() {
- return null;
- }
-
- /**
- * getPreviousSibling method
- * @return org.w3c.dom.Node
- */
- public Node getPreviousSibling() {
- return this.previousSibling;
- }
-
- /**
- */
- public String getSource() {
- if (this.flatNode == null)
- return new String();
- return this.flatNode.getText();
- }
-
- public IStructuredDocumentRegion getStartStructuredDocumentRegion() {
- return getFirstStructuredDocumentRegion();
- }
-
- /**
- * getStartOffset method
- * @return int
- */
- public int getStartOffset() {
- if (this.flatNode != null)
- return this.flatNode.getStart();
- NodeImpl prev = (NodeImpl) getPreviousSibling();
- if (prev != null)
- return prev.getEndOffset();
- Node parent = getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- ElementImpl element = (ElementImpl) parent;
- if (element.hasStartTag())
- return element.getStartEndOffset();
- return element.getStartOffset();
- }
- // final fallback to look into first child
- NodeImpl child = (NodeImpl) getFirstChild();
- while (child != null) {
- IStructuredDocumentRegion childStructuredDocumentRegion = child.getStructuredDocumentRegion();
- if (childStructuredDocumentRegion != null)
- return childStructuredDocumentRegion.getStart();
- child = (NodeImpl) child.getFirstChild();
- }
- return 0;
- }
-
- /**
- * all but attr return null
- */
- public ITextRegion getValueRegion() {
- return null;
- }
-
- /**
- */
- public String getValueSource() {
- return getNodeValue();
- }
-
- /**
- */
- public boolean hasAttributes() {
- return false;
- }
-
- /**
- * hasChildNodes method
- * @return boolean
- */
- public boolean hasChildNodes() {
- return false;
- }
-
- /**
- * hasProperties method
- * @return boolean
- */
- public boolean hasProperties() {
- return false;
- }
-
- /**
- * insertBefore method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param refChild org.w3c.dom.Node
- */
- public Node insertBefore(Node newChild, Node refChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String());
- }
-
- /**
- */
- public boolean isClosed() {
- return true;
- }
-
- /**
- * isContainer method
- * @return boolean
- */
- public boolean isContainer() {
- return false;
- }
-
- /**
- */
- public boolean isSupported(String feature, String version) {
- if (this.ownerDocument == null)
- return false;
- DOMImplementation impl = this.ownerDocument.getImplementation();
- if (impl == null)
- return false;
- return impl.hasFeature(feature, version);
- }
-
- /**
- * normalize method
- */
- public void normalize() {
- TextImpl prevText = null;
- for (Node child = getFirstChild(); child != null; child = child.getNextSibling()) {
- switch (child.getNodeType()) {
- case TEXT_NODE :
- {
- if (prevText == null) {
- prevText = (TextImpl) child;
- break;
- }
- Text text = (Text) child;
- removeChild(text);
- prevText.appendText(text);
- child = prevText;
- break;
- }
- case ELEMENT_NODE :
- {
- Element element = (Element) child;
- element.normalize();
- prevText = null;
- break;
- }
- default :
- prevText = null;
- break;
- }
- }
- }
-
- /**
- * notifyValueChanged method
- */
- protected void notifyValueChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
-
- syncDataEditableState();
-
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.valueChanged(this);
- }
-
- protected void syncDataEditableState() {
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (fDataEditable) {
- roc.unlockData(this);
- }
- else {
- roc.lockData(this);
- }
- }
-
- protected void notifyEditableChanged() {
- DocumentImpl document = (DocumentImpl) getContainerDocument();
- if (document == null)
- return;
- XMLModelImpl model = (XMLModelImpl) document.getModel();
- if (model == null)
- return;
- model.editableChanged(this);
- }
-
- /**
- * removeChild method
- * @return org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- public Node removeChild(Node oldChild) throws DOMException {
- throw new DOMException(DOMException.NOT_FOUND_ERR, new String());
- }
-
- /**
- * removeChildNodes method
- */
- public void removeChildNodes() {
- }
-
- /**
- * removeChildNodes method
- * @return org.w3c.dom.DocumentFragment
- * @param firstChild org.w3c.dom.Node
- * @param lastChild org.w3c.dom.Node
- */
- public DocumentFragment removeChildNodes(Node firstChild, Node lastChild) {
- return null;
- }
-
- /**
- * replaceChild method
- * @return org.w3c.dom.Node
- * @param newChild org.w3c.dom.Node
- * @param oldChild org.w3c.dom.Node
- */
- public Node replaceChild(Node newChild, Node oldChild) throws DOMException {
- throw new DOMException(DOMException.HIERARCHY_REQUEST_ERR, new String());
- }
-
- /**
- * Resets children values from IStructuredDocumentRegion.
- */
- void resetStructuredDocumentRegions() {
- for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) {
- child.resetStructuredDocumentRegions();
- }
- this.flatNode = null;
- }
-
- /**
- */
- void setStructuredDocumentRegion(IStructuredDocumentRegion flatNode) {
- this.flatNode = flatNode;
- }
-
- /**
- * setNextSibling method
- * @param nextSibling org.w3c.dom.Node
- */
- protected void setNextSibling(Node nextSibling) {
- this.nextSibling = (NodeImpl) nextSibling;
- }
-
- /**
- * setNodeValue method
- * @param nodeValue java.lang.String
- */
- public void setNodeValue(String nodeValue) throws DOMException {
- }
-
- /**
- * setOwnerDocument method
- * @param ownerDocument org.w3c.dom.Document
- */
- protected void setOwnerDocument(Document ownerDocument) {
- this.ownerDocument = (DocumentImpl) ownerDocument;
- }
-
- /**
- */
- protected void setOwnerDocument(Document ownerDocument, boolean deep) {
- this.ownerDocument = (DocumentImpl) ownerDocument;
-
- if (deep) {
- for (NodeImpl child = (NodeImpl) getFirstChild(); child != null; child = (NodeImpl) child.getNextSibling()) {
- child.setOwnerDocument(ownerDocument, deep);
- }
- }
- }
-
- /**
- * setParentNode method
- * @param parentNode org.w3c.dom.Node
- */
- protected void setParentNode(Node parentNode) {
- this.parentNode = (NodeImpl) parentNode;
- }
-
- /**
- */
- public void setPrefix(String prefix) throws DOMException {
- }
-
- /**
- * setPreviousSibling method
- * @param previousSibling org.w3c.dom.Node
- */
- protected void setPreviousSibling(Node previousSibling) {
- this.previousSibling = (NodeImpl) previousSibling;
- }
-
- /**
- */
- public void setSource(String source) throws InvalidCharacterException {
- // not supported
- }
-
- /**
- */
- public void setValueSource(String source) {
- setNodeValue(source);
- }
-
- /**
- * toString method
- * @return java.lang.String
- */
- public String toString() {
- return getNodeName();
- }
-
- public boolean isChildEditable() {
- return false;
- }
-
- public void setChildEditable(boolean editable) {
- // nop
- }
-
- public boolean isDataEditable() {
- if (!fDataEditable) {
- XMLModelImpl model = (XMLModelImpl) getModel();
- if (model != null && model.isReparsing()) {
- return true;
- }
- }
- return fDataEditable;
- }
-
- public void setDataEditable(boolean editable) {
- if (fDataEditable == editable) {
- return;
- }
-
- ReadOnlyController roc = ReadOnlyController.getInstance();
- if (editable) {
- roc.unlockData(this);
- }
- else {
- roc.lockData(this);
- }
-
- fDataEditable = editable;
-
- notifyEditableChanged();
- }
-
- public void setEditable(boolean editable, boolean deep) {
- if (deep) {
- XMLNode node = (XMLNode) getFirstChild();
- while (node != null) {
- node.setEditable(editable, deep);
- node = (XMLNode) node.getNextSibling();
- }
- }
- setChildEditable(editable);
- setDataEditable(editable);
- }
-
- private boolean fDataEditable = true;
-
- /**
- * @param s
- * @param tagName
- * @return
- */
- protected String createDOMExceptionMessage(short s, String tagName) {
- String result = null;
- // TODO: Should localize these messages, and provide /u escaped version of tagName
- result = lookupMessage(s) + " " + tagName; //$NON-NLS-1$
- return result;
- }
-
- /**
- * @param s
- * @return
- */
- private String lookupMessage(short s) {
- // TODO: make localized version
- String result = null;
- switch (s) {
- case DOMException.INVALID_CHARACTER_ERR :
- result = "INVALID_CHARACTER_ERR"; //$NON-NLS-1$
- break;
-
- default :
- result = new String();
- break;
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java
deleted file mode 100644
index 4c9dece..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeIteratorImpl.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.traversal.NodeFilter;
-import org.w3c.dom.traversal.NodeIterator;
-
-/**
- * NodeIteratorImpl class
- */
-public class NodeIteratorImpl implements NodeIterator {
-
- private Node rootNode = null;
- private Node nextNode = null;
- private int whatToShow = NodeFilter.SHOW_ALL;
- private NodeFilter filter = null;
-
- /**
- * NodeIteratorImpl constructor
- * @param rootNode org.w3c.dom.Node
- */
- NodeIteratorImpl(Node rootNode, int whatToShow, NodeFilter filter) {
- this.rootNode = rootNode;
- this.nextNode = rootNode;
- this.whatToShow = whatToShow;
- this.filter = filter;
- }
-
- /**
- */
- private final boolean acceptNode(Node node) {
- if (this.whatToShow != NodeFilter.SHOW_ALL) {
- if (node == null)
- return false;
- short nodeType = node.getNodeType();
- switch (this.whatToShow) {
- case NodeFilter.SHOW_ELEMENT :
- if (nodeType != Node.ELEMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ATTRIBUTE :
- if (nodeType != Node.ATTRIBUTE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_TEXT :
- if (nodeType != Node.TEXT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_CDATA_SECTION :
- if (nodeType != Node.CDATA_SECTION_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ENTITY_REFERENCE :
- if (nodeType != Node.ENTITY_REFERENCE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_ENTITY :
- if (nodeType != Node.ENTITY_NODE)
- return false;
- break;
- case NodeFilter.SHOW_PROCESSING_INSTRUCTION :
- if (nodeType != Node.PROCESSING_INSTRUCTION_NODE)
- return false;
- break;
- case NodeFilter.SHOW_COMMENT :
- if (nodeType != Node.COMMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT :
- if (nodeType != Node.DOCUMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT_TYPE :
- if (nodeType != Node.DOCUMENT_TYPE_NODE)
- return false;
- break;
- case NodeFilter.SHOW_DOCUMENT_FRAGMENT :
- if (nodeType != Node.DOCUMENT_FRAGMENT_NODE)
- return false;
- break;
- case NodeFilter.SHOW_NOTATION :
- if (nodeType != Node.NOTATION_NODE)
- return false;
- break;
- default :
- return false;
- }
- }
- if (this.filter != null) {
- return (this.filter.acceptNode(node) == NodeFilter.FILTER_ACCEPT);
- }
- return true;
- }
-
- /**
- * Detaches the <code>NodeIterator</code> from the set which it iterated
- * over, releasing any computational resources and placing the iterator
- * in the INVALID state. After <code>detach</code> has been invoked,
- * calls to <code>nextNode</code> or <code>previousNode</code> will
- * raise the exception INVALID_STATE_ERR.
- */
- public void detach() {
- this.rootNode = null;
- this.nextNode = null;
- this.filter = null;
- }
-
- /**
- * The value of this flag determines whether the children of entity
- * reference nodes are visible to the iterator. If false, they and
- * their descendants will be rejected. Note that this rejection takes
- * precedence over <code>whatToShow</code> and the filter. Also note
- * that this is currently the only situation where
- * <code>NodeIterators</code> may reject a complete subtree rather than
- * skipping individual nodes.
- * <br>
- * <br> To produce a view of the document that has entity references
- * expanded and does not expose the entity reference node itself, use
- * the <code>whatToShow</code> flags to hide the entity reference node
- * and set <code>expandEntityReferences</code> to true when creating the
- * iterator. To produce a view of the document that has entity reference
- * nodes but no entity expansion, use the <code>whatToShow</code> flags
- * to show the entity reference node and set
- * <code>expandEntityReferences</code> to false.
- */
- public boolean getExpandEntityReferences() {
- // not supported
- return false;
- }
-
- /**
- * The <code>NodeFilter</code> used to screen nodes.
- */
- public NodeFilter getFilter() {
- return this.filter;
- }
-
- /**
- */
- private final Node getNextNode() {
- if (this.nextNode == null)
- return null;
- Node oldNext = this.nextNode;
- Node child = this.nextNode.getFirstChild();
- if (child != null) {
- this.nextNode = child;
- return oldNext;
- }
- for (Node node = this.nextNode; node != null && node != this.rootNode; node = node.getParentNode()) {
- Node next = node.getNextSibling();
- if (next != null) {
- this.nextNode = next;
- return oldNext;
- }
- }
- this.nextNode = null;
- return oldNext;
- }
-
- /**
- */
- private final Node getPreviousNode() {
- if (this.nextNode == this.rootNode)
- return null;
- Node prev = null;
- if (this.nextNode == null) {
- prev = this.rootNode; // never null
- }
- else {
- prev = this.nextNode.getPreviousSibling();
- if (prev == null) {
- this.nextNode = this.nextNode.getParentNode();
- return this.nextNode;
- }
- }
- Node last = prev.getLastChild();
- while (last != null) {
- prev = last;
- last = prev.getLastChild();
- }
- this.nextNode = prev;
- return this.nextNode;
- }
-
- /**
- * The root node of the <code>NodeIterator</code>, as specified when it
- * was created.
- */
- public Node getRoot() {
- return this.rootNode;
- }
-
- /**
- * This attribute determines which node types are presented via the
- * iterator. The available set of constants is defined in the
- * <code>NodeFilter</code> interface. Nodes not accepted by
- * <code>whatToShow</code> will be skipped, but their children may still
- * be considered. Note that this skip takes precedence over the filter,
- * if any.
- */
- public int getWhatToShow() {
- return this.whatToShow;
- }
-
- /**
- * Returns the next node in the set and advances the position of the
- * iterator in the set. After a <code>NodeIterator</code> is created,
- * the first call to <code>nextNode()</code> returns the first node in
- * the set.
- * @return The next <code>Node</code> in the set being iterated over, or
- * <code>null</code> if there are no more members in that set.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if this method is called after the
- * <code>detach</code> method was invoked.
- */
- public Node nextNode() throws DOMException {
- for (Node node = getNextNode(); node != null; node = getNextNode()) {
- if (acceptNode(node))
- return node;
- }
- return null;
- }
-
- /**
- * Returns the previous node in the set and moves the position of the
- * <code>NodeIterator</code> backwards in the set.
- * @return The previous <code>Node</code> in the set being iterated over,
- * or <code>null</code> if there are no more members in that set.
- * @exception DOMException
- * INVALID_STATE_ERR: Raised if this method is called after the
- * <code>detach</code> method was invoked.
- */
- public Node previousNode() throws DOMException {
- for (Node node = getPreviousNode(); node != null; node = getPreviousNode()) {
- if (acceptNode(node))
- return node;
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java
deleted file mode 100644
index ee920ab..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NodeListImpl.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Vector;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * NodeListImpl class
- */
-public class NodeListImpl implements NodeList {
-
- private Vector nodes = null;
-
- /**
- * NodeListImpl constructor
- */
- public NodeListImpl() {
- super();
- }
-
- /**
- * appendNode method
- * @return org.w3c.dom.Node
- * @param node org.w3c.dom.Node
- */
- protected Node appendNode(Node node) {
- if (node == null)
- return null;
- if (this.nodes == null)
- this.nodes = new Vector();
- this.nodes.addElement(node);
- return node;
- }
-
- /**
- * getLength method
- * @return int
- */
- public int getLength() {
- if (this.nodes == null)
- return 0;
- return this.nodes.size();
- }
-
- /**
- */
- protected Node insertNode(Node node, int index) {
- if (node == null)
- return null;
- if (this.nodes == null || index >= this.nodes.size()) {
- return appendNode(node);
- }
- this.nodes.insertElementAt(node, index);
- return node;
- }
-
- /**
- * item method
- * @return org.w3c.dom.Node
- */
- public Node item(int index) {
- if (this.nodes == null)
- return null;
- if (index < 0 || index >= this.nodes.size())
- return null;
- return (Node) this.nodes.elementAt(index);
- }
-
- /**
- * removeNode method
- * @return org.w3c.dom.Node
- * @param index int
- */
- protected Node removeNode(int index) {
- if (this.nodes == null)
- return null; // no node
- if (index < 0 || index >= this.nodes.size())
- return null; // invalid parameter
-
- Node removed = (Node) this.nodes.elementAt(index);
- this.nodes.removeElementAt(index);
- return removed;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java
deleted file mode 100644
index 43e373c..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/NotationImpl.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.Notation;
-
-/**
- * NotationImpl class
- */
-public class NotationImpl extends NodeImpl implements Notation {
-
- private String name = null;
- private String publicId = null;
- private String systemId = null;
-
- /**
- * NotationImpl constructor
- */
- protected NotationImpl() {
- super();
- }
-
- /**
- * NotationImpl constructor
- * @param that NotationImpl
- */
- protected NotationImpl(NotationImpl that) {
- super(that);
-
- if (that != null) {
- this.name = that.name;
- this.publicId = that.publicId;
- this.systemId = that.systemId;
- }
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- NotationImpl cloned = new NotationImpl(this);
- return cloned;
- }
-
- /**
- * getNodeName method
- * @return java.lang.String
- */
- public String getNodeName() {
- if (this.name == null)
- return new String();
- return this.name;
- }
-
- /**
- * getNodeType method
- * @return short
- */
- public short getNodeType() {
- return NOTATION_NODE;
- }
-
- /**
- * getPublicId method
- * @return java.lang.String
- */
- public String getPublicId() {
- return this.publicId;
- }
-
- /**
- * getSystemId method
- * @return java.lang.String
- */
- public String getSystemId() {
- return this.systemId;
- }
-
- /**
- * setName method
- * @param name java.lang.String
- */
- protected void setName(String name) {
- this.name = name;
- }
-
- /**
- * setPublicId method
- * @param publicId java.lang.String
- */
- public void setPublicId(String publicId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
- this.publicId = publicId;
- }
-
- /**
- * setSystemId method
- * @param systemId java.lang.String
- */
- public void setSystemId(String systemId) {
- if (!isDataEditable()) {
- throw new DOMException(DOMException.NO_MODIFICATION_ALLOWED_ERR, new String());
- }
- this.systemId = systemId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java
deleted file mode 100644
index d613007..0000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/document/ProcessingInstructionImpl.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
-* Copyright (c) 2002 IBM Corporation and others.
-* All rights reserved. This program and the accompanying materials
-* are made available under the terms of the Common Public License v1.0
-* which accompanies this distribution, and is available at
-* http://www.eclipse.org/legal/cpl-v10.html
-*
-* Contributors:
-* IBM - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.xml.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.xml.core.jsp.model.parser.temp.XMLJSPRegionContexts;
-import org.eclipse.wst.xml.core.parser.XMLRegionContext;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-
-/**
- * ProcessingInstructionImpl class
- */
-public class ProcessingInstructionImpl extends NodeImpl implements XMLJSPRegionContexts, ProcessingInstruction {
-
- private String target = null;
- private String data = null;
-
- /**
- * Proces