Skip to main content

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

summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement')
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java110
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java107
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java135
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java230
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java84
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java65
-rw-r--r--bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java196
7 files changed, 0 insertions, 927 deletions
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java
deleted file mode 100644
index 3d8d4bfe5b..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementAdapter.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement;
-
-
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.commentelement.impl.CommentElementConfiguration;
-import org.eclipse.wst.xml.core.internal.document.TagAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-
-/**
- */
-public class CommentElementAdapter implements TagAdapter {
- private CommentElementConfiguration fConfiguration;
-
- private boolean fEndTag;
- private CommentElementHandler fHandler;
-
- public CommentElementAdapter(boolean isEndTag, CommentElementHandler handler) {
- fEndTag = isEndTag;
- fHandler = handler;
- }
-
- private String generateCommentClose(IDOMElement element) {
- return (element.isJSPTag()) ? "--%>" : "-->"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private String generateCommentOpen(IDOMElement element) {
- return (element.isJSPTag()) ? "<%--" : "<!--"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private CommentElementConfiguration getConfiguration() {
- return fConfiguration;
- }
-
- public String getEndTag(IDOMElement 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();
- }
-
- /**
- * @deprecated this should not be needed by anyone
- */
- public IPluginDescriptor getHandlerPluginDescriptor() {
- return fConfiguration.getHandlerPluginDescriptor();
- }
-
- public String getProperty(String name) {
- return getConfiguration().getProperty(name);
- }
-
- public String getStartTag(IDOMElement 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 boolean isAdapterForType(Object type) {
- return (type == CommentElementAdapter.class || type == TagAdapter.class);
- }
-
- public boolean isContainer() {
- return (!fHandler.isEmpty());
- }
-
- public boolean isEndTag() {
- return fEndTag;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- public void setConfiguration(CommentElementConfiguration configuration) {
- fConfiguration = configuration;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java
deleted file mode 100644
index 03d7f3a80f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/CommentElementHandler.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement;
-
-
-
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-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 &lt;startswith prefix=""/&gt; 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 (&lt;!-- or &lt;%--), suffix
- * (--&gt; or --%&gt;), 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=&quot;both&quot; 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 end tag for the passed
- * element. Do not generate comment prefix (&lt;!-- or &lt;%--) and suffix
- * (--&gt; or --%&gt;). XMLGenerator uses this method to generate XML/HTML
- * source for a comment element.
- *
- * @param element
- * the comment element
- * @return generated tag string
- */
- String generateEndTagContent(IDOMElement element);
-
- /**
- * This method generates the source text of the start tag for the passed
- * element. Do not generate comment prefix (&lt;!-- or &lt;%--) and suffix
- * (--&gt; or --%&gt;). XMLGenerator uses this method to generate XML/HTML
- * source for a comment element.
- *
- * @param element
- * the comment element
- * @return generated tag string
- */
- String generateStartTagContent(IDOMElement element);
-
- /**
- *
- * @param element
- * the element
- * @return boolean whether the element is comment element or not
- */
- boolean isCommentElement(IDOMElement element);
-
- /**
- *
- * @return boolean whether this element can have children or not
- */
- boolean isEmpty();
-
- /**
- * @return String
- */
- // String getElementPrefix();
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java
deleted file mode 100644
index d4b8391a08..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/BasicCommentElementHandler.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement.impl;
-
-
-
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.commentelement.util.CommentElementFactory;
-import org.eclipse.wst.xml.core.internal.commentelement.util.TagScanner;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.ISourceGenerator;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-
-
-/**
- */
-class BasicCommentElementHandler implements CommentElementHandler {
-
- private String elementName;
- private boolean isEmpty;
-
- 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)
- ((IDOMAttr) attr).setValueSource(attrValue);
- element.setAttributeNode(attr);
- }
- attrName = scanner.nextName();
- }
- }
- }
- return element;
- }
-
-
- public String generateEndTagContent(IDOMElement element) {
- if (isEmpty) {
- return null;
- }
- ISourceGenerator 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();
- }
-
- public String generateStartTagContent(IDOMElement element) {
- ISourceGenerator 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 boolean isCommentElement(IDOMElement element) {
- return (element != null && element.getTagName().equals(elementName)) ? true : false;
- }
-
- public boolean isEmpty() {
- return isEmpty;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java
deleted file mode 100644
index 1fe62da76a..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementConfiguration.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.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.internal.Logger;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementConfiguration {
- private Map fAttributes = null;
- private boolean fCustom;
- private IConfigurationElement fElement = null;
-
- private boolean fEmpty;
- private CommentElementHandler fHandler = null;
- private String fID = null;
- private boolean fJSPComment;
- private String[] fPrefix = null;
- private boolean fXMLComment;
-
- 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$
- }
-
- public boolean acceptJSPComment() {
- return fJSPComment;
- }
-
- public boolean acceptXMLComment() {
- return fXMLComment;
- }
-
- public Element createElement(Document document, String data, boolean isJSPTag) {
- IDOMElement element = (IDOMElement) getHandler().createElement(document, data, isJSPTag);
- if (element != null) {
- CommentElementAdapter adapter = (CommentElementAdapter) element.getAdapterFor(CommentElementAdapter.class);
- if (adapter != null) {
- adapter.setConfiguration(this);
- }
- }
- return element;
- }
-
- 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 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 (Exception 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 generateEndTagContent(IDOMElement element) {
- return null;
- }
-
- public String generateStartTagContent(IDOMElement element) {
- return null;
- }
-
-// removed in RC2, ro removed "unused" error/warning
-// public String getElementPrefix() {
-// return null;
-// }
-
- public boolean isCommentElement(IDOMElement element) {
- return false;
- }
-
- public boolean isEmpty() {
- return false;
- }
- };
- }
- }
- return fHandler;
- }
-
- 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(fElement.getDeclaringExtension().getNamespace());
- buf.append('.');
- buf.append(getProperty("elementname")); //$NON-NLS-1$
- fID = buf.toString();
- }
- }
- }
- return fID;
- }
-
- /**
- * @deprecated this should not be needed by anyone
- */
- public IPluginDescriptor getHandlerPluginDescriptor() {
- return fElement.getDeclaringExtension().getDeclaringPluginDescriptor();
- }
-
- 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 String getProperty(String name) {
- return (fAttributes != null) ? (String) fAttributes.get(name) : null;
- }
-
- private boolean isCustom() {
- return fCustom;
- }
-
- private boolean isEmpty() {
- return fEmpty;
- }
-
- void setupCommentElement(IDOMElement element) {
- element.setCommentTag(true);
- CommentElementAdapter adapter = new CommentElementAdapter(false, fHandler);
- adapter.setConfiguration(this);
- element.addAdapter(adapter);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java
deleted file mode 100644
index 8fc50b5523..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/impl/CommentElementRegistry.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement.impl;
-
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-
-/**
- */
-public class CommentElementRegistry {
-
- private static CommentElementRegistry fInstance = null;
-
- public synchronized static CommentElementRegistry getInstance() {
- if (fInstance == null) {
- fInstance = new CommentElementRegistry();
- }
- return fInstance;
- }
-
- private String EXTENSION_POINT_ID = "commentElementHandler"; //$NON-NLS-1$
- private CommentElementConfiguration[] fConfigurations = null;
-
- private String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- /**
- * Constructor for CommentElementRegistry.
- */
- private CommentElementRegistry() {
- super();
- }
-
- public CommentElementConfiguration[] getConfigurations() {
- if (fConfigurations == null) {
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.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(IDOMElement 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;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java
deleted file mode 100644
index 1351c4237f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/CommentElementFactory.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement.util;
-
-
-
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementAdapter;
-import org.eclipse.wst.xml.core.internal.commentelement.CommentElementHandler;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-
-/**
- */
-public class CommentElementFactory {
- public static final int IS_EMPTY = 4866;
- public static final int IS_END = 1808;
-
- public static final int IS_START = 28011;
-
- private Document fDocument;
- private CommentElementHandler fHandler;
- private boolean fJSPTag;
-
- /**
- * 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) {
- IDOMElement element = (IDOMElement) 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;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java b/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java
deleted file mode 100644
index 33d9cb102f..0000000000
--- a/bundles/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/commentelement/util/TagScanner.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.core.internal.commentelement.util;
-
-
-
-/**
- */
-public class TagScanner {
-
- /**
- */
- 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 int length = 0;
- private int memOffset = 0;
- private int offset = 0;
- private boolean oneLine = false;
-
- private String tag = null;
-
- /**
- */
- 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;
- }
-
- /**
- */
- private final boolean isEnd(char c) {
- return (this.oneLine && (c == '\r' || c == '\n'));
- }
-
- /**
- */
- 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 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);
- }
-}

Back to the top