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.html.core/src/org/eclipse/wst/html/core/internal/document')
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DOMStyleModelImpl.java67
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DocumentStyleImpl.java93
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/ElementStyleImpl.java69
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLConverter.java302
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapter.java266
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapterFactory.java170
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeConstants.java20
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeEntry.java136
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistry.java172
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistryReader.java107
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapter.java365
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapterFactory.java83
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaData.java28
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaDataAdapter.java301
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/TagScanner.java166
-rw-r--r--bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/UnknownTagAdapter.java82
16 files changed, 0 insertions, 2427 deletions
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DOMStyleModelImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DOMStyleModelImpl.java
deleted file mode 100644
index dc2de33bd1..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DOMStyleModelImpl.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 2, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.html.core.internal.document;
-
-import org.eclipse.wst.xml.core.internal.document.DOMModelImpl;
-import org.w3c.dom.Document;
-
-/**
- * @author davidw
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class DOMStyleModelImpl extends DOMModelImpl {
- public DOMStyleModelImpl() {
- // remember, the document is created in super constructor,
- // via internalCreateDocument
- super();
- }
-
- public void releaseFromEdit() {
- releaseStyleSheets();
- super.releaseFromEdit();
- }
-
- /**
- */
- public void releaseFromRead() {
- releaseStyleSheets();
- super.releaseFromRead();
- }
-
- private void releaseStyleSheets() {
- if (!isShared()) {
- Document doc = getDocument();
- if (doc instanceof DocumentStyleImpl) {
- ((DocumentStyleImpl) doc).releaseStyleSheets();
- }
- }
- }
-
- /**
- * createDocument method
- * @return org.w3c.dom.Document
- */
- protected Document internalCreateDocument() {
- DocumentStyleImpl document = new DocumentStyleImpl();
- document.setModel(this);
- return document;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DocumentStyleImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DocumentStyleImpl.java
deleted file mode 100644
index 8efb14b226..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/DocumentStyleImpl.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 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
- *******************************************************************************/
-/*
- * http://www.w3.org/TR/DOM-Level-2-Style/stylesheets.html#StyleSheets-StyleSheet-DocumentStyle
- */
-package org.eclipse.wst.html.core.internal.document;
-
-import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetListAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.css.CSSStyleDeclaration;
-import org.w3c.dom.css.DocumentCSS;
-import org.w3c.dom.stylesheets.StyleSheetList;
-
-/**
- * @author davidw
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public class DocumentStyleImpl extends DocumentImpl implements IDOMDocument, DocumentCSS {
- public DocumentStyleImpl() {
- super();
- }
-
- protected DocumentStyleImpl(DocumentImpl that) {
- super(that);
- }
-
- public CSSStyleDeclaration getOverrideStyle(Element element, String pseudoName) {
- INodeAdapter adapter = getAdapterFor(IStyleSheetListAdapter.class);
- if (adapter == null)
- return null;
- return ((IStyleSheetListAdapter) adapter).getOverrideStyle(element, pseudoName);
- }
-
- public StyleSheetList getStyleSheets() {
- INodeAdapter adapter = getAdapterFor(IStyleSheetListAdapter.class);
- if (adapter == null)
- return null;
- return ((IStyleSheetListAdapter) adapter).getStyleSheets();
- }
-
- protected void releaseStyleSheets() {
- INodeAdapter adapter = getExistingAdapter(IStyleSheetListAdapter.class);
- if (adapter == null)
- return;
- ((IStyleSheetListAdapter) adapter).releaseStyleSheets();
- }
-
- /**
- * createElement method
- * @return org.w3c.dom.Element
- * @param tagName java.lang.String
- */
- public Element createElement(String tagName) throws DOMException {
- checkTagNameValidity(tagName);
-
- ElementStyleImpl element = new ElementStyleImpl();
- element.setOwnerDocument(this);
- element.setTagName(tagName);
- return element;
- }
-
- /**
- * cloneNode method
- * @return org.w3c.dom.Node
- * @param deep boolean
- */
- public Node cloneNode(boolean deep) {
- DocumentStyleImpl cloned = new DocumentStyleImpl(this);
- if (deep)
- cloned.importChildNodes(this, true);
- return cloned;
- }
-
- protected void setModel(IDOMModel model) {
- super.setModel(model);
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/ElementStyleImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/ElementStyleImpl.java
deleted file mode 100644
index 7acc0fbfe8..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/ElementStyleImpl.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-/*
- * Created on Sep 2, 2003
- *
- * To change the template for this generated file go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-package org.eclipse.wst.html.core.internal.document;
-
-import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleDeclarationAdapter;
-import org.eclipse.wst.css.core.internal.provisional.adapters.IStyleSheetAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.xml.core.internal.document.ElementImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.w3c.dom.Document;
-import org.w3c.dom.css.CSSStyleDeclaration;
-import org.w3c.dom.css.ElementCSSInlineStyle;
-import org.w3c.dom.stylesheets.LinkStyle;
-import org.w3c.dom.stylesheets.StyleSheet;
-
-public class ElementStyleImpl extends ElementImpl implements IDOMElement, ElementCSSInlineStyle, LinkStyle {
- public ElementStyleImpl() {
- super();
- }
-
- public ElementStyleImpl(ElementImpl that) {
- super(that);
- }
-
- public StyleSheet getSheet() {
- INodeAdapter adapter = getAdapterFor(IStyleSheetAdapter.class);
- if (adapter == null)
- return null;
- if (!(adapter instanceof IStyleSheetAdapter))
- return null;
- return ((IStyleSheetAdapter) adapter).getSheet();
- }
-
- public CSSStyleDeclaration getStyle() {
- INodeAdapter adapter = getAdapterFor(IStyleDeclarationAdapter.class);
- if (adapter == null)
- return null;
- if (!(adapter instanceof IStyleDeclarationAdapter))
- return null;
- return ((IStyleDeclarationAdapter) adapter).getStyle();
- }
-
- protected void setOwnerDocument(Document ownerDocument) {
- super.setOwnerDocument(ownerDocument);
- }
-
- protected void setTagName(String tagName) {
- super.setTagName(tagName);
- }
-
- protected ElementImpl newInstance() {
- return new ElementStyleImpl(this);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLConverter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLConverter.java
deleted file mode 100644
index c1cfcc1502..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLConverter.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.html.core.internal.cleanup.HTMLCleanupProcessorImpl;
-import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupPreferences;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-import org.w3c.dom.Text;
-
-/**
- */
-public class HTMLConverter {
-
- /**
- */
- public HTMLConverter() {
- super();
-
- }
-
- public void cleanupModel(IDOMModel model) {
- if (model == null)
- return;
-
- HTMLCleanupProcessorImpl processor = new HTMLCleanupProcessorImpl();
- IStructuredCleanupPreferences pref = processor.getCleanupPreferences();
-
- // backup options
- boolean compressEmptyElementTags = pref.getCompressEmptyElementTags();
- boolean insertRequiredAttrs = pref.getInsertRequiredAttrs();
- boolean insertMissingTags = pref.getInsertMissingTags();
- boolean quoteAttrValues = pref.getQuoteAttrValues();
- boolean formatSource = pref.getFormatSource();
- int tagNameCase = pref.getTagNameCase();
- int attrNameCase = pref.getAttrNameCase();
-
- // setup options
- pref.setCompressEmptyElementTags(true);
- pref.setInsertRequiredAttrs(true);
- pref.setInsertMissingTags(true);
- pref.setQuoteAttrValues(true);
- pref.setFormatSource(false);
- if (model.getDocument().isXMLType()) { // XHTML
- pref.setTagNameCase(HTMLCorePreferenceNames.LOWER);
- pref.setAttrNameCase(HTMLCorePreferenceNames.LOWER);
- }
- else {
- pref.setTagNameCase(HTMLCorePreferenceNames.ASIS);
- pref.setAttrNameCase(HTMLCorePreferenceNames.ASIS);
- }
-
- processor.cleanupModel(model);
-
- // set back options
- pref.setCompressEmptyElementTags(compressEmptyElementTags);
- pref.setInsertRequiredAttrs(insertRequiredAttrs);
- pref.setInsertMissingTags(insertMissingTags);
- pref.setQuoteAttrValues(quoteAttrValues);
- pref.setFormatSource(formatSource);
- pref.setTagNameCase(tagNameCase);
- pref.setAttrNameCase(attrNameCase);
- }
-
- /**
- * declaratoin: "data" for XML declaration, such as "version=\"1.0\""
- * publicId: publicId for DOCTYPE declaration
- */
- public void convert(IDOMModel model, String declaration, String publicId) {
- if (model == null)
- return;
- setDeclaration(model, declaration, publicId);
- cleanupModel(model);
- }
-
- /**
- * declaratoin: "data" for XML declaration, such as "version=\"1.0\""
- * publicId: publicId for DOCTYPE declaration
- */
- public void convert(InputStream input, OutputStream output, String declaration, String publicId) throws UnsupportedEncodingException, IOException, CoreException {
- IDOMModel model = readModel(input);
- if (model == null)
- return;
- try {
- convert(model, declaration, publicId);
- writeModel(model, output);
- }
- finally {
- if (model != null)
- model.releaseFromEdit();
- }
- }
-
- /**
- * declaratoin: "data" for XML declaration, such as "version=\"1.0\""
- * publicId: publicId for DOCTYPE declaration
- */
- public void convert(IFile file, String declaration, String publicId) throws IOException, CoreException {
- IDOMModel model = readModel(file);
- if (model == null)
- return;
- try {
- convert(model, declaration, publicId);
- writeModel(model, file);
- }
- finally {
- if (model != null)
- model.releaseFromEdit();
- }
- }
-
- /**
- */
- private static void insertBreak(IDOMModel model, Node node) {
- if (model == null || node == null)
- return;
- if (node.getNodeType() == Node.TEXT_NODE)
- return;
-
- // get delimiter string
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument == null)
- return;
- String delim = structuredDocument.getLineDelimiter();
- if (delim == null || delim.length() == 0)
- return;
-
- Node parent = node.getParentNode();
- if (parent == null)
- return;
- Document document = node.getOwnerDocument();
- if (document == null)
- return;
- Text text = document.createTextNode(delim);
- parent.insertBefore(text, node);
- }
-
- /**
- */
- private IDOMModel readModel(InputStream input) throws IOException, UnsupportedEncodingException {
- if (input == null)
- return null;
- // create temporary model
- String id = input.toString() + ".html"; //$NON-NLS-1$
- IModelManager manager = StructuredModelManager.getModelManager();
- IStructuredModel model = manager.getModelForEdit(id, input, null);
- if (!(model instanceof IDOMModel)) {
- if (model != null)
- model.releaseFromEdit();
- return null;
- }
- return (IDOMModel) model;
- }
-
- /**
- */
- private IDOMModel readModel(IFile file) throws IOException, CoreException {
- if (file == null)
- return null;
- IModelManager manager = StructuredModelManager.getModelManager();
- IStructuredModel model = manager.getModelForEdit(file);
- if (!(model instanceof IDOMModel)) {
- if (model != null)
- model.releaseFromEdit();
- return null;
- }
- return (IDOMModel) model;
- }
-
- /**
- */
- public void setDeclaration(IDOMModel model, String declaration, String publicId) {
- if (model == null)
- return;
- IDOMDocument document = model.getDocument();
- if (document == null)
- return;
-
- try {
- model.aboutToChangeModel();
-
- ProcessingInstruction pi = null;
- Node child = document.getFirstChild();
- if (child != null && child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- String target = child.getNodeName();
- if (target != null && target.equals("xml")) { //$NON-NLS-1$
- pi = (ProcessingInstruction) child;
- child = child.getNextSibling();
- }
- }
- IDOMDocumentType docType = (IDOMDocumentType) document.getDoctype();
-
- if (declaration != null) {
- if (pi != null) {
- pi.setData(declaration);
- }
- else {
- pi = document.createProcessingInstruction("xml", declaration); //$NON-NLS-1$
- document.insertBefore(pi, child);
- insertBreak(model, child);
- }
- }
-
- if (publicId != null) {
- HTMLDocumentTypeEntry entry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId);
- String name = (entry != null ? entry.getName() : null);
- if (name == null || name.length() == 0)
- name = "HTML"; // default //$NON-NLS-1$
- if (docType != null) {
- if (!name.equals(docType.getName())) { // replace
- Node parent = docType.getParentNode();
- child = docType;
- docType = (IDOMDocumentType) document.createDoctype(name);
- parent.insertBefore(docType, child);
- parent.removeChild(child);
- }
- }
- else {
- docType = (IDOMDocumentType) document.createDoctype(name);
- document.insertBefore(docType, child);
- insertBreak(model, child);
- }
- docType.setPublicId(publicId);
- if (entry != null) {
- String systemId = entry.getSystemId();
- if (systemId != null)
- docType.setSystemId(systemId);
- String namespaceURI = entry.getNamespaceURI();
- if (namespaceURI != null) {
- Element element = document.getDocumentElement();
- if (element != null) {
- element.setAttribute("xmlns", namespaceURI); //$NON-NLS-1$
- }
- }
- }
- }
- }
- finally {
- model.changedModel();
- }
- }
-
- /**
- */
- private void writeModel(IDOMModel model, OutputStream output) throws UnsupportedEncodingException, IOException, CoreException {
- if (model == null || output == null)
- return;
- model.save();
- }
-
- /**
- */
- private void writeModel(IDOMModel model, IFile file) throws IOException, CoreException {
- if (model == null || file == null)
- return;
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument == null)
- return;
- //ByteArrayOutputStream output = null;
- ByteArrayInputStream input = null;
- try {
- //output = new
- // ByteArrayOutputStream(structuredDocument.getLength());
- model.save();
- //input = new ByteArrayInputStream(output.toByteArray());
- //file.setContents(input, true, true, null);
- }
- finally {
- // if (output != null)
- // output.close();
- if (input != null)
- input.close();
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapter.java
deleted file mode 100644
index d03900aab4..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapter.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.html.core.internal.contentproperties.HTMLContentProperties;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapterImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.DOMImplementation;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Node;
-
-/**
- */
-public class HTMLDocumentTypeAdapter extends DocumentTypeAdapterImpl implements HTMLDocumentTypeConstants {
-
- private HTMLDocumentTypeAdapterFactory fFactory = null;
- private HTMLDocumentTypeEntry entry = null;
- private boolean isXMLType = false;
- private final static String XML = "xml"; //$NON-NLS-1$
- private final static String XHTML = "xhtml"; //$NON-NLS-1$
- private final static String WML = "wml"; //$NON-NLS-1$
-
- /**
- */
- protected HTMLDocumentTypeAdapter() {
- super();
- }
-
- /**
- */
- protected HTMLDocumentTypeAdapter(IDOMDocument document, HTMLDocumentTypeAdapterFactory factory) {
- super(document);
-
- this.fFactory = factory;
-
- // initialize
- documentTypeChanged();
- }
-
- /**
- */
- private void documentTypeChanged() {
- IDOMDocument document = getDocument();
- if (document == null)
- return; // error
- IDOMModel model = document.getModel();
- if (model == null)
- return; // error
-
- IFile file = getFile(model);
-
- // find DOCTYPE delcaration and Public ID
- String publicId = null;
- String systemId = null;
- DocumentType newDocumentType = findDocumentType(document);
- if (newDocumentType != null) {
- publicId = newDocumentType.getPublicId();
- systemId = newDocumentType.getSystemId();
- }
- else {
- // lookup default set by contentsettings
- publicId = HTMLContentProperties.getProperty(HTMLContentProperties.DOCUMENT_TYPE, file, true);
- }
-
- // lookup DOCTYPE registry
- HTMLDocumentTypeEntry newEntry = null;
- if (publicId != null) {
- newEntry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId);
- }
- else if (systemId == null){
- newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML5);
- }
-
- boolean newXMLType = (newEntry != null ? newEntry.isXMLType() : false);
- boolean newWMLType = (newEntry != null ? newEntry.isWMLType() : false);
-
- if (!newXMLType) {
- // find XML declaration
- if (findXMLNode(document) != null) {
- newXMLType = true;
- }
-
- // check file extension
- if (file != null) {
- String ext = file.getFileExtension();
- if (ext != null && ext.equalsIgnoreCase(XHTML)) {
- newXMLType = true;
- }
-
- if (ext != null && ext.equalsIgnoreCase(WML)) {
- newXMLType = true;
- newWMLType = true;
- }
- }
-
- }
-
- if (newEntry == null) {
- // lookup system default
- if (newXMLType && newDocumentType == null) {
- // use default XHTML, if it's XML and no document type
- // declared
- if (newWMLType)
- newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_WML);
- else
- newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_XHTML);
-
- }
- else {
- newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML);
- }
- if (newEntry == null)
- return; // error
- }
-
- if (newDocumentType == null) {
- DocumentType oldDocumentType = getDocumentType();
- if (oldDocumentType == null || oldDocumentType.getName() != newEntry.getName()) {
- // create implicit DocumentType
- DOMImplementation impl = document.getImplementation();
- if (impl != null) {
- String name = newEntry.getName();
- publicId = newEntry.getPublicId();
- systemId = newEntry.getSystemId();
- newDocumentType = impl.createDocumentType(name, publicId, systemId);
- }
- }
- }
-
- boolean notify = false;
- if (this.entry != null) { // do not notify on initialization
- notify = (newEntry != this.entry || newXMLType != this.isXMLType);
- }
-
- if (newDocumentType != null)
- setDocumentType(newDocumentType);
- this.entry = newEntry;
- this.isXMLType = newXMLType;
-
- if (notify)
- notifyDocumentTypeChanged();
- }
-
- /**
- */
- private IDOMDocumentType findDocumentType(IDOMDocument document) {
- IDOMDocumentType documentType = (IDOMDocumentType) document.getDoctype();
- if (documentType != null && documentType.getExistingAdapter(DocumentTypeAdapter.class) == null) {
- // watch future changes
- documentType.addAdapter(this);
- }
- return documentType;
- }
-
- /**
- */
- private Node findXMLNode(Document document) {
- for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE)
- continue;
- String target = child.getNodeName();
- if (target != null && target.equals(XML)) {
- return child;
- }
- }
- return null;
- }
-
- /**
- */
- public int getAttrNameCase() {
- if (isXMLType())
- return super.getAttrNameCase(); // XHTML
- return this.fFactory.getAttrNameCase();
- }
-
- private IFile getFile(IStructuredModel model) {
- IFile result = null;
- String location = model.getBaseLocation();
- if (location != null) {
- IPath path = new Path(location);
- if (path.segmentCount() > 1) {
- result = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- }
- }
- return result;
- }
-
- /**
- */
- public int getTagNameCase() {
- if (isXMLType())
- return LOWER_CASE; // XHTML
- return this.fFactory.getTagNameCase();
- }
-
- /**
- */
- public boolean hasFeature(String feature) {
- if (feature == null)
- return false;
- if (feature.equals(HTML))
- return true;
- if (feature.equals(SSI))
- return true;
- if (feature.equals(FRAMESET)) {
- if (this.entry == null)
- return false;
- return this.entry.hasFrameset();
- }
- if (feature.equals(HTML5)) {
- if (this.entry == null)
- return false;
- return this.entry == HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML5);
- }
- return false;
- }
-
- /**
- */
- public boolean isXMLType() {
- return this.isXMLType;
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (notifier == null)
- return;
- if (notifier instanceof IDOMDocument) {
- if (eventType != INodeNotifier.STRUCTURE_CHANGED)
- return;
- }
- else {
- if (eventType != INodeNotifier.CHANGE)
- return;
- }
- documentTypeChanged();
- }
-
- /**
- */
- public void release() {
- super.release();
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapterFactory.java
deleted file mode 100644
index 3e15e1348b..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeAdapterFactory.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.html.core.internal.HTMLCorePlugin;
-import org.eclipse.wst.html.core.internal.preferences.HTMLCorePreferenceNames;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-
-/**
- */
-public class HTMLDocumentTypeAdapterFactory implements INodeAdapterFactory, Preferences.IPropertyChangeListener {
-
- private int tagNameCase = DocumentTypeAdapter.LOWER_CASE;
- private int attrNameCase = DocumentTypeAdapter.LOWER_CASE;
- private Preferences preferences = null;
-
- // for removal later on release()
- private HashMap fDoc2AdapterMap = new HashMap();
-
- /**
- */
- public HTMLDocumentTypeAdapterFactory() {
- super();
- this.preferences = HTMLCorePlugin.getDefault().getPluginPreferences();
-
- if (this.preferences != null) {
- updateCases(); // initialize
- this.preferences.addPropertyChangeListener(this);
- }
- }
-
- /**
- * Method that returns the adapter associated with the given object. It
- * may be a singleton or not ... depending on the needs of the
- * INodeAdapter ... but in general it is recommended for an adapter to be
- * stateless, so the efficiencies of a singleton can be gained.
- *
- * The implementation of this method should call addAdapter on the adapted
- * object with the correct instance of the adapter.
- */
- public INodeAdapter adapt(INodeNotifier notifier) {
- INodeAdapter result = null;
- // only adapt IDOMDocument
- if (notifier instanceof IDOMDocument) {
-
- // if already has an adapter, no need to recreate/initialize.
- // Note: this means if "doctype" for DOM changes,
- // theDocumentTypeAdatper for that DOM
- // should be removed (and released) and it will be re-created next
- // time required.
- DocumentTypeAdapter oldAdapter = (DocumentTypeAdapter) notifier.getExistingAdapter(DocumentTypeAdapter.class);
- if (oldAdapter != null) {
- result = oldAdapter;
- }
- else {
-
- // if there already was an adapter
- //if(fAdapter != null)
- // fAdapter.release();
-
- // note, the factory is included in this case to have a central place
- // to come back to for case preferences.
- result = new HTMLDocumentTypeAdapter((IDOMDocument) notifier, this);
- notifier.addAdapter(result);
-
- fDoc2AdapterMap.put(notifier, result);
- }
- }
- return result;
- }
-
- /**
- */
- public int getAttrNameCase() {
- return this.attrNameCase;
- }
-
- /**
- */
- public int getTagNameCase() {
- return this.tagNameCase;
- }
-
- /**
- */
- public boolean isFactoryForType(Object type) {
- return (type == DocumentTypeAdapter.class);
- }
-
- /**
- */
- public void propertyChange(Preferences.PropertyChangeEvent event) {
- if (event == null)
- return;
- String property = event.getProperty();
- if (property == null)
- return;
-
- if (property.equals(HTMLCorePreferenceNames.TAG_NAME_CASE) || property.equals(HTMLCorePreferenceNames.ATTR_NAME_CASE)) {
- updateCases();
- }
- }
-
- /**
- */
- private void updateCases() {
- this.tagNameCase = DocumentTypeAdapter.LOWER_CASE;
- this.attrNameCase = DocumentTypeAdapter.LOWER_CASE;
-
- if (this.preferences == null)
- return;
-
- int tagCase = this.preferences.getInt(HTMLCorePreferenceNames.TAG_NAME_CASE);
- if (tagCase == HTMLCorePreferenceNames.LOWER)
- this.tagNameCase = DocumentTypeAdapter.LOWER_CASE;
- else if (tagCase == HTMLCorePreferenceNames.UPPER)
- this.tagNameCase = DocumentTypeAdapter.UPPER_CASE;
-
- int attCase = this.preferences.getInt(HTMLCorePreferenceNames.ATTR_NAME_CASE);
- if (attCase == HTMLCorePreferenceNames.LOWER)
- this.attrNameCase = DocumentTypeAdapter.LOWER_CASE;
- else if (attCase == HTMLCorePreferenceNames.UPPER)
- this.tagNameCase = DocumentTypeAdapter.UPPER_CASE;
- }
-
- /**
- */
- public void release() {
-
- if(!fDoc2AdapterMap.isEmpty()) {
- Object[] docs = fDoc2AdapterMap.keySet().toArray();
- DocumentTypeAdapter adapter = null;
- for (int i = 0; i < docs.length; i++) {
- adapter = (DocumentTypeAdapter)fDoc2AdapterMap.get(docs[i]);
- adapter.release();
- ((IDOMDocument)docs[i]).removeAdapter(adapter);
- }
- fDoc2AdapterMap.clear();
- }
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=95960
- if (this.preferences != null) {
- this.preferences.removePropertyChangeListener(this);
- }
- }
-
- /**
- * Overriding copy method
- */
- public INodeAdapterFactory copy() {
- return new HTMLDocumentTypeAdapterFactory();
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeConstants.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeConstants.java
deleted file mode 100644
index 7aae3cffec..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeConstants.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2011 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-public interface HTMLDocumentTypeConstants {
-
- public final static String HTML = "HTML"; //$NON-NLS-1$
- public final static String FRAMESET = "FRAMESET"; //$NON-NLS-1$
- public final static String SSI = "SSI"; //$NON-NLS-1$
- String HTML5 = "HTML5"; //$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeEntry.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeEntry.java
deleted file mode 100644
index 83158e7b8d..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeEntry.java
+++ /dev/null
@@ -1,136 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-/**
- */
-public class HTMLDocumentTypeEntry {
-
- private String name;
- private String publicId;
- private String systemId;
- private String namespaceURI;
- private boolean isXMLType;
- private boolean isXHTMLType;
- private boolean isWMLType;
- private boolean hasFrameset;
- private String displayName;
- private boolean isDefaultXHTML;
- private boolean isDefaultWML;
- private static String XHTML_NAME = "html"; //$NON-NLS-1$
- private static String HTML_NAME = "HTML"; //$NON-NLS-1$
- private boolean useInternalModel = false;
-
- /**
- */
- private HTMLDocumentTypeEntry() {
- super();
- }
-
- /**
- */
- public HTMLDocumentTypeEntry(String name, String publicId, String systemId, String namespaceURI, boolean isXHTMLType, boolean hasFrameset, String displayName, boolean isDefaultXHTML, boolean isDefaultWML, boolean isWMLType) {
- this();
-
- if (name != null && name.length() > 0) {
- this.name = name;
- }
- else {
- if (isXMLType)
- this.name = XHTML_NAME;// need code for wml?
- else
- this.name = HTML_NAME;
- }
- this.publicId = publicId;
- this.systemId = systemId;
- this.namespaceURI = namespaceURI;
- this.isXMLType = isXHTMLType | isWMLType;
- this.hasFrameset = hasFrameset;
- this.displayName = displayName;
- this.isDefaultXHTML = isDefaultXHTML;
- this.isDefaultWML = isDefaultWML;
- this.isXHTMLType = isXHTMLType;
- this.isWMLType = isWMLType;
- }
-
- HTMLDocumentTypeEntry(String name, String publicId, String systemId, String namespaceURI, boolean isXHTMLType, boolean hasFrameset, String displayName, boolean isDefaultXHTML, boolean isDefaultWML, boolean isWMLType, boolean useInternalModel) {
- this(name, publicId, systemId, namespaceURI, isXHTMLType, hasFrameset, displayName, isDefaultXHTML, isDefaultWML, isWMLType);
- this.useInternalModel = useInternalModel;
- }
-
- /**
- */
- public final String getName() {
- return this.name;
- }
-
- /**
- */
- public final String getNamespaceURI() {
- return this.namespaceURI;
- }
-
- /**
- */
- public final String getPublicId() {
- return this.publicId;
- }
-
- /**
- */
- public final String getSystemId() {
- return this.systemId;
- }
-
- /**
- */
- public final boolean isXMLType() {
- return this.isXMLType;
- }
-
- /**
- */
- public final boolean hasFrameset() {
- return this.hasFrameset;
- }
-
- /**
- */
- public final String getDisplayName() {
- return this.displayName;
- }
-
- /**
- */
- public final boolean isDefaultXHTML() {
- return this.isDefaultXHTML;
- }
-
- public final boolean isDefaultWML() {
- return this.isDefaultWML;
- }
-
-
- public final boolean isXHTMLType() {
- return isXHTMLType;
- }
-
- public final boolean isWMLType() {
- return isWMLType;
- }
-
- public final boolean useInternalModel() {
- return useInternalModel;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistry.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistry.java
deleted file mode 100644
index 457558f22f..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistry.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Vector;
-
-public class HTMLDocumentTypeRegistry {
- static class HTMLDocumentTypeEntryComparator implements Comparator {
- static Collator delegate = Collator.getInstance();
-
- public int compare(Object o1, Object o2) {
- if (o1 instanceof HTMLDocumentTypeEntry && o2 instanceof HTMLDocumentTypeEntry) {
- if (((HTMLDocumentTypeEntry) o1).getDisplayName() != null && ((HTMLDocumentTypeEntry) o2).getDisplayName() != null) {
- return delegate.compare(((HTMLDocumentTypeEntry) o1).getDisplayName(), ((HTMLDocumentTypeEntry) o2).getDisplayName());
- }
- }
- return 0;
- }
- }
-
- private static HTMLDocumentTypeRegistry instance = null;
- private Hashtable entries = null;
- private HTMLDocumentTypeEntry defaultEntry = null;
- private HTMLDocumentTypeEntry defaultXHTMLEntry = null;
- private HTMLDocumentTypeEntry defaultWMLEntry = null;
- private HTMLDocumentTypeEntry defaultCHTMLEntry = null;
- private HTMLDocumentTypeEntry defaultHTML5Entry = null;
-
- final static int DEFAULT_HTML = 0;
- final static int DEFAULT_XHTML = 1;
- final static int DEFAULT_WML = 2;
- final static int DEFAULT_CHTML = 3;
- final static int DEFAULT_HTML5 = 4;
-
- public static final String CHTML_PUBLIC_ID = "-//W3C//DTD Compact HTML 1.0 Draft//EN";//$NON-NLS-1$
-
- /**
- */
- private HTMLDocumentTypeRegistry() {
- super();
-
- this.entries = new Hashtable();
- // HTML 4.01
- String name = "HTML";//$NON-NLS-1$
- String publicId = "-//W3C//DTD HTML 4.01 Transitional//EN";//$NON-NLS-1$
- String systemId = "http://www.w3.org/TR/html4/loose.dtd";//$NON-NLS-1$
- String displayName = "HTML 4.01 Transitional"; //$NON-NLS-1$
- this.defaultEntry = new HTMLDocumentTypeEntry(name, publicId, systemId, null, false, false, displayName, false, false, false, true);
- this.entries.put(publicId, this.defaultEntry);
- publicId = "-//W3C//DTD HTML 4.01//EN";//$NON-NLS-1$
- systemId = "http://www.w3.org/TR/html4/strict.dtd";//$NON-NLS-1$
- displayName = "HTML 4.01 Strict"; //$NON-NLS-1$
- this.entries.put(publicId, new HTMLDocumentTypeEntry(name, publicId, systemId, null, false, false, displayName, false, false, false, true));
- publicId = "-//W3C//DTD HTML 4.01 Frameset//EN";//$NON-NLS-1$
- systemId = "http://www.w3.org/TR/html4/frameset.dtd";//$NON-NLS-1$
- displayName = "HTML 4.01 Frameset"; //$NON-NLS-1$
- this.entries.put(publicId, new HTMLDocumentTypeEntry(name, publicId, systemId, null, false, true, displayName, false, false, false, true));
- // CHTML
- name = "HTML";//$NON-NLS-1$
- publicId = CHTML_PUBLIC_ID;
- displayName = "Compact HTML 1.0 Draft"; //$NON-NLS-1$
- this.defaultCHTMLEntry = new HTMLDocumentTypeEntry(name, publicId, null, null, false, false, displayName, false, false, false, true);
- this.entries.put(publicId, this.defaultCHTMLEntry);
-
- //HTML5
- name = "HTML5";//$NON-NLS-1$
- publicId = "";
- displayName = "HTML5"; //$NON-NLS-1$
- this.defaultHTML5Entry = new HTMLDocumentTypeEntry(name, publicId, null, null, false, false, displayName, false, false, false, true);
- this.entries.put(publicId, this.defaultHTML5Entry);
-
-
-
- HTMLDocumentTypeRegistryReader reader = new HTMLDocumentTypeRegistryReader();
- if (reader != null)
- reader.readRegistry(this);
- }
-
- /**
- */
- void regist(String pid, HTMLDocumentTypeEntry doctype) {
- if (pid == null || doctype == null)
- return;
- this.entries.put(pid, doctype);
- if (this.defaultXHTMLEntry == null) {
- if (doctype.isDefaultXHTML())
- this.defaultXHTMLEntry = doctype;
- }
- if (this.defaultWMLEntry == null) {
- if (doctype.isDefaultWML())
- this.defaultWMLEntry = doctype;
- }
- }
-
- /**
- *
- */
- public HTMLDocumentTypeEntry getDefaultEntry(int type) {
- HTMLDocumentTypeEntry entry = null;
- switch (type) {
- case DEFAULT_HTML5 :
- entry = this.defaultHTML5Entry;
- break;
- case DEFAULT_XHTML :
- entry = this.defaultXHTMLEntry;
- break;
- case DEFAULT_WML :
- entry = this.defaultWMLEntry;
- break;
- case DEFAULT_CHTML :
- entry = this.defaultCHTMLEntry;
- break;
- case DEFAULT_HTML :
- default :
- entry = this.defaultEntry;
- break;
- }
- return entry;
- }
-
- /**
- *
- */
- public HTMLDocumentTypeEntry getDefaultEntry() {
- return this.defaultEntry;
- }
-
- /**
- */
- public HTMLDocumentTypeEntry getXHTMLDefaultEntry() {
- return this.defaultXHTMLEntry;
- }
-
- /**
- */
- public Enumeration getEntries() {
- List values = new ArrayList(this.entries.values());
- Collections.sort(values, new HTMLDocumentTypeEntryComparator());
- return new Vector(values).elements();
- }
-
- /**
- */
- public HTMLDocumentTypeEntry getEntry(String publicId) {
- if (publicId == null)
- return null;
- return (HTMLDocumentTypeEntry) this.entries.get(publicId);
- }
-
- /**
- */
- public synchronized static HTMLDocumentTypeRegistry getInstance() {
- if (instance == null)
- instance = new HTMLDocumentTypeRegistry();
- return instance;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistryReader.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistryReader.java
deleted file mode 100644
index f419978fad..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLDocumentTypeRegistryReader.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-
-/**
- */
-class HTMLDocumentTypeRegistryReader {
-
- //
- private final static String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- private final static String EXTENSION_POINT_ID = "documentTypes"; //$NON-NLS-1$
- private final static String TAG_NAME = "documentType"; //$NON-NLS-1$
- private final static String ATT_PID = "publicID"; //$NON-NLS-1$
- private final static String ATT_SID = "systemID"; //$NON-NLS-1$
- private final static String ATT_IS_XHTML = "isXHTML"; //$NON-NLS-1$
- private final static String ATT_IS_WML = "isWML"; //$NON-NLS-1$
- private final static String ATT_HAS_FRAMESET = "hasFrameset"; //$NON-NLS-1$
- private final static String ATT_NSURI = "namespaceURI"; //$NON-NLS-1$
- private final static String ATT_ENAME = "elementName"; //$NON-NLS-1$
- private final static String ATT_DNAME = "displayName"; //$NON-NLS-1$
- private final static String ATT_IS_DEFAULT_XHTML = "defaultXHTML"; //$NON-NLS-1$
- private final static String ATT_IS_DEFAULT_WML = "defaultWML"; //$NON-NLS-1$
- private final static String ATV_TRUE = "true"; //$NON-NLS-1$
- private final static String ATV_NULL_STRING = ""; //$NON-NLS-1$
-
- /**
- */
- HTMLDocumentTypeRegistryReader() {
- super();
- }
-
- /**
- */
- void readRegistry(HTMLDocumentTypeRegistry reg) {
- if (reg == null)
- return;
- IExtensionRegistry registry = Platform.getExtensionRegistry();
- IExtensionPoint point = registry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- HTMLDocumentTypeEntry doctype = readElement(elements[i]);
- // null can be returned if there's an error reading the element
- if (doctype != null) {
- reg.regist(doctype.getPublicId(), doctype);
- }
- }
- }
- }
-
- /**
- */
- private HTMLDocumentTypeEntry readElement(IConfigurationElement element) {
- HTMLDocumentTypeEntry doctype = null;
- String pid = null;
- String sid = null;
- String nsuri = null;
- String root = null;
- boolean xhtml = true;
- boolean frameset = false;
- String dname = null;
- boolean defaultXhtml = false;
- boolean defaultWML = false;
- boolean isWML = false;
-
- if (element.getName().equals(TAG_NAME)) {
- pid = element.getAttribute(ATT_PID);
- // publicID attribute is mandatory.
- if (pid == null || pid.equals(ATV_NULL_STRING))
- return null;
-
- sid = element.getAttribute(ATT_SID);
- nsuri = element.getAttribute(ATT_NSURI);
- root = element.getAttribute(ATT_ENAME);
- xhtml = getBoolean(element, ATT_IS_XHTML);
- frameset = getBoolean(element, ATT_HAS_FRAMESET);
- dname = element.getAttribute(ATT_DNAME);
- defaultXhtml = getBoolean(element, ATT_IS_DEFAULT_XHTML);
- defaultWML = getBoolean(element, ATT_IS_DEFAULT_WML);
- isWML = getBoolean(element, ATT_IS_WML);
- doctype = new HTMLDocumentTypeEntry(root, pid, sid, nsuri, xhtml, frameset, dname, defaultXhtml, defaultWML, isWML);
- }
- return doctype;
- }
-
- /**
- */
- private boolean getBoolean(IConfigurationElement element, String att) {
- String value = element.getAttribute(att);
- if (value != null && value.equals(ATV_TRUE))
- return true;
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapter.java
deleted file mode 100644
index 4e7ddcb52b..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapter.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import org.eclipse.wst.html.core.internal.contentmodel.HTMLElementDeclaration;
-import org.eclipse.wst.html.core.internal.contentmodel.HTMLPropertyDeclaration;
-import org.eclipse.wst.html.core.internal.provisional.HTML40Namespace;
-import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.document.CMNodeUtil;
-import org.eclipse.wst.xml.core.internal.document.ModelParserAdapter;
-import org.eclipse.wst.xml.core.internal.document.TagAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * HTMLDocumentImpl class
- */
-public class HTMLModelParserAdapter implements ModelParserAdapter {
- /**
- * note: I made public, temparily, so could be used by JSPLoader
- */
- protected HTMLModelParserAdapter() {
- super();
- }
-
- private boolean shouldTerminateAt(CMElementDeclaration parent, CMElementDeclaration child) {
- if (!parent.supports(HTMLCMProperties.TERMINATORS))
- return false;
- java.util.Iterator i = (java.util.Iterator) parent.getProperty(HTMLCMProperties.TERMINATORS);
- if (i == null)
- return false;
- String nextName = child.getElementName();
- while (i.hasNext()) {
- // NOTE: CMElementDeclaration of child is not always HTMLCMElementDeclaration.
- // It might be one of based on DTD (for XHTML element). So, comparison must
- // be performed ignoring case.
- // -- 3/20/2002
- String terminator = (String) i.next();
- if (terminator == null)
- continue;
- if (nextName.equalsIgnoreCase(terminator))
- return true;
- }
- return false;
- }
-
- public boolean isEndTagOmissible(Element element) {
- CMElementDeclaration dec = CMNodeUtil.getElementDeclaration(element);
- if (dec == null || !(dec instanceof HTMLPropertyDeclaration))
- return false;
- int type = ((HTMLPropertyDeclaration)dec ).getOmitType();
- return type == HTMLElementDeclaration.OMIT_BOTH || type == HTMLElementDeclaration.OMIT_END || type == HTMLElementDeclaration.OMIT_END_DEFAULT || type == HTMLElementDeclaration.OMIT_END_MUST;
- }
-
- /**
- */
- public boolean canContain(Element element, Node child) {
- if (element == null || child == null)
- return false;
- IDOMElement impl = (IDOMElement) element;
-
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- if (!impl.isGlobalTag())
- return true; // non HTML tag
- IDOMElement childElement = (IDOMElement) child;
-
- CMElementDeclaration myDec = CMNodeUtil.getElementDeclaration(element);
- if (myDec == null)
- return true;
- //if (!(myDec instanceof HTMLElementDeclaration)) return true;
- if (myDec.getContentType() == CMElementDeclaration.EMPTY)
- return false;
-
- if (!childElement.isGlobalTag())
- return true; // non HTML tag
- CMElementDeclaration childDec = CMNodeUtil.getElementDeclaration(childElement);
- if (childDec == null)
- return true;
- //if (!(childDec instanceof HTMLElementDeclaration)) return true;
-
- if (myDec instanceof HTMLElementDeclaration) {
- if (((Boolean) ((HTMLElementDeclaration) myDec).getProperty(HTMLCMProperties.IS_JSP)).booleanValue())
- return true;
- }
- if (shouldTerminateAt(myDec, childDec) && !isValidChild(myDec, childDec)) {
- return false;
- }
-
- String tagName = impl.getTagName();
- if (tagName == null)
- return true;
- String childName = childElement.getTagName();
- if (childName == null)
- return true;
- if (!impl.hasStartTag() && !impl.hasEndTag()) {
- // implicit element
- if (tagName.equalsIgnoreCase(childElement.getTagName()))
- return false;
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.HEAD)) {
- if (!childName.equalsIgnoreCase(HTML40Namespace.ElementName.META) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.TITLE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.LINK) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.STYLE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.BASE) && !childName.equalsIgnoreCase(HTML40Namespace.ElementName.ISINDEX)) {
- return false;
- }
- }
-
- Node parent = element.getParentNode();
- if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement parentElement = (IDOMElement) parent;
- if (!parentElement.hasStartTag() && !parentElement.hasEndTag()) {
- if (!canContain(parentElement, child))
- return false;
- }
- }
- return true;
- }
-
- // contexual termination for TABLE content tags
- boolean isTableContent = false;
- if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT)) {
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE))
- return true;
- isTableContent = true;
- }
- else if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TR)) {
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE))
- return true;
- isTableContent = true;
- }
- else if (childName.equalsIgnoreCase(HTML40Namespace.ElementName.TD) || childName.equalsIgnoreCase(HTML40Namespace.ElementName.TH)) {
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TR) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TBODY) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.THEAD) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TFOOT) || tagName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE))
- return true;
- isTableContent = true;
- }
- if (isTableContent) {
- // TABLE content tags should terminate non TABLE content tags,
- // if in TABLE
- for (Node parent = element.getParentNode(); parent != null; parent = parent.getParentNode()) {
- if (parent.getNodeType() != Node.ELEMENT_NODE)
- break;
- IDOMElement parentElement = (IDOMElement) parent;
- String parentName = parentElement.getTagName();
- if (parentName == null)
- continue;
- if (parentName.equalsIgnoreCase(HTML40Namespace.ElementName.TABLE))
- return false;
- }
- }
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.EMBED)) {
- if (!childName.equalsIgnoreCase(HTML40Namespace.ElementName.NOEMBED))
- return false;
- }
- }
- else if (child.getNodeType() == Node.TEXT_NODE) {
- String tagName = impl.getTagName();
- if (tagName != null && tagName.equalsIgnoreCase(HTML40Namespace.ElementName.EMBED)) {
- IDOMText text = (IDOMText) child;
- if (!text.isElementContentWhitespace())
- return false;
- }
- }
- else if (child.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- if (impl.isImplicitTag())
- return false;
- }
-
- return true;
- }
-
- /**
- */
- public boolean canBeImplicitTag(Element element) {
- return false;
- }
-
- /**
- */
- public boolean canBeImplicitTag(Element element, Node child) {
- return false;
- }
-
- /**
- */
- public Element createCommentElement(Document document, String data, boolean isJSPTag) {
- if (document == null || data == null || data.length() == 0)
- return null;
-
- return createMetaElement(document, data, isJSPTag);
- }
-
- /**
- * This routine create an implicit Element for given parent and child,
- * such as HTML, BODY, HEAD, and TBODY for HTML document.
- */
- public Element createImplicitElement(Document document, Node parent, Node child) {
- return null;
- }
-
- /**
- */
- private Element createMetaElement(Document document, String data, boolean isJSPTag) {
- if (data == null || data.length() == 0)
- return null;
-
- TagScanner scanner = new TagScanner(data, 0, true); // one line
- String name = scanner.nextName();
- if (name == null || !name.equalsIgnoreCase(MetaData.METADATA))
- return null;
-
- String type = null;
- boolean isStartSpan = false;
- boolean isEndSpan = false;
- name = scanner.nextName();
- while (name != null) {
- String value = scanner.nextValue();
- if (name.equalsIgnoreCase(MetaData.TYPE)) {
- if (value == null)
- return null;
- if (value.equalsIgnoreCase(MetaData.DESIGNER_CONTROL)) {
- type = MetaData.DESIGNER_CONTROL;
- }
- else if (value.equalsIgnoreCase(MetaData.DYNAMIC_DATA)) {
- type = MetaData.DYNAMIC_DATA;
- }
- else if (value.equalsIgnoreCase(MetaData.AUTHOR_TIME_VISUAL)) {
- type = MetaData.AUTHOR_TIME_VISUAL;
- }
- else if (value.equalsIgnoreCase(MetaData.ANNOTATION)) {
- type = MetaData.ANNOTATION;
- }
- else {
- return null;
- }
- }
- else if (name.equalsIgnoreCase(MetaData.STARTSPAN)) {
- isStartSpan = true;
- }
- else if (name.equalsIgnoreCase(MetaData.ENDSPAN)) {
- if (!isStartSpan)
- isEndSpan = true;
- }
- name = scanner.nextName();
- }
- if (type == null)
- return null;
- if (!isStartSpan && !isEndSpan)
- return null;
- String metaData = null;
- int offset = scanner.getNextOffset(); // skip new line
- if (offset < data.length())
- metaData = data.substring(offset);
- if (metaData == null)
- metaData = new String();
-
- IDOMElement element = (IDOMElement) document.createElement(MetaData.PREFIX + type);
-
- MetaDataAdapter adapter = new MetaDataAdapter(type);
- if (isStartSpan) {
- if (metaData != null)
- adapter.setData(metaData);
- }
- else {
- if (metaData != null)
- adapter.setEndData(metaData);
- }
- element.addAdapter(adapter);
- adapter.setElement(element);
- element.setJSPTag(isJSPTag);
-
- return element;
- }
-
- /**
- */
- public String getFindRootName(String tagName) {
- if (tagName == null)
- return null;
- // tag matching should not beyond TABLE tag except BODY tag
- if (tagName.equalsIgnoreCase(HTML40Namespace.ElementName.BODY))
- return null;
- return HTML40Namespace.ElementName.TABLE;
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == ModelParserAdapter.class);
- }
-
- /**
- */
- public boolean isEndTag(IDOMElement element) {
- TagAdapter adapter = (TagAdapter) element.getExistingAdapter(TagAdapter.class);
- if (adapter != null)
- return adapter.isEndTag();
- return element.isEndTag();
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // do nothing on notifiy change
- // TODO: this means good candidate for regular platform adapter
- }
-
- private static boolean isValidChild(CMElementDeclaration parent, CMElementDeclaration child) {
- if (parent == null || child == null)
- return false;
- CMContent content = parent.getContent();
- if (content == null)
- return false;
- return isChild(content, child);
- }
-
- /**
- */
- private static boolean isChild(CMContent content, CMElementDeclaration target) {
- switch (content.getNodeType()) {
- case CMNode.ELEMENT_DECLARATION :
- return isSameDeclaration((CMElementDeclaration) content, target);
- case CMNode.GROUP :
- CMNodeList children = ((CMGroup) content).getChildNodes();
- for (int i = 0; i < children.getLength(); i++) {
- CMNode child = children.item(i);
- switch (child.getNodeType()) {
- case CMNode.ELEMENT_DECLARATION :
- if (isSameDeclaration((CMElementDeclaration) child, target))
- return true;
- continue; // Go next child.
- case CMNode.GROUP :
- if (isChild((CMContent) child, target))
- return true;
- continue; // Go next child.
- default :
- continue; // Go next child.
- }
- }
- }
- return false;
- }
-
- /**
- */
- private static boolean isSameDeclaration(CMElementDeclaration aDec, CMElementDeclaration otherDec) {
- return aDec.getElementName() == otherDec.getElementName();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapterFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapterFactory.java
deleted file mode 100644
index 98765e8d3b..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/HTMLModelParserAdapterFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.document.ModelParserAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-
-/**
- */
-public class HTMLModelParserAdapterFactory implements INodeAdapterFactory {
-
- private static HTMLModelParserAdapterFactory instance = null;
-
- /**
- */
- private HTMLModelParserAdapterFactory() {
- super();
- }
-
- /**
- * Method that returns the adapter associated with the given object. It
- * may be a singleton or not ... depending on the needs of the
- * INodeAdapter ... but in general it is recommended for an adapter to be
- * stateless, so the efficiencies of a singleton can be gained.
- *
- * The implementation of this method should call addAdapter on the adapted
- * object with the correct instance of the adapter.
- */
- public INodeAdapter adapt(INodeNotifier notifier) {
- INodeAdapter adapter = null;
- if (notifier != null) {
- if (notifier instanceof IDOMDocument) {
- adapter = notifier.getExistingAdapter(ModelParserAdapter.class);
- if (adapter == null) {
- adapter = new HTMLModelParserAdapter();
- notifier.addAdapter(adapter);
- }
- }
- }
- return adapter;
-
- }
-
- /**
- */
- public synchronized static HTMLModelParserAdapterFactory getInstance() {
- if (instance == null)
- instance = new HTMLModelParserAdapterFactory();
- return instance;
- }
-
- /**
- */
- public boolean isFactoryForType(Object type) {
- return (type == ModelParserAdapter.class);
- }
-
- /**
- */
- public void release() {
- // no state to cleanup
- }
-
- /**
- * Overriding copy method
- */
- public INodeAdapterFactory copy() {
- return getInstance();
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaData.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaData.java
deleted file mode 100644
index a05758c072..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaData.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-/**
- */
-public interface MetaData {
-
- static final String METADATA = "METADATA";//$NON-NLS-1$
- static final String TYPE = "type";//$NON-NLS-1$
- static final String STARTSPAN = "startspan";//$NON-NLS-1$
- static final String ENDSPAN = "endspan";//$NON-NLS-1$
- static final String DESIGNER_CONTROL = "DesignerControl";//$NON-NLS-1$
- static final String DYNAMIC_DATA = "DynamicData";//$NON-NLS-1$
- static final String AUTHOR_TIME_VISUAL = "AuthorTimeVisual";//$NON-NLS-1$
- static final String ANNOTATION = "Annotation";//$NON-NLS-1$
- static final String PREFIX = "METADATA:";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaDataAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaDataAdapter.java
deleted file mode 100644
index 9b8596e610..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/MetaDataAdapter.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.document.TagAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-/**
- */
-public class MetaDataAdapter implements TagAdapter, MetaData {
-
- private IDOMElement element = null;
- private String type = null;
- private String data = null;
- private String endData = null;
-
- /**
- */
- public MetaDataAdapter(String type) {
- super();
-
- if (type != null) {
- if (type.equals(ANNOTATION)) {
- this.type = ANNOTATION;
- }
- else if (type.equals(AUTHOR_TIME_VISUAL)) {
- this.type = AUTHOR_TIME_VISUAL;
- }
- else {
- this.type = type;
- }
- }
- }
-
- /**
- */
- private String getData(IStructuredDocumentRegion flatNode) {
- if (flatNode == null)
- return null;
- ITextRegionList regions = flatNode.getRegions();
- if (regions == null)
- return null;
-
- String data = null;
- Iterator e = regions.iterator();
- while (e.hasNext()) {
- ITextRegion region = (ITextRegion) e.next();
- String regionType = region.getType();
- if (isCommentText(regionType)) {
- data = flatNode.getText(region);
- break;
- }
- }
- if (data == null)
- return null;
- int length = data.length();
- int offset = 0;
- for (; offset < length; offset++) {
- char c = data.charAt(offset);
- if (c == '\r' || c == '\n') {
- offset++;
- break;
- }
- }
- for (; offset < length; offset++) {
- char c = data.charAt(offset);
- if (c != '\r' && c != '\n') {
- break;
- }
- }
- return data.substring(offset);
- }
-
- private boolean isCommentText(String regionType) {
- boolean result = false;
- result = isDOMComment(regionType) || isNestedContentComment(regionType);
- return result;
- }
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
-
- private boolean isNestedContentComment(String regionType) {
- final String JSP_COMMENT_TEXT = "JSP_COMMENT_TEXT"; //$NON-NLS-1$
- return regionType.equals(JSP_COMMENT_TEXT);
- }
-
- private boolean isDOMComment(String regionType) {
- return regionType == DOMRegionContext.XML_COMMENT_TEXT;
- }
-
- public String getData() {
- if (this.element == null)
- return null;
- IStructuredDocumentRegion flatNode = this.element.getStartStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- if (this.data != null)
- return this.data;
- return getData(flatNode);
- }
-
- /**
- */
- private String getDelimiter(IDOMModel model) {
- String delim = null;
- if (model != null) {
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument != null)
- delim = structuredDocument.getLineDelimiter();
- }
- if (delim == null)
- delim = "\r\n";//$NON-NLS-1$
- return delim;
- }
-
- /**
- */
- public String getEndData() {
- if (this.element == null)
- return null;
- IStructuredDocumentRegion flatNode = this.element.getEndStructuredDocumentRegion();
- if (flatNode == null)
- return null;
- if (this.endData != null)
- return this.endData;
- return getData(flatNode);
- }
-
- /**
- */
- public String getEndTag(IDOMElement element) {
- StringBuffer buffer = new StringBuffer();
- if (element.isJSPTag())
- buffer.append("<%--");//$NON-NLS-1$
- else
- buffer.append("<!--");//$NON-NLS-1$
- buffer.append(METADATA);
- buffer.append(' ');
- buffer.append(TYPE);
- buffer.append("=\"");//$NON-NLS-1$
- buffer.append(this.type);
- buffer.append("\" ");//$NON-NLS-1$
- buffer.append(MetaData.ENDSPAN);
- String data = getEndData();
- if (data != null && data.length() > 0) {
- String delim = getDelimiter(element.getModel());
- buffer.append(delim);
- buffer.append(data);
- buffer.append(delim);
- }
- if (element.isJSPTag())
- buffer.append("--%>");//$NON-NLS-1$
- else
- buffer.append("-->");//$NON-NLS-1$
-
- return buffer.toString();
- }
-
- /**
- */
- public String getStartTag(IDOMElement element) {
- StringBuffer buffer = new StringBuffer();
- if (element.isJSPTag())
- buffer.append("<%--");//$NON-NLS-1$
- else
- buffer.append("<!--");//$NON-NLS-1$
- buffer.append(METADATA);
- buffer.append(' ');
- buffer.append(TYPE);
- buffer.append("=\"");//$NON-NLS-1$
- buffer.append(this.type);
- buffer.append("\" ");//$NON-NLS-1$
- buffer.append(MetaData.STARTSPAN);
- String data = getData();
- if (data != null && data.length() > 0) {
- String delim = getDelimiter(element.getModel());
- buffer.append(delim);
- buffer.append(data);
- buffer.append(delim);
- }
- if (element.isJSPTag())
- buffer.append("--%>");//$NON-NLS-1$
- else
- buffer.append("-->");//$NON-NLS-1$
-
- return buffer.toString();
- }
-
- /**
- */
- public String getType() {
- return this.type;
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == TagAdapter.class || type == MetaDataAdapter.class);
- }
-
- /**
- */
- public boolean isEndTag() {
- if (this.element == null)
- return false;
- if (this.element.hasStartTag())
- return false;
- if (this.element.hasEndTag())
- return true;
- if (this.data != null)
- return false;
- return (this.endData != null);
- }
-
- /**
- */
- public boolean isRuntimeContainer() {
- return (this.type == ANNOTATION || this.type == AUTHOR_TIME_VISUAL);
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- /**
- */
- public void setData(String data) {
- this.data = data;
-
- if (this.element != null)
- this.element.notifyStartTagChanged();
- }
-
- /**
- */
- public void setEndData(String data) {
- this.endData = data;
-
- if (this.element != null)
- this.element.notifyEndTagChanged();
- }
-
- /**
- */
- public void setElement(IDOMElement element) {
- this.element = element;
-
- if (this.element != null) {
- this.element.setCommentTag(true);
- if (this.type != MetaData.ANNOTATION) {
- this.element.setJSPTag(true);
- }
- }
- }
-
- /**
- */
- public void setRuntimeSource(String source) {
- if (source == null)
- return;
- if (this.element == null)
- return;
- if (isRuntimeContainer())
- return;
-
- IDOMModel model = this.element.getModel();
- if (model == null)
- return;
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- if (structuredDocument == null)
- return;
- int offset = this.element.getStartEndOffset();
- int end = this.element.getEndStartOffset();
- int length = end - offset;
- structuredDocument.replaceText(model, offset, length, source);
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/TagScanner.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/TagScanner.java
deleted file mode 100644
index 4cbd5096b2..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/TagScanner.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-/**
- */
-class TagScanner {
-
- private String tag = null;
- private int offset = 0;
- private int length = 0;
- private boolean oneLine = false;
-
- /**
- */
- TagScanner(String tag, int offset) {
- super();
-
- this.tag = tag;
- this.offset = offset;
- if (tag != null)
- this.length = tag.length();
- }
-
- /**
- */
- TagScanner(String tag, int offset, boolean oneLine) {
- this(tag, offset);
-
- this.oneLine = oneLine;
- }
-
- /**
- */
- int getNextOffset() {
- for (; this.offset < this.length; this.offset++) {
- char c = this.tag.charAt(this.offset);
- if (!isEnd(c))
- break;
- }
- return this.offset;
- }
-
- /**
- */
- int getOffset() {
- return this.offset;
- }
-
- /**
- */
- 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;
- }
-
- /**
- */
- 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;
-
- return this.tag.substring(nameOffset, this.offset);
- }
-
- /**
- */
- 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;
-
- return this.tag.substring(valueOffset, valueEnd);
- }
-}
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/UnknownTagAdapter.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/UnknownTagAdapter.java
deleted file mode 100644
index ec6053fe0c..0000000000
--- a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/document/UnknownTagAdapter.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.html.core.internal.document;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.xml.core.internal.document.TagAdapter;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-
-/**
- */
-public class UnknownTagAdapter implements TagAdapter {
-
- private String startTag = null;
- private String endTag = null;
-
- /**
- */
- public UnknownTagAdapter() {
- super();
- }
-
- /**
- */
- public String getEndTag(IDOMElement element) {
- String tag = null;
- if (this.endTag != null) {
- tag = this.endTag;
- this.endTag = null;
- }
- return tag;
- }
-
- /**
- */
- public String getStartTag(IDOMElement element) {
- String tag = null;
- if (this.startTag != null) {
- tag = this.startTag;
- this.startTag = null;
- }
- return tag;
- }
-
- /**
- */
- public boolean isAdapterForType(Object type) {
- return (type == TagAdapter.class);
- }
-
- /**
- */
- public boolean isEndTag() {
- return false;
- }
-
- /**
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- /**
- */
- public void setEndTag(String endTag) {
- this.endTag = endTag;
- }
-
- /**
- */
- public void setStartTag(String startTag) {
- this.startTag = startTag;
- }
-}

Back to the top