diff options
Diffstat (limited to 'bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd')
59 files changed, 0 insertions, 8828 deletions
diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Attribute.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Attribute.java deleted file mode 100644 index 5dd9fe5c49..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Attribute.java +++ /dev/null @@ -1,376 +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.dtd.core.internal; - -import java.util.Hashtable; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -// base class for an Element's contentmodel -public class Attribute extends DTDNode { - - public static final String CDATA = DTDCoreMessages._UI_CHARACTER_DATA_DESC; //$NON-NLS-1$ - public static final String ENTITIES = DTDCoreMessages._UI_ENTITY_NAMES_DESC; //$NON-NLS-1$ - public static final String ENTITY = DTDCoreMessages._UI_ENTITY_NAME_DESC; //$NON-NLS-1$ - public static final String ENUMERATED_NAME = DTDCoreMessages._UI_ENUM_NAME_TOKENS_DESC; //$NON-NLS-1$ - public static final String ENUMERATED_NOTATION = DTDCoreMessages._UI_ENUM_NOTATION_DESC; //$NON-NLS-1$ - public static final String FIXED = "#FIXED"; //$NON-NLS-1$ - public static final String ID = DTDCoreMessages._UI_IDENTIFIER_DESC; //$NON-NLS-1$ - public static final String IDREF = DTDCoreMessages._UI_ID_REFERENCE_DESC; //$NON-NLS-1$ - public static final String IDREFS = DTDCoreMessages._UI_ID_REFERENCES_DESC; //$NON-NLS-1$ - - public static final String IMPLIED = "#IMPLIED"; //$NON-NLS-1$ - public static final String NMTOKEN = DTDCoreMessages._UI_NAME_TOKEN_DESC; //$NON-NLS-1$ - public static final String NMTOKENS = DTDCoreMessages._UI_NAME_TOKENS_DESC; //$NON-NLS-1$ - public static final String REQUIRED = "#REQUIRED"; //$NON-NLS-1$ - - protected static Hashtable typeHash = new Hashtable(); - - public static final String[] types = {CDATA, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS, ENUMERATED_NAME, ENUMERATED_NOTATION}; - - { - typeHash.put(DTDRegionTypes.CDATA_KEYWORD, CDATA); - typeHash.put(DTDRegionTypes.ID_KEYWORD, ID); - typeHash.put(DTDRegionTypes.IDREF_KEYWORD, IDREF); - typeHash.put(DTDRegionTypes.IDREFS_KEYWORD, IDREFS); - typeHash.put(DTDRegionTypes.ENTITY_KEYWORD, ENTITY); - typeHash.put(DTDRegionTypes.ENTITIES_KEYWORD, ENTITIES); - typeHash.put(DTDRegionTypes.NMTOKEN_KEYWORD, NMTOKEN); - typeHash.put(DTDRegionTypes.NMTOKENS_KEYWORD, NMTOKENS); - typeHash.put(DTDRegionTypes.NOTATION_KEYWORD, ENUMERATED_NOTATION); - // this one's a special case since there is no keyword for - // enumerated name tokens - typeHash.put("()", ENUMERATED_NAME); //$NON-NLS-1$ - - // now put the reverse in place. This gives us a 2 way lookup - // for when we want to retrieve the value and when we want to set it - typeHash.put(CDATA, "CDATA"); //$NON-NLS-1$ - typeHash.put(ID, "ID"); //$NON-NLS-1$ - typeHash.put(IDREF, "IDREF"); //$NON-NLS-1$ - typeHash.put(IDREFS, "IDREFS"); //$NON-NLS-1$ - typeHash.put(ENTITY, "ENTITY"); //$NON-NLS-1$ - typeHash.put(ENTITIES, "ENTITIES"); //$NON-NLS-1$ - typeHash.put(NMTOKEN, "NMTOKEN"); //$NON-NLS-1$ - typeHash.put(NMTOKENS, "NMTOKENS"); //$NON-NLS-1$ - typeHash.put(ENUMERATED_NAME, ""); //$NON-NLS-1$ - typeHash.put(ENUMERATED_NOTATION, "NOTATION"); //$NON-NLS-1$ - } - - private AttributeEnumList enumList = null; - - // public static final String IMPLIED = "IMPLIED"; - - public Attribute(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public String getDefaultKind() { - ITextRegion defaultKindRegion = getDefaultKindRegion(); - if (defaultKindRegion != null) { - return getStructuredDTDDocumentRegion().getText(defaultKindRegion); - } - - return ""; //$NON-NLS-1$ - } - - public ITextRegion getDefaultKindRegion() { - RegionIterator iter = iterator(); - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType() == DTDRegionTypes.IMPLIED_KEYWORD || region.getType() == DTDRegionTypes.REQUIRED_KEYWORD || region.getType() == DTDRegionTypes.FIXED_KEYWORD) { - return region; - } - } - return null; - } - - public String getDefaultValue() { - ITextRegion defaultValue = getNextQuotedLiteral(iterator()); - if (defaultValue != null) { - return getValueFromQuotedRegion(defaultValue); - } - return ""; //$NON-NLS-1$ - } - - public AttributeEnumList getEnumList() { - return enumList; - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.ATTRIBUTEICON); - } - - public ITextRegion getNameRegion() { - return getNextRegion(iterator(), DTDRegionTypes.ATTRIBUTE_NAME); - } - - public ITextRegion getNextQuotedLiteral(RegionIterator iter) { - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType().equals(DTDRegionTypes.SINGLEQUOTED_LITERAL) || region.getType().equals(DTDRegionTypes.DOUBLEQUOTED_LITERAL)) { - return region; - } - } - return null; - } - - protected int getOffsetAfterType() { - ITextRegion typeRegion = getTypeRegion(); - - String type = getType(); - boolean isEnumeration = type.equals(ENUMERATED_NAME) || type.equals(ENUMERATED_NOTATION); - if (isEnumeration) { - // now check if maybe this is an enumeration - if (getEnumList() != null) { - return getEnumList().getEndOffset(); - } - } - if (typeRegion != null) { - return getStructuredDTDDocumentRegion().getEndOffset(typeRegion); - } - else { - ITextRegion nameRegion = getNameRegion(); - return getStructuredDTDDocumentRegion().getEndOffset(nameRegion); - // // create one - // typeRegion = - // findOrCreateTypeRegion((String)typeHash.get(CDATA)); - } - } - - public String getType() { - ITextRegion region = getTypeRegion(); - if (region != null) { - String type = (String) typeHash.get(region.getType()); - if (type == null) { - // just return the text of the type region since this may be - // an entity representing the type; - return getStructuredDTDDocumentRegion().getText(region); - } - return type; - } - else if (getEnumList() != null) { - // enumerated name tokens don't have a type keyword. just - // the existence of the left paren is enough - return (String) typeHash.get("()"); //$NON-NLS-1$ - } - - return ""; //$NON-NLS-1$ - } - - public ITextRegion getTypeRegion() { - RegionIterator iter = iterator(); - - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType() == DTDRegionTypes.CDATA_KEYWORD || region.getType() == DTDRegionTypes.ID_KEYWORD || region.getType() == DTDRegionTypes.IDREF_KEYWORD || region.getType() == DTDRegionTypes.IDREFS_KEYWORD || region.getType() == DTDRegionTypes.ENTITY_KEYWORD || region.getType() == DTDRegionTypes.ENTITIES_KEYWORD || region.getType() == DTDRegionTypes.NMTOKEN_KEYWORD || region.getType() == DTDRegionTypes.NMTOKENS_KEYWORD || region.getType() == DTDRegionTypes.NOTATION_KEYWORD || region.getType() == DTDRegionTypes.PARM_ENTITY_TYPE) { - return region; - } - } - return null; - } - - public String getValueFromQuotedRegion(ITextRegion region) { - String type = region.getType(); - if (type.equals(DTDRegionTypes.SINGLEQUOTED_LITERAL) || type.equals(DTDRegionTypes.DOUBLEQUOTED_LITERAL)) { - String text = getStructuredDTDDocumentRegion().getText(region); - return text.substring(1, text.length() - 1); - } - return ""; //$NON-NLS-1$ - } - - public void resolveRegions() { - removeChildNodes(); - RegionIterator iter = iterator(); - - while (iter.hasNext()) { - ITextRegion currentRegion = iter.next(); - if (currentRegion.getType().equals(DTDRegionTypes.LEFT_PAREN)) { - enumList = new AttributeEnumList(getDTDFile(), getStructuredDTDDocumentRegion()); - } - if (enumList != null) { - enumList.addRegion(currentRegion); - if (currentRegion.getType() == DTDRegionTypes.RIGHT_PAREN) { - return; - } - } - } - - } - - public void setDefaultKind(Object requestor, String kind) { - - ITextRegion defaultKindRegion = getDefaultKindRegion(); - String oldDefaultKind = defaultKindRegion == null ? "" : getStructuredDTDDocumentRegion().getText(defaultKindRegion); //$NON-NLS-1$ - if (!kind.equals(oldDefaultKind)) { - String newText = kind; - int startOffset = 0; - int length = 0; - if (defaultKindRegion != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(defaultKindRegion); - length = getStructuredDTDDocumentRegion().getEndOffset(defaultKindRegion) - startOffset; - } - else { - startOffset = getOffsetAfterType(); - newText = " " + newText; //$NON-NLS-1$ - } - - ITextRegion defaultValue = getNextQuotedLiteral(iterator()); - - if (kind.equals(Attribute.FIXED) || kind.equals("")) { //$NON-NLS-1$ - if (defaultValue == null) { - // we are changing to fixed and wehave no quoted region. - // put in an empty value - newText += " \"\""; //$NON-NLS-1$ - } - } - else { - if (defaultValue != null) { - length = getStructuredDTDDocumentRegion().getEndOffset(defaultValue) - startOffset; - } - } - replaceText(requestor, startOffset, length, newText); - // do something if there is no "kind" region - } - } - - public void setDefaultKind(String kind) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ATTR_DEFAULT_KIND); //$NON-NLS-1$ - setDefaultKind(this, kind); - endRecording(this); - } - - public void setDefaultValue(Object requestor, String value, boolean fixed) { - ITextRegion defaultValue = getNextQuotedLiteral(iterator()); - String quoteChar = value.indexOf("\"") == -1 ? "\"" : "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - int startOffset = 0; - int endOffset = 0; - String newText = ""; //$NON-NLS-1$ - - String oldValue = getDefaultValue(); - boolean oldKindIsFixed = getDefaultKind().equals(Attribute.FIXED); - if (oldValue.equals(value) && fixed == oldKindIsFixed) { - // nothing to do - return; - } - - if (defaultValue != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(defaultValue); - endOffset = getStructuredDTDDocumentRegion().getEndOffset(defaultValue); - } - - ITextRegion defaultKindRegion = getDefaultKindRegion(); - if (defaultKindRegion != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(defaultKindRegion); - endOffset = endOffset == 0 ? getStructuredDTDDocumentRegion().getEndOffset(defaultKindRegion) : endOffset; - } - else { - if (startOffset == 0) { - endOffset = startOffset = getOffsetAfterType(); - newText += " "; //$NON-NLS-1$ - } - ITextRegion typeRegion = getTypeRegion(); - if (typeRegion == null && getEnumList() == null) { - // tack on a default type - // newText += "CDATA "; - } - } - if (fixed) { - newText += "#FIXED "; //$NON-NLS-1$ - } - else { - if (getDefaultKind().equals("") && value.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ - // if not fixed and value is "" then reset the default kind to - // implied - newText += "#IMPLIED"; //$NON-NLS-1$ - } - } - - if (!getType().equals("") && !value.equals("")) { //$NON-NLS-1$ //$NON-NLS-2$ - newText += quoteChar + value + quoteChar; - } - replaceText(requestor, startOffset, endOffset - startOffset, newText); - } - - public void setDefaultValue(String value, boolean fixed) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ATTR_DEFAULT_VAL); //$NON-NLS-1$ - setDefaultValue(this, value, fixed); - endRecording(this); - } - - public void setType(Object requestor, String type) { - String oldType = getType(); - if (!type.equals(oldType)) { - boolean wasEnumeration = oldType.equals(ENUMERATED_NAME) || oldType.equals(ENUMERATED_NOTATION); - boolean isEnumeration = type.equals(ENUMERATED_NAME) || type.equals(ENUMERATED_NOTATION); - String newText = ""; //$NON-NLS-1$ - int startOffset = 0; - int endOffset = 0; - - if (wasEnumeration && !isEnumeration) { - // get rid of the old enumlist - AttributeEnumList enumList = getEnumList(); - if (enumList != null) { - startOffset = enumList.getStartOffset(); - endOffset = enumList.getEndOffset(); - } - } - - ITextRegion region = getTypeRegion(); - if (region != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(region); - if (endOffset == 0) { - endOffset = getStructuredDTDDocumentRegion().getEndOffset(region); - } - } - else if (startOffset == 0) { - ITextRegion nameRegion = getNameRegion(); - newText += " "; //$NON-NLS-1$ - endOffset = startOffset = getStructuredDTDDocumentRegion().getEndOffset(nameRegion); - } - - String newTypeWord = (String) typeHash.get(type); - if (newTypeWord == null) { - // then this must be a parm entity being used in the type - // use the type text directly - newTypeWord = type; - } - - newText += newTypeWord; - - if (isEnumeration && !wasEnumeration) { - // put in a new numlist - boolean isSpaceNeeded = !type.equals(ENUMERATED_NAME); - newText += isSpaceNeeded ? " " : ""; //$NON-NLS-1$ //$NON-NLS-2$ - newText += "()"; //$NON-NLS-1$ - } - replaceText(requestor, startOffset, endOffset - startOffset, newText); - if (newTypeWord.equals("") && !type.equals(ENUMERATED_NAME)) { //$NON-NLS-1$ - // the set the defaultkind to "" - // setDefaultKind(requestor, ""); - setDefaultValue(requestor, "", false); //$NON-NLS-1$ - } - - } - } - - public void setType(String type) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ATTR_TYPE); //$NON-NLS-1$ - setType(this, type); - endRecording(this); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeEnumList.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeEnumList.java deleted file mode 100644 index a50e12e49b..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeEnumList.java +++ /dev/null @@ -1,72 +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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class AttributeEnumList extends DTDNode { - - private ArrayList list = new ArrayList(); - - public AttributeEnumList(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public Image getImage() { - // never exposed in tree - return null; - } - - // return the items that are in this enumerated list - public List getItems() { - list.clear(); - RegionIterator iter = iterator(); - while (iter.hasNext()) { - ITextRegion name = getNextRegion(iter, DTDRegionTypes.NAME); - if (name != null) { - list.add(getStructuredDTDDocumentRegion().getText(name)); - } - } - return list; - } - - public void setItems(Object requestor, String[] items) { - if (items != null) { - String text = "("; //$NON-NLS-1$ - for (int i = 0; i < items.length; i++) { - if (i > 0) { - text += " | " + items[i]; //$NON-NLS-1$ - } - else { - text += items[i]; - } - } - text += ")"; //$NON-NLS-1$ - replaceText(requestor, getStartOffset(), getNodeLength(), text); - } - } - - public void setItems(String[] items) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ATTR_ENUM_ITEMS); //$NON-NLS-1$ - setItems(this, items); - endRecording(this); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeList.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeList.java deleted file mode 100644 index ae22b6a8f9..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/AttributeList.java +++ /dev/null @@ -1,118 +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.dtd.core.internal; - -import java.util.ArrayList; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class AttributeList extends NamedTopLevelNode { - public AttributeList(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode, DTDRegionTypes.ATTLIST_TAG); - } - - public void addAttribute(String name) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ATTR_LIST_ADD); //$NON-NLS-1$ - - DTDNode lastAttribute = (DTDNode) getLastChild(); - if (lastAttribute != null) { - replaceText(this, lastAttribute.getEndOffset(), 0, "\n\t" + name + " CDATA #IMPLIED"); //$NON-NLS-1$ //$NON-NLS-2$ - } - else { - ITextRegion nameRegion = getNameRegion(); - if (nameRegion != null) { - replaceText(this, getStructuredDTDDocumentRegion().getEndOffset(nameRegion), 0, "\n\t" + name + " CDATA #IMPLIED"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - } - - endRecording(this); - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.ATTRIBUTELISTICON); - } - - public void insertIntoModel(Object requestor, Attribute reference, Attribute node, boolean isAfter) { - int offset = 0; - String newText = ""; //$NON-NLS-1$ - String nodeText = node.getFullNodeText(); - if (!isAfter) { - offset = reference.getStartOffset(); - } - else { - // try and get next child - Attribute attr = (Attribute) reference.getNextSibling(); - if (attr != null) { - offset = attr.getStartOffset(); - } - else { - // just use the end offset - offset = reference.getWhitespaceEndOffset(); - } - } - newText += nodeText;// + (isLastChild ? "\n" : "\n\t"); - if (!node.hasTrailingWhitespace()) { - newText += "\n\t"; //$NON-NLS-1$ - } - replaceText(requestor, offset, 0, newText); - } - - public void resolveRegions() { - removeChildNodes(); - RegionIterator iter = iterator(); - - if (getNameRegion() != null) { - // we skip past the name token is our name - skipPastName(iter); - } - - ArrayList children = new ArrayList(); - Attribute attribute = null; - boolean trailingWhitespace = false; - while (iter.hasNext()) { - ITextRegion currentRegion = iter.next(); - if (currentRegion.getType().equals(DTDRegionTypes.ATTRIBUTE_NAME)) { - attribute = new Attribute(getDTDFile(), getStructuredDTDDocumentRegion()); - children.add(attribute); - appendChild(attribute); - trailingWhitespace = false; - } - if (attribute != null && currentRegion.getType() != DTDRegionTypes.END_TAG) { - if (!trailingWhitespace) { - attribute.addRegion(currentRegion); - } - else { - if (currentRegion.getType() == DTDRegionTypes.WHITESPACE) { - attribute.addWhitespaceRegion(currentRegion); - } - } - - // the following prevents extra whitespace from being picked - // up by the attribute - if (currentRegion.getType() == DTDRegionTypes.REQUIRED_KEYWORD || currentRegion.getType() == DTDRegionTypes.IMPLIED_KEYWORD || currentRegion.getType() == DTDRegionTypes.SINGLEQUOTED_LITERAL || currentRegion.getType() == DTDRegionTypes.DOUBLEQUOTED_LITERAL) { - trailingWhitespace = true; - } - } - } - int numKids = children.size(); - for (int i = 0; i < numKids; i++) { - ((Attribute) children.get(i)).resolveRegions(); - } // end of for () - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMBasicNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMBasicNode.java deleted file mode 100644 index 5b27f02ee9..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMBasicNode.java +++ /dev/null @@ -1,165 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -/* - * CMBasicNode combines all the different content types into one. The idea - * behind this is to allow arbitrary name changes to not require a tree - * update. - */ -public class CMBasicNode extends CMRepeatableNode { - - // static final int EMPTY = 0; - // static final int ANY = 1; - // static final int PCDATA = 2; - - public CMBasicNode(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public Image getImage() { - final String name = getName(); - ITextRegion pcdata = getNextRegion(iterator(), DTDRegionTypes.CONTENT_PCDATA); - if (pcdata != null) { - return DTDCorePlugin.getInstance().getImage(DTDResource.PCDATAICON); - } - - if (isRootElementContent()) { - if (name.equals(EMPTY)) { - return DTDCorePlugin.getInstance().getImage(DTDResource.EMPTYICON); - } - else if (name.equals(ANY)) { - return DTDCorePlugin.getInstance().getImage(DTDResource.ANYICON); - } - } - - // Otherwise this is just an element reference node. Just return - // what CMRepeatableNode would give us - return super.getImage(); - } - - public ITextRegion getNameRegion() { - RegionIterator iter = iterator(); - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType() == DTDRegionTypes.NAME || region.getType() == DTDRegionTypes.CONTENT_PCDATA) { - return region; - } - } - return null; - } - - // returns the occurrencetoken, or the token where the occurrence token - // should appear after - public ITextRegion getOccurrenceRegion() { - RegionIterator iter = iterator(); - skipPastName(iter); - if (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType() == DTDRegionTypes.OCCUR_TYPE) { - return region; - } - } - return getNameRegion(); - } - - public String getType() { - ITextRegion pcdata = getNextRegion(iterator(), DTDRegionTypes.CONTENT_PCDATA); - if (pcdata != null) { - return PCDATA; - } - - if (isRootElementContent()) { - final String name = getName(); - if (isRootElementContent()) { - if (name.equals(EMPTY)) { - return EMPTY; - } - else if (name.equals(ANY)) { - return ANY; - } - else { - // otherwise just return it's name as the type - return name; - } - - } - } - return ""; //$NON-NLS-1$ - } - - public boolean isEmptyAnyOrPCData() { - if (isPCData()) { - return true; - } - - - final String name = getName(); - if (isRootElementContent()) { - if (name.equals(EMPTY) || name.equals(ANY)) { - return true; - } - } - return false; - } - - public boolean isPCData() { - ITextRegion pcdata = getNextRegion(iterator(), DTDRegionTypes.CONTENT_PCDATA); - if (pcdata != null) { - return true; - } - return false; - } - - // public Node insertRegion(Region token) - // { - // if (!tokenStream.containsToken(token) && token.getType() == - // Token.OCCUR_TYPE) - // { - // // then add it so that our range contains it - // insertIntoTokenStream(token); - // } - // return this; - // } - - public boolean isReference() { - return !isEmptyAnyOrPCData(); - } - - public void setName(Object requestor, String name) { - // beginRecording(requestor, "Name Change"); - - super.setName(requestor, name); - if (!isReference()) { - // if it is no longer a reference node, remove the occurrence - // token - setOccurrence(requestor, CMRepeatableNode.ONCE); - } - - // endRecording(requestor); - } - - /* - * public static String getName(int type) { switch (type) { case EMPTY: - * return emptyString; case ANY: return anyString; case PCDATA: return - * pcdataString; default: break; } // end of switch () return ""; } - */ - -}// CMBasicNode diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMGroupNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMGroupNode.java deleted file mode 100644 index 1951fd710e..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMGroupNode.java +++ /dev/null @@ -1,430 +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.dtd.core.internal; - -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.dtd.core.internal.util.DTDUniqueNameHelper; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class CMGroupNode extends CMRepeatableNode { - - public static final char CHOICE = '|'; - public static final char SEQUENCE = ','; - - protected char connector = SEQUENCE; - - // protected ArrayList children = new ArrayList(); - - public CMGroupNode(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public void addChild() { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_GRP_NODE_ADD_CHILD); //$NON-NLS-1$ - DTDNode lastNode = (DTDNode) getLastChild(); - String elementName = DTDUniqueNameHelper.getUniqueName(getChildrenList(), "ChildNode"); //$NON-NLS-1$ - if (lastNode != null) { - replaceText(this, lastNode.getEndOffset(), 0, String.valueOf(getConnector()) + elementName); //$NON-NLS-1$ - } - else { - replaceText(this, getStartOffset() + 1, 0, elementName); //$NON-NLS-1$ - } - - endRecording(this); - } - - public void addGroup() { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_GRP_NODE_ADD_GRP); //$NON-NLS-1$ - DTDNode lastNode = (DTDNode) getLastChild(); - if (lastNode != null) { - replaceText(this, lastNode.getEndOffset(), 0, String.valueOf(getConnector()) + " ()"); //$NON-NLS-1$ - } - else { - replaceText(this, getStartOffset() + 1, 0, "()"); //$NON-NLS-1$ - } - - endRecording(this); - } - - public void delete(Object requestor, DTDNode child) { - Object[] children = getChildren(); - - if (children.length == 1 && getFirstChild() == child) { - replaceText(requestor, child.getStartOffset(), child.getNodeLength(), null); - return; - } - - for (int i = 0; i < children.length - 1; i++) { - DTDNode childA = (DTDNode) children[i]; - DTDNode childB = (DTDNode) children[i + 1]; - - boolean childADeleted = childA == child; - boolean childBDeleted = childB == child; - if (childADeleted || childBDeleted) { - // we found the child - int startOffset = childADeleted ? childA.getStartOffset() : childA.getEndOffset(); - int endOffset = childADeleted ? childB.getStartOffset() : childB.getEndOffset(); - replaceText(requestor, startOffset, endOffset - startOffset, ""); //$NON-NLS-1$ - removeChild(child); - break; - } - } - } - - /** - * Get the value of connector. - * - * @return value of connector. - */ - public char getConnector() { - Object[] children = getChildren(); - for (int i = 0; i < children.length - 1; i++) { - DTDNode childA = (DTDNode) children[i]; - DTDNode childB = (DTDNode) children[i + 1]; - - // create a stream between the two siblings and walk it - // note that this stream includes the last region of the first - // sibling and the first region of the next sibling. - // both these should be ignored - RegionIterator iter = new RegionIterator(getStructuredDTDDocumentRegion(), childA.getEndOffset(), childB.getStartOffset()); - // stream.setFirstRegion(childA.getLastRegion()); - // stream.setLastRegion(childB.getFirstRegion()); - // Iterator iter = stream.iterator(); - // skip the first region which is the last region of childA - // do we need this now ? - // iter.next(); - ITextRegion currentRegion = null; - while (iter.hasNext() && currentRegion != childB.getStartRegion()) { - currentRegion = iter.next(); - if (currentRegion.getType() == DTDRegionTypes.CONNECTOR) { - connector = getStructuredDTDDocumentRegion().getText(currentRegion).charAt(0); - return connector; - } - } - } - return connector; - } - - public Image getImage() { - DTDCorePlugin resourcePlugin = DTDCorePlugin.getInstance(); - switch (getConnector()) { - case SEQUENCE : - return resourcePlugin.getImage(DTDResource.ONESEQUENCEICON); - /* - * switch (getOccurrence()) { case ONCE : return - * resourcePlugin.getImage(DTDResource.ONESEQUENCEICON); case - * OPTIONAL : return - * resourcePlugin.getImage(DTDResource.OPTIONALSEQUENCEICON); case - * ONE_OR_MORE : return - * resourcePlugin.getImage(DTDResource.ONEORMORESEQUENCEICON); - * case ZERO_OR_MORE : return - * resourcePlugin.getImage(DTDResource.ZEROORMORESEQUENCEICON); } - */ - case CHOICE : - return resourcePlugin.getImage(DTDResource.ONECHOICEICON); - /* - * switch (getOccurrence()) { case ONCE : return - * resourcePlugin.getImage(DTDResource.ONECHOICEICON); case OPTIONAL : - * return resourcePlugin.getImage(DTDResource.OPTIONALCHOICEICON); - * case ONE_OR_MORE : return - * resourcePlugin.getImage(DTDResource.ONEORMORECHOICEICON); case - * ZERO_OR_MORE : return - * resourcePlugin.getImage(DTDResource.ZEROORMORECHOICEICON); } - */ - } - return null; - } - - public String getName() { - return ""; //$NON-NLS-1$ - } - - // returns the occurrenceregion, or the last region where the occurrence - // region should appear after - public ITextRegion getOccurrenceRegion() { - int nesting = 0; - - // we skip past the first left paren we see since that is the - // beginning of our own node - RegionIterator iter = iterator(); - // we assume the first region is the '(' - iter.next(); - ITextRegion currentRegion = null; - while (iter.hasNext() && nesting >= 0) { - currentRegion = iter.next(); - if (currentRegion.getType() == DTDRegionTypes.LEFT_PAREN) { - nesting++; - } - if (currentRegion.getType() == DTDRegionTypes.RIGHT_PAREN) { - nesting--; - } - } - if (nesting < 0) { - // This means we have passed over the right paren that marks the - // end of our grouping. - // Look for an occurrence region - while (iter.hasNext()) { - currentRegion = iter.next(); - if (currentRegion.getType() == DTDRegionTypes.OCCUR_TYPE) { - return currentRegion; - } - } - } - // if we're here, this means that there is no occur region. return the - // last region - return iter.previous(); - } - - public String getType() { - if (isRootElementContent()) { - if (getFirstChild() != null) { - CMNode node = (CMNode) getFirstChild(); - if (node.getType().equals(PCDATA)) { - return MIXED; - } - else { - return CHILDREN; - } - } - } - return ""; //$NON-NLS-1$ - } - - public void insertChildNode(Object requestor, String nodeText, int position) { - Object[] children = getChildren(); - - int startOffset = 0; - String newText = ""; //$NON-NLS-1$ - if (position < children.length) { - DTDNode reference = (DTDNode) children[position]; - startOffset = reference.getStartOffset(); - newText = nodeText + " " + String.valueOf(getConnector()) + " "; //$NON-NLS-1$ //$NON-NLS-2$ - } - else if (position == children.length) { - // add to end - DTDNode reference = (DTDNode) children[position - 1]; - startOffset = reference.getEndOffset(); - newText = " " + String.valueOf(getConnector()) + " " + nodeText; //$NON-NLS-1$ //$NON-NLS-2$ - } - replaceText(requestor, startOffset, 0, newText); - } - - public void insertChildNode(String nodeText, int position) { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_GRP_NODE_INSERT_ELEMENT); //$NON-NLS-1$ - insertChildNode(this, nodeText, position); - endRecording(this); - } - - public void insertIntoModel(Object requestor, CMNode reference, CMNode node, boolean isAfter) { - String nodeText = node.getNodeText(); - List children = getChildrenList(); - - int index = children.indexOf(reference); - if (index == -1) { - // no reference node, add it to the end?? - index = children.size(); - } - else { - // got an index. if we want to add after, increase by 1 - index = isAfter ? index + 1 : index; - } - insertChildNode(requestor, nodeText, index); - } - - public void resolveRegions() { - int nesting = 0; - // children.clear(); - removeChildNodes(); - DTDNode currentGroupNode = null; - CMBasicNode currentReferenceNode = null; - RegionIterator iter = iterator(); - // we assume the first region is the '(' - iter.next(); - while (iter.hasNext() && nesting >= 0) { - ITextRegion currentRegion = iter.next(); - if (nesting == 0) { - if (currentRegion.getType().equals(DTDRegionTypes.CONTENT_PCDATA)) { - currentGroupNode = currentReferenceNode = null; - DTDNode pcData = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion()); - pcData.addRegion(currentRegion); - appendChild(pcData); - // children.add(pcData); - } - else if (currentRegion.getType().equals(DTDRegionTypes.NAME)) { - // we have hit a new reference node. Make sure we reset - // the groupnode var so it doesn't collect more regions - currentGroupNode = null; - currentReferenceNode = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion()); - currentReferenceNode.addRegion(currentRegion); - appendChild(currentReferenceNode); - // children.add(currentReferenceNode); - } - else if (currentRegion.getType().equals(DTDRegionTypes.OCCUR_TYPE)) { - // we could potentially flag an error here if we hit an - // occurrence type and currentRefNode and currentGroupNode - // are null - if (currentReferenceNode != null) { - // currentReferenceNode.setOccurrence(currentRegion.getText().toCharArray()[0]); - currentReferenceNode.addRegion(currentRegion); - currentReferenceNode = null; - } - } - else if (currentRegion.getType().equals(DTDRegionTypes.CONNECTOR)) { - // note that if connector is already set and it is - // different from the current connector region, then we - // have an error! - // setConnector(currentRegion.getText().toCharArray()[0]); - } - else if (currentRegion.getType().equals(DTDRegionTypes.LEFT_PAREN)) { - if (currentGroupNode == null) { - // we have hit a new group. Make sure we reset the - // referencenode var so it doesn't collect any more - // regions - currentReferenceNode = null; - currentGroupNode = new CMGroupNode(getDTDFile(), getStructuredDTDDocumentRegion()); - appendChild(currentGroupNode); - // children.add(currentGroupNode); - } - } - } - - if (currentRegion.getType().equals(DTDRegionTypes.LEFT_PAREN)) { - nesting++; - } - if (currentRegion.getType().equals(DTDRegionTypes.RIGHT_PAREN)) { - nesting--; - if (nesting == 0 && currentGroupNode != null) { - currentGroupNode.addRegion(currentRegion); - // peek at next region to see if it is an occur region. if - // so, add it to the groupnode - if (iter.hasNext()) { - ITextRegion nextRegion = iter.next(); - if (nextRegion.getType().equals(DTDRegionTypes.OCCUR_TYPE)) { - currentGroupNode.addRegion(nextRegion); - } - else { - // Otherwise, push it back as the next item to be - // retrieved by a future next() call - iter.previous(); - } - } - currentGroupNode = null; - } - } - if (currentGroupNode != null) { - currentGroupNode.addRegion(currentRegion); - } - } - - if (nesting < 0) { - // This means we have passed over the right paren that marks the - // end of our grouping. - // Look for an occurrence region - while (iter.hasNext()) { - ITextRegion currentRegion = iter.next(); - if (currentRegion.getType().equals(DTDRegionTypes.OCCUR_TYPE)) { - // setOccurrence(currentRegion.getText().toCharArray()[0]); - } - } // end of while () - } - - // for (org.w3c.dom.Node child = getFirstChild(); child != null; child - // = child.getNextSibling()) - // { - // System.out.println("child found = " + child); - // } - - Object[] children = getChildren(); - // System.out.println("children legnth = " + children.length); - - for (int i = 0; i < children.length; i++) { - DTDNode currentNode = (DTDNode) children[i]; - currentNode.resolveRegions(); - } // end of while () - - } - - /** - * Set the value of connector. - * - * @param v - * Value to assign to connector. - */ - public void setConnector(char v) { - if (connector != v) { - connector = v; - // walk through our kids and see if there is a connector between - // each sibling. if not, create one and set the connector. if - // there is - // then just change the text of the connector - Object[] children = getChildren(); - if (children.length <= 1) { - // there won't be any connector existing between the children - // just notify a change in the node and return; - getDTDFile().notifyNodeChanged(this); - return; - } - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_GRP_NODE_CONNECTOR); //$NON-NLS-1$ - for (int i = 0; i < children.length - 1; i++) { - DTDNode childA = (DTDNode) children[i]; - DTDNode childB = (DTDNode) children[i + 1]; - - // create a stream between the two siblings and walk it - // note that this stream includes the last region of the first - // sibling and the first region of the next sibling. - // both these should be ignored - RegionIterator iter = new RegionIterator(getStructuredDTDDocumentRegion(), childA.getEndOffset(), childB.getStartOffset()); - // skip the first region which is the last region of childA - - // do we still need this - // iter.next(); - ITextRegion currentRegion = null; - boolean foundConnector = false; - while (iter.hasNext() && currentRegion != childB.getStartRegion()) { - currentRegion = iter.next(); - if (currentRegion.getType() == DTDRegionTypes.CONNECTOR) { - foundConnector = true; - // Region oldRegion = currentRegion.createCopy(); - // found a connector! on to the next sibling pair - // currentRegion.updateText(String.valueOf(v)); - replaceText(this, getStructuredDTDDocumentRegion().getStartOffset(currentRegion), 1, String.valueOf(connector)); - // changeStructuredDocument(oldRegion, currentRegion); - break; - } - } - - if (!foundConnector) { - // if we're here, that means we need to insert a new - // connector region after childA - replaceText(this, childA.getEndOffset(), 0, String.valueOf(connector)); - // DTDRegion connectorRegion = new - // DTDRegion(DTDRegionTypes.CONNECTOR, - // childA.getEndOffset(), 1); - // insertIntoStructuredDocument(connectorRegion); - } - } - endRecording(this); - } - } - - // public Object[] getChildren() - // { - // return children.toArray(); - // } -}// CMGroupNode diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMNode.java deleted file mode 100644 index 6c93c5d62f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMNode.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.dtd.core.internal; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - -// base class for an Element's contentmodel -public abstract class CMNode extends DTDNode { - public static final String ANY = DTDCoreMessages._UI_LABEL_CM_NODE_ANY; //$NON-NLS-1$ - public static final String CHILDREN = DTDCoreMessages._UI_LABEL_CM_NODE_CHILD_CONTENT; //$NON-NLS-1$ - - public static final String EMPTY = DTDCoreMessages._UI_LABEL_CM_NODE_EMPTY; //$NON-NLS-1$ - public static final String MIXED = DTDCoreMessages._UI_LABEL_CM_NODE_MIX_CONTENT; //$NON-NLS-1$ - public static final String PCDATA = DTDCoreMessages._UI_LABEL_CM_NODE_PCDATA; //$NON-NLS-1$ - - - boolean rootElementContent; - - public CMNode(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - // this is only valid to ask if the content is a root element content - abstract public String getType(); - - /** - * Get the value of rootElementContent. This tells us whether this element - * content's parent is a direct decendent of the containing element - * - * @return value of rootElementContent. - */ - public boolean isRootElementContent() { - return rootElementContent; - } - - // if this is a root element, change the content to children - // ie . (child1) - public void setChildrenContent(String newChild) { - if (isRootElementContent()) { - if (!newChild.equals("")) { //$NON-NLS-1$ - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_NODE_SET_CHILD_CONTENT); //$NON-NLS-1$ - replaceText(this, getStartOffset(), getNodeLength(), "(" + newChild + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - endRecording(this); - return; - } - - if (!getType().equals(CHILDREN)) { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_NODE_SET_CHILD_CONTENT); //$NON-NLS-1$ - if (this instanceof CMBasicNode) { - replaceText(this, getStartOffset(), getNodeLength(), "(newChild)"); //$NON-NLS-1$ - } - else { - // now must convert from mixed content to this one. must - // preserve the remaining children - CMGroupNode group = (CMGroupNode) this; - CMNode firstChild = (CMNode) group.getFirstChild(); - if (firstChild.getType().equals(PCDATA)) { - group.delete(firstChild); - } - } - - endRecording(this); - } - } - } - - public void setContent(String content) { - if (isRootElementContent()) { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_NODE_SET + " " + content + " " + DTDCoreMessages._UI_LABEL_CM_NODE_CONTENT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - replaceText(this, getStartOffset(), getNodeLength(), content); - endRecording(this); - } - } - - // if this is a root element, change the content to mixed - // ie . (#PCDATA, child1) - public void setMixedContent() { - if (isRootElementContent()) { - if (!getType().equals(MIXED)) { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_NODE_SET_MIX_CONTENT); //$NON-NLS-1$ - if (this instanceof CMBasicNode) { - replaceText(this, getStartOffset(), getNodeLength(), "(#PCDATA | newChild)*"); //$NON-NLS-1$ - } - else { - // now must convert from children content to this one. - // must - // preserve the children - CMGroupNode group = (CMGroupNode) this; - group.setConnector(CMGroupNode.CHOICE); - group.setOccurrence(CMRepeatableNode.ZERO_OR_MORE); - CMNode firstChild = (CMNode) group.getFirstChild(); - if (!firstChild.getType().equals(PCDATA)) { - group.insertChildNode("#PCDATA", 0); //$NON-NLS-1$ - } - } - endRecording(this); - } - } - } - - /** - * Set the value of rootElementContent. - * - * @param v - * Value to assign to rootElementContent. - */ - public void setRootElementContent(boolean v) { - this.rootElementContent = v; - } - - // public void delete() - // { - // if (isRootElementContent()) - // { - // // then the superclasses delete will be fine - // super.delete(); - // return; - // } - - // CMGroupNode parent = (CMGroupNode) getParentNode(); - // parent.removeChildNode(this); - // } - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMRepeatableNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMRepeatableNode.java deleted file mode 100644 index 69ce110525..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/CMRepeatableNode.java +++ /dev/null @@ -1,81 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public abstract class CMRepeatableNode extends CMNode { - - public static final char ONCE = '1'; - public static final char ONE_OR_MORE = '+'; - public static final char OPTIONAL = '?'; - public static final char ZERO_OR_MORE = '*'; - - - public CMRepeatableNode(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public Image getImage() { - DTDCorePlugin resourcePlugin = DTDCorePlugin.getInstance(); - return resourcePlugin.getImage(DTDResource.ELEMENTREFICON); - } - - public char getOccurrence() { - ITextRegion occurRegion = getOccurrenceRegion(); - if (occurRegion != null && occurRegion.getType() == DTDRegionTypes.OCCUR_TYPE) { - return getStructuredDTDDocumentRegion().getText(occurRegion).charAt(0); - } - return CMRepeatableNode.ONCE; - } - - // returns the occurrenceregion, or the last region where the occurrence - // region should appear after - abstract public ITextRegion getOccurrenceRegion(); - - public void setOccurrence(char occurrence) { - beginRecording(this, DTDCoreMessages._UI_LABEL_CM_REP_NODE_CHG_OCCUR); //$NON-NLS-1$ - setOccurrence(this, occurrence); - endRecording(this); - } - - public void setOccurrence(Object requestor, char occurrence) { - if (getOccurrence() != occurrence) { - ITextRegion region = getOccurrenceRegion(); - if (region != null) { - if (region.getType().equals(DTDRegionTypes.OCCUR_TYPE)) { - if (occurrence == CMRepeatableNode.ONCE) { - // we need to remove the occur region from the flat - // model; - getDTDFile().getStructuredDocument().replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(region), 1, ""); //$NON-NLS-1$ - } - else { - // Region oldOccur = region.createCopy(); - getDTDFile().getStructuredDocument().replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(region), 1, String.valueOf(occurrence)); - // changeStructuredDocument(oldOccur, region); - } - } - else if (occurrence != CMRepeatableNode.ONCE) { - // System.out.println(getString()); - // we need to create an occurrenceRegion - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(region), 0, String.valueOf(occurrence)); - } - } - } - } - -}// CMRepeatableNode diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Comment.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Comment.java deleted file mode 100644 index 935ff52324..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Comment.java +++ /dev/null @@ -1,75 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class Comment extends NamedTopLevelNode { - - public class StartEndPair { - public int startOffset, endOffset; - } - - public Comment(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode, DTDRegionTypes.COMMENT_START); - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.COMMENTICON); - } - - public String getName() { - String text = getText(); - if (text.length() <= 30) { - return text; - } - else { - return text.substring(0, 29) + "..."; //$NON-NLS-1$ - } - } - - private void getStartAndEndOffsetForText(StartEndPair pair) { - RegionIterator iter = iterator(); - ITextRegion commentStartTag = getStartTag(iter); - ITextRegion endCommentTag = getNextRegion(iter, DTDRegionTypes.COMMENT_END); - pair.endOffset = getStructuredDTDDocumentRegion().getEndOffset(); - if (commentStartTag != null) { - pair.startOffset = getStructuredDTDDocumentRegion().getEndOffset(commentStartTag); - } - if (endCommentTag != null) { - pair.endOffset = getStructuredDTDDocumentRegion().getStartOffset(endCommentTag); - } - } - - public String getText() { - String text = getStructuredDTDDocumentRegion().getText(); - int flatNodeStart = getStructuredDTDDocumentRegion().getStartOffset(); - StartEndPair pair = new StartEndPair(); - getStartAndEndOffsetForText(pair); - return text.substring(pair.startOffset - flatNodeStart, pair.endOffset - flatNodeStart); - } - - public void setText(String newText) { - beginRecording(this, DTDCoreMessages._UI_LABEL_COMMENT_CHG); //$NON-NLS-1$ - StartEndPair pair = new StartEndPair(); - getStartAndEndOffsetForText(pair); - replaceText(this, pair.startOffset, pair.endOffset - pair.startOffset, newText); - endRecording(this); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCoreMessages.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCoreMessages.java deleted file mode 100644 index 0e12f8e060..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCoreMessages.java +++ /dev/null @@ -1,95 +0,0 @@ -/********************************************************************** - * Copyright (c) 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 - Initial API and implementation - **********************************************************************/ -package org.eclipse.wst.dtd.core.internal; - -import org.eclipse.osgi.util.NLS; - -/** - * Strings used by DTD Core - * - * @plannedfor 1.0 - */ -public class DTDCoreMessages extends NLS { - private static final String BUNDLE_NAME = "org.eclipse.wst.dtd.core.internal.DTDCorePluginResources";//$NON-NLS-1$ - - public static String _UI_NONE_DESC; - public static String _UI_CHARACTER_DATA_DESC; - public static String _UI_IDENTIFIER_DESC; - public static String _UI_ID_REFERENCE_DESC; - public static String _UI_ID_REFERENCES_DESC; - public static String _UI_ENTITY_NAME_DESC; - public static String _UI_ENTITY_NAMES_DESC; - public static String _UI_NAME_TOKEN_DESC; - public static String _UI_NAME_TOKENS_DESC; - public static String _UI_ENUM_NAME_TOKENS_DESC; - public static String _UI_ENUM_NOTATION_DESC; - public static String _UI_LABEL_ATTR_DEFAULT_VAL; - public static String _UI_LABEL_ATTR_DEFAULT_KIND; - public static String _UI_LABEL_ATTR_TYPE; - public static String _UI_LABEL_ATTR_ENUM_ITEMS; - public static String _UI_LABEL_ATTR_LIST_ADD; - public static String _UI_LABEL_CM_GRP_NODE_CONNECTOR; - public static String _UI_LABEL_CM_GRP_NODE_INSERT_ELEMENT; - public static String _UI_LABEL_CM_GRP_NODE_ADD_GRP; - public static String _UI_LABEL_CM_GRP_NODE_ADD_CHILD; - public static String _UI_LABEL_CM_NODE_MIX_CONTENT; - public static String _UI_LABEL_CM_NODE_CHILD_CONTENT; - public static String _UI_LABEL_CM_NODE_SET_MIX_CONTENT; - public static String _UI_LABEL_CM_NODE_SET_CHILD_CONTENT; - public static String _UI_LABEL_CM_NODE_SET; - public static String _UI_LABEL_CM_NODE_CONTENT; - public static String _UI_LABEL_CM_NODE_PCDATA; - public static String _UI_LABEL_CM_NODE_ANY; - public static String _UI_LABEL_CM_NODE_EMPTY; - public static String _UI_LABEL_CM_REP_NODE_CHG_OCCUR; - public static String _UI_LABEL_COMMENT_CHG; - public static String _UI_LABEL_DTD_FILE_ADD_ELEMENT; - public static String _UI_LABEL_DTD_FILE_ADD_ENTITY; - public static String _UI_LABEL_DTD_FILE_ADD_COMMENT; - public static String _UI_LABEL_DTD_FILE_ADD_PARM_ENTITY_REF; - public static String _UI_LABEL_DTD_FILE_ADD_NOTATION; - public static String _UI_LABEL_DTD_FILE_ADD_ATTR_LIST; - public static String _UI_LABEL_DTD_FILE_DELETE; - public static String _UI_LABEL_DTD_NODE_NAME_CHG; - public static String _UI_LABEL_DTD_NODE_DELETE; - public static String _UI_LABEL_ELEMENT_ADD_ATTR; - public static String _UI_LABEL_ELEMENT_ADD_GRP; - public static String _UI_LABEL_ELEMENT_ADD_CHILD; - public static String _UI_LABEL_ENTITY_SET_PARM_ENTITY; - public static String _UI_LABEL_ENTITY_SET_GENERAL_ENTITY; - public static String _UI_LABEL_ENTITY_SET_EXT_ENTITY; - public static String _UI_LABEL_ENTITY_SET_INT_ENTITY; - public static String _UI_LABEL_ENTITY_VALUE_CHG; - public static String _UI_LABEL_ENTITY_NDATA_CHANGE; - public static String _UI_LABEL_EXT_NODE_PUBLIC_ID_CHG; - public static String _UI_LABEL_EXT_NODE_SYSTEM_ID_CHG; - public static String _UI_LABEL_NODE_LIST_ELEMENTS; - public static String _UI_LABEL_NODE_LIST_ENTITIES; - public static String _UI_LABEL_NODE_LIST_NOTATIONS; - public static String _UI_LABEL_NODE_LIST_COMMENTS; - public static String _UI_LABEL_NODE_LIST_OTHER; - public static String _UI_LABEL_NODE_LIST_ATTRIBUTES; - public static String _UI_LABEL_PARM_ENTITY_REF_CHG_ENTITY_REF; - public static String _UI_LABEL_PARM_ENTITY_REF_COMMENT_CHG; - public static String _UI_LABEL_TOP_LEVEL_NODE_DELETE; - public static String _ERROR_INCL_FILE_LOAD_FAILURE; - public static String _ERROR_UNDECLARED_ELEMENT_1; - public static String _UI_ERRORPART_UNDECLARED_ELEMENT_2; - public static String _ERROR_DUP_ID_ATTRIBUTE_1; - public static String _UI_ERRORPART_DUP_ID_ATTRIBUTE_2; - public static String _ERROR_INVALID_DEFAULT_ATTR_VALUE_1; - public static String _UI_ERRORPART_INVALID_DEFAULT_ATTR_VALUE_2; - public static String _EXC_OPERATION_NOT_SUPPORTED; - - static { - // load message values from bundle file - NLS.initializeMessages(BUNDLE_NAME, DTDCoreMessages.class); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePlugin.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePlugin.java deleted file mode 100644 index 5cb55c563c..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePlugin.java +++ /dev/null @@ -1,57 +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.dtd.core.internal; - -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.ImageRegistry; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.plugin.AbstractUIPlugin; - -public class DTDCorePlugin extends AbstractUIPlugin { - private static DTDCorePlugin instance; - - public static Image getDTDImage(String iconName) { - return getInstance().getImage(iconName); - } - - public static ImageDescriptor getDTDImageDescriptor(String iconName) { - String thisID = getInstance().getBundle().getSymbolicName(); - return AbstractUIPlugin.imageDescriptorFromPlugin(thisID, iconName); - } - - public synchronized static DTDCorePlugin getInstance() { - return instance; - } - - public static DTDCorePlugin getPlugin() { - return instance; - } - - public DTDCorePlugin() { - super(); - instance = this; - } - - public Image getImage(String iconName) { - ImageRegistry imageRegistry = getImageRegistry(); - Image image = imageRegistry.get(iconName); - - if (image == null) { - String thisID = getInstance().getBundle().getSymbolicName(); - imageRegistry.put(iconName, imageDescriptorFromPlugin(thisID, iconName)); - image = imageRegistry.get(iconName); - } - - return image; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePluginResources.properties b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePluginResources.properties deleted file mode 100644 index a7ac3db0ef..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDCorePluginResources.properties +++ /dev/null @@ -1,127 +0,0 @@ -############################################################################### -# Copyright (c) 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 -############################################################################### -! Strings for DTDBasicTypeImpl type descriptions -_UI_NONE_DESC=None - -!! NOTE TO TRANSLATOR: Do not translate following text in parentheses on following 10 lines i.e.(CDATA) -_UI_CHARACTER_DATA_DESC=Character Data (CDATA) -_UI_IDENTIFIER_DESC=Identifier (ID) -_UI_ID_REFERENCE_DESC=ID Reference (IDREF) -_UI_ID_REFERENCES_DESC=ID References (IDREFS) -_UI_ENTITY_NAME_DESC=Entity Name (ENTITY) -_UI_ENTITY_NAMES_DESC=Entity Names (ENTITIES) -_UI_NAME_TOKEN_DESC=Name Token (NMTOKEN) -_UI_NAME_TOKENS_DESC=Name Tokens (NMTOKENS) -_UI_ENUM_NAME_TOKENS_DESC=Enumerated Name Tokens -_UI_ENUM_NOTATION_DESC=Enumerated NOTATION - -! Strings from sed/model - -! Attribute.java -_UI_LABEL_ATTR_DEFAULT_VAL=Attribute Default Change Value -_UI_LABEL_ATTR_DEFAULT_KIND=Change Attribute Default Value -_UI_LABEL_ATTR_TYPE=Change Attribute Type - -! AttributeEnumList -_UI_LABEL_ATTR_ENUM_ITEMS=Change Attribute Enumeration Value - -! AttributeList -_UI_LABEL_ATTR_LIST_ADD=Add Attribute - -! CMGroupNode -_UI_LABEL_CM_GRP_NODE_CONNECTOR=Change Connector -_UI_LABEL_CM_GRP_NODE_INSERT_ELEMENT=Insert Element -_UI_LABEL_CM_GRP_NODE_ADD_GRP=Add Group -_UI_LABEL_CM_GRP_NODE_ADD_CHILD=Add Child Element - -! CMNode -_UI_LABEL_CM_NODE_MIX_CONTENT=Mixed Content -_UI_LABEL_CM_NODE_CHILD_CONTENT=Children Content -_UI_LABEL_CM_NODE_SET_MIX_CONTENT=Set Mixed Content -_UI_LABEL_CM_NODE_SET_CHILD_CONTENT=Set Children Content - -!! NOTE TO TRANSLATOR - USAGE: "Set <variable content> Content" -_UI_LABEL_CM_NODE_SET=Set -_UI_LABEL_CM_NODE_CONTENT=Content - -!! NOTE TO TRANSLATOR - DO NOT TRANSLATE FOLLOWING 3 LINES -_UI_LABEL_CM_NODE_PCDATA=(#PCDATA) -_UI_LABEL_CM_NODE_ANY=ANY -_UI_LABEL_CM_NODE_EMPTY=EMPTY - -! CMRepeatableNode -_UI_LABEL_CM_REP_NODE_CHG_OCCUR=Change Occurrence - -! Comment -_UI_LABEL_COMMENT_CHG=Comment Change - -! DTDFile -_UI_LABEL_DTD_FILE_ADD_ELEMENT=Add Element -_UI_LABEL_DTD_FILE_ADD_ENTITY=Add Entity -_UI_LABEL_DTD_FILE_ADD_COMMENT=Add Comment -_UI_LABEL_DTD_FILE_ADD_PARM_ENTITY_REF=Add Parameter Entity Reference -_UI_LABEL_DTD_FILE_ADD_NOTATION=Add Notation -_UI_LABEL_DTD_FILE_ADD_ATTR_LIST=Add Attribute List -_UI_LABEL_DTD_FILE_DELETE=Delete - -! DTDNode -_UI_LABEL_DTD_NODE_NAME_CHG=Name Change -_UI_LABEL_DTD_NODE_DELETE=Delete - -! Element -_UI_LABEL_ELEMENT_ADD_ATTR=Add Attribute -_UI_LABEL_ELEMENT_ADD_GRP=Add Group -_UI_LABEL_ELEMENT_ADD_CHILD=Add Child Element - -! Entity -_UI_LABEL_ENTITY_SET_PARM_ENTITY=Set Parameter Entity -_UI_LABEL_ENTITY_SET_GENERAL_ENTITY=Set General Entity -_UI_LABEL_ENTITY_SET_EXT_ENTITY=Set External Entity -_UI_LABEL_ENTITY_SET_INT_ENTITY=Set Internal Entity -_UI_LABEL_ENTITY_VALUE_CHG=Entity Value Change - -!! NOTE TO TRANSLATOR - USAGE: "NDATA Change" -_UI_LABEL_ENTITY_NDATA_CHANGE=Change - -! ExternalNode -_UI_LABEL_EXT_NODE_PUBLIC_ID_CHG=Public ID Change -_UI_LABEL_EXT_NODE_SYSTEM_ID_CHG=System ID Change - -! NodeList -_UI_LABEL_NODE_LIST_ELEMENTS=Elements -_UI_LABEL_NODE_LIST_ENTITIES=Entities -_UI_LABEL_NODE_LIST_NOTATIONS=Notations -_UI_LABEL_NODE_LIST_COMMENTS=Comments -_UI_LABEL_NODE_LIST_OTHER=Other -_UI_LABEL_NODE_LIST_ATTRIBUTES=Attributes - -! ParameterEntityReference -_UI_LABEL_PARM_ENTITY_REF_CHG_ENTITY_REF=Change Entity Reference -_UI_LABEL_PARM_ENTITY_REF_COMMENT_CHG=Comment Change - -! TopLevelNode -_UI_LABEL_TOP_LEVEL_NODE_DELETE=Delete - -_ERROR_INCL_FILE_LOAD_FAILURE = Failed to load included file - -! usage: _ERROR_UNDECLARED_ELEMENT_1 + <elementName> + _PARTERROR_UNDECLARED_ELEMENT_2 -_ERROR_UNDECLARED_ELEMENT_1 = Reference to undeclared element ' -_UI_ERRORPART_UNDECLARED_ELEMENT_2 =' in content model. - -! usage: _ERROR_DUP_ID_ATTRIBUTE_1 + <attributeName> + _PARTERROR_DUP_ID_ATTRIBUTE_2 -_ERROR_DUP_ID_ATTRIBUTE_1 = Duplicate ID attribute ' -_UI_ERRORPART_DUP_ID_ATTRIBUTE_2 = '. Only one ID attribute can be specified per ELEMENT type. - -! usage:_ERROR_INVALID_DEFAULT_ATTR_VALUE_1 + <typeString> + _PARTERROR_INVALID_DEFAULT_ATTR_VALUE_2 + <attributeName> -_ERROR_INVALID_DEFAULT_ATTR_VALUE_1 = Invalid default -_UI_ERRORPART_INVALID_DEFAULT_ATTR_VALUE_2 = value for attribute ' - -_EXC_OPERATION_NOT_SUPPORTED = Operation not supported diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDFile.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDFile.java deleted file mode 100644 index 7c5a8e1467..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDFile.java +++ /dev/null @@ -1,674 +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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.document.DTDModelImpl; -import org.eclipse.wst.dtd.core.internal.event.IDTDFileListener; -import org.eclipse.wst.dtd.core.internal.event.NodesEvent; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.util.DTDExternalReferenceRemover; -import org.eclipse.wst.dtd.core.internal.util.DTDModelUpdater; -import org.eclipse.wst.dtd.core.internal.util.DTDNotationReferenceRemover; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent; -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.IStructuredDocumentRegionList; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList; - -public class DTDFile implements IndexedRegion { - private NodeList attlistList = new NodeList(this, DTDRegionTypes.ATTLIST_TAG); - private NodeList commentList = new NodeList(this, DTDRegionTypes.COMMENT_START); - - boolean creatingNewModel = false; - private DTDModelImpl fDTDModel; - - private NodeList elementList = new NodeList(this, DTDRegionTypes.ELEMENT_TAG); - private NodeList entityList = new NodeList(this, DTDRegionTypes.ENTITY_TAG); - - private List folderList = null; - - private boolean isMovingNode = false; - - private List modelListeners = new ArrayList(); - - private List nodeList = new ArrayList(); - private NodeList notationList = new NodeList(this, DTDRegionTypes.NOTATION_TAG); - private NodeList unrecognizedList = new NodeList(this, DTDRegionTypes.UNKNOWN_CONTENT); - - public DTDFile(DTDModelImpl dtdModel) { - this.fDTDModel = dtdModel; - } - - public void addDTDFileListener(IDTDFileListener listener) { - modelListeners.add(listener); - } - - protected void addNode(DTDNode node) { - addNode(nodeList.size(), node); - } - - protected void addNode(int index, DTDNode node) { - nodeList.add(index, node); - /* - * if (index < nodeList.size()) { insertBefore(node, (DTDNode) - * nodeList.get(index)); } else { appendChild(node); } - */ - } - - public DTDNode buildNode(IStructuredDocumentRegion flatNode) { - // ITextRegionList regions = flatNode.getRegions(); - DTDNode node = null; - if (isElement(flatNode)) { - // then this is an element - node = new Element(this, flatNode); - } - else if (isEntity(flatNode)) { - node = new Entity(this, flatNode); - } - else if (isNotation(flatNode)) { - node = new Notation(this, flatNode); - } - else if (isAttributeList(flatNode)) { - node = new AttributeList(this, flatNode); - } - else if (isComment(flatNode)) { - node = new Comment(this, flatNode); - } - else if (isParameterEntityReference(flatNode)) { - node = new ParameterEntityReference(this, flatNode); - } - else if (!flatNode.getText().trim().equals("")) { //$NON-NLS-1$ - node = new Unrecognized(this, flatNode); - } - if (node != null) { - insertNode(node); - node.resolveRegions(); - } - return node; - } - - public void buildNodes(IStructuredDocumentRegionList list) { - NodesEvent addedDTDNodes = new NodesEvent(); - - TopLevelNode previousNode = null; - for (int i = 0; i < list.getLength(); i++) { - IStructuredDocumentRegion flatNode = list.item(i); - TopLevelNode node = (TopLevelNode) buildNode(flatNode); - // if we don't create a node, then we assume that the flat - // node was whitespace. Tack it on to a previous toplevel - // node - if (node != null) { - previousNode = node; - addedDTDNodes.add(node); - } - else { - if (previousNode != null) { - previousNode.addWhitespaceStructuredDocumentRegion(flatNode); - } - } - } - - if (addedDTDNodes.getNodes().size() > 0)// && - // creatingNewModel == false) - { - // now tell people about the additions - notifyNodesAdded(addedDTDNodes); - } - } - - // Implements IndexedRegion - - public boolean contains(int testPosition) { - return getStartOffset() <= testPosition && testPosition <= getEndOffset(); - } - - public void createAttributeList(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_ATTR_LIST); //$NON-NLS-1$ - String newStream = "<!ATTLIST " + name + ">\n"; //$NON-NLS-1$ //$NON-NLS-2$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void createComment(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_COMMENT); //$NON-NLS-1$ - String newStream = "<!-- " + name + " -->\n"; //$NON-NLS-1$ //$NON-NLS-2$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void createElement(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_ELEMENT); //$NON-NLS-1$ - String newStream = "<!ELEMENT " + name + " EMPTY>\n"; //$NON-NLS-1$ //$NON-NLS-2$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void createEntity(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_ENTITY); //$NON-NLS-1$ - String newStream = "<!ENTITY " + name + " \"\">\n"; //$NON-NLS-1$//$NON-NLS-2$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void createNotation(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_NOTATION); //$NON-NLS-1$ - String newStream = "<!NOTATION " + name + " SYSTEM \"\">\n"; //$NON-NLS-1$ //$NON-NLS-2$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void createParameterEntityReference(DTDNode node, String name, boolean isAfter) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_ADD_PARM_ENTITY_REF); //$NON-NLS-1$ - String newStream = name + "\n"; //$NON-NLS-1$ - int offset = getInsertOffset(node, isAfter); - getStructuredDocument().replaceText(this, offset, 0, newStream); - getDTDModel().endRecording(this); - } - - public void deleteNode(DTDNode node) { - getDTDModel().beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_FILE_DELETE); //$NON-NLS-1$ - deleteNode(this, node); - getDTDModel().endRecording(this); - } - - public void deleteNode(Object requestor, DTDNode node) { - DTDNode parent = (DTDNode) node.getParentNode(); - if (parent != null) { - parent.delete(requestor, node); - } - else { - if (!isMovingNode) { - DTDModelUpdater updater = new DTDModelUpdater(); - updater.objectAboutToBeDeleted(requestor, node); - if (node instanceof ParameterEntityReference) { - Entity referencedEntity = ((ParameterEntityReference) node).getEntityObject(); - if (referencedEntity != null) { - // remove references to all elements and parm entities - // contained in our current model - DTDExternalReferenceRemover remover = new DTDExternalReferenceRemover(); - remover.externalReferenceAboutToChange(requestor, referencedEntity); - } - } - else if (node instanceof Notation) { - Notation notation = ((Notation) node); - DTDNotationReferenceRemover remover = new DTDNotationReferenceRemover(); - remover.notationAboutToBeDeleted(requestor, notation); - } - } - - // no parent? then delete up until the start of the next node - // if it is a top level node - int startOffset = node.getStartOffset(); - int endOffset = node.getWhitespaceEndOffset(); - if (node instanceof TopLevelNode) { - endOffset = getInsertOffset(node, true); - } - getStructuredDocument().replaceText(requestor, startOffset, endOffset - startOffset, ""); //$NON-NLS-1$ - } - } - - public NodeList getComments() { - return commentList; - } - - public DTDModelImpl getDTDModel() { - return fDTDModel; - } - - public NodeList getElementsAndParameterEntityReferences() { - return elementList; - } - - public int getEndOffset() { - int result = -1; - IStructuredDocumentRegion region = getStructuredDocument().getLastStructuredDocumentRegion(); - if (region != null) { - result = region.getEndOffset(); - } - return result; - } - - public int getLength() { - int result = -1; - int start = getStartOffset(); - if (start >= 0) { - int end = getEndOffset(); - if (end >= 0) { - result = end - start; - if (result < -1) { - result = -1; - } - } - } - return result; - } - - public NodeList getEntities() { - return entityList; - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.DTDFILEICON); - } - - - - public int getInsertOffset(DTDNode node, boolean isAfter) { - int offset = 0; - if (node != null) { - if (isAfter) { - // then get the next node and use it's start offset - int index = getNodes().indexOf(getNode(node.getStructuredDTDDocumentRegion())); - - DTDNode afterNode = null; - if (index + 1 < getNodes().size()) { - afterNode = (DTDNode) getNodes().get(index + 1); - } - if (afterNode != null) { - offset = afterNode.getStructuredDTDDocumentRegion().getStartOffset(); - } - else { - // add to end - if (getStructuredDocument().getLastStructuredDocumentRegion() != null) { - offset = getStructuredDocument().getLastStructuredDocumentRegion().getEndOffset(); - } - } - } - else { - offset = node.getStructuredDTDDocumentRegion().getStartOffset(); - } - } - else { - // add to end - if (getStructuredDocument().getLastStructuredDocumentRegion() != null) { - offset = getStructuredDocument().getLastStructuredDocumentRegion().getEndOffset(); - } - } - return offset; - } - - public String getName() { - org.eclipse.core.runtime.Path path = new org.eclipse.core.runtime.Path(getDTDModel().getId().toString()); - return path.lastSegment(); - } - - public DTDNode getNode(IStructuredDocumentRegion flatNode) { - for (int i = 0; i < nodeList.size(); i++) { - DTDNode node = (DTDNode) nodeList.get(i); - if (node.getStructuredDTDDocumentRegion() == flatNode) { - return node; - } - } - return null; - } - - public IndexedRegion getNodeAt(int offset) { - DTDNode node = getTopLevelNodeAt(offset); - if (node != null) { - return node.getDeepestNode(offset); - } - return null; - } - - public IndexedRegion getNodeAt(int startOffset, int endOffset) { - DTDNode node = getTopLevelNodeAt(startOffset); - if (node != null) { - return node.getDeepestNode(startOffset, endOffset); - } - return null; - } - - public List getNodeLists() { - if (folderList == null) { - folderList = new ArrayList(); - folderList.add(notationList); - folderList.add(entityList); - folderList.add(elementList); - folderList.add(attlistList); - folderList.add(commentList); - folderList.add(unrecognizedList); - } - return folderList; - } - - public List getNodes() { - return nodeList; - } - - public NodeList getNotations() { - return notationList; - } - - public int getStartOffset() { - int result = -1; - IStructuredDocumentRegion region = getStructuredDocument().getFirstStructuredDocumentRegion(); - if (region != null) { - result = region.getStartOffset(); - } - return result; - } - - public IStructuredDocument getStructuredDocument() { - return fDTDModel.getStructuredDocument(); - } - - public DTDNode getTopLevelNodeAt(int offset) { - for (int i = 0; i < nodeList.size(); i++) { - DTDNode node = (DTDNode) nodeList.get(i); - if (node.contains(offset)) { - return node; - } - } - return null; - } - - public NodeList getUnrecognized() { - return unrecognizedList; - } - - public void insertIntoModel(Object requestor, DTDNode reference, DTDNode node, boolean isAfter) { - String nodeText = ""; //$NON-NLS-1$ - if (node instanceof TopLevelNode) { - nodeText = ((TopLevelNode) node).getFullText(); - } - else { - nodeText = node.getNodeText(); - } - int offset = getInsertOffset(reference, isAfter); - getStructuredDocument().replaceText(requestor, offset, 0, nodeText); - } - - - public void insertNode(DTDNode node) { - int startOffset = node.getStartOffset(); - int insertIndex = -1; - // System.out.println("startoffset = " + startOffset); - for (int i = 0; i < getNodes().size(); i++) { - DTDNode currentNode = (DTDNode) getNodes().get(i); - // System.out.println("currentNode endOffset = " - // +currentNode.getEndOffset()); - - if (currentNode.getEndOffset() > startOffset) { - // System.out.println("endoffset " + - // currentNode.getEndOffset() + " > " + startOffset); - insertIndex = i; - break; - } - } - if (insertIndex == -1) { - insertIndex = getNodes().size(); - } - - - // System.out.println("insert index = " + insertIndex); - - addNode(insertIndex, node); - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isAttributeList(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() >= 3) { - ITextRegion second = flatNode.getRegions().get(1); - ITextRegion third = flatNode.getRegions().get(2); - if (second.getType().equals(DTDRegionTypes.EXCLAMATION) && third.getType().equals(DTDRegionTypes.ATTLIST_TAG)) { - return true; - } - } - return false; - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isComment(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() >= 2) { - ITextRegion region = flatNode.getRegions().get(1); - if (region.getType().equals(DTDRegionTypes.COMMENT_START)) { - return true; - } - } - return false; - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isElement(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() >= 3) { - ITextRegion second = flatNode.getRegions().get(1); - ITextRegion third = flatNode.getRegions().get(2); - if (second.getType().equals(DTDRegionTypes.EXCLAMATION) && third.getType().equals(DTDRegionTypes.ELEMENT_TAG)) { - return true; - } - } - return false; - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isEntity(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() >= 3) { - ITextRegion second = flatNode.getRegions().get(1); - ITextRegion third = flatNode.getRegions().get(2); - if (second.getType().equals(DTDRegionTypes.EXCLAMATION) && third.getType().equals(DTDRegionTypes.ENTITY_TAG)) { - return true; - } - } - return false; - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isNotation(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() >= 3) { - ITextRegion second = flatNode.getRegions().get(1); - ITextRegion third = flatNode.getRegions().get(2); - if (second.getType().equals(DTDRegionTypes.EXCLAMATION) && third.getType().equals(DTDRegionTypes.NOTATION_TAG)) { - return true; - } - } - return false; - } - - // it is assumed that flatnode contains at least 3 regions - public boolean isParameterEntityReference(IStructuredDocumentRegion flatNode) { - if (flatNode.getRegions().size() == 1) { - ITextRegion region = flatNode.getRegions().get(0); - if (region.getType().equals(DTDRegionTypes.ENTITY_PARM)) { - return true; - } - } - return false; - } - - boolean isSameTopLevelType(DTDNode affectedNode) { - IStructuredDocumentRegion flatNode = affectedNode.getStructuredDTDDocumentRegion(); - // return true if the flatnode still matches what the affectedNode - // is representing - if (affectedNode instanceof Element && isElement(flatNode)) { - return true; - } - if (affectedNode instanceof Entity && isEntity(flatNode)) { - return true; - } - if (affectedNode instanceof Comment && isComment(flatNode)) { - return true; - } - if (affectedNode instanceof AttributeList && isAttributeList(flatNode)) { - return true; - } - if (affectedNode instanceof Notation && isNotation(flatNode)) { - return true; - } - if (affectedNode instanceof Unrecognized && isUnrecognized(flatNode)) { - return true; - } - return false; - } - - public boolean isUnrecognized(IStructuredDocumentRegion flatNode) { - return !isElement(flatNode) && !isEntity(flatNode) && !isNotation(flatNode) && !isParameterEntityReference(flatNode) && !isAttributeList(flatNode) && !isComment(flatNode); - } - - public void moveNode(Object requestor, DTDNode referenceNode, DTDNode nodeToMove, boolean isAfter) { - isMovingNode = true; - - deleteNode(requestor, nodeToMove); - insertIntoModel(requestor, referenceNode, nodeToMove, isAfter); - isMovingNode = false; - } - - public void newModel(NewDocumentEvent event) { - creatingNewModel = true; - nodeList.clear(); - NodesEvent removeEvent = new NodesEvent(); - removeEvent.getNodes().addAll(nodeList); - notifyNodesRemoved(removeEvent); - /* removeChildNodes(); */ - - if (event.getStructuredDocument() != null && event.getStructuredDocument().getRegionList() != null) { - buildNodes(event.getStructuredDocument().getRegionList()); - } - creatingNewModel = false; - } - - public void nodesReplaced(StructuredDocumentRegionsReplacedEvent event) { - IStructuredDocumentRegionList oldNodes = event.getOldStructuredDocumentRegions(); - NodesEvent removedDTDNodes = new NodesEvent(); - for (int i = 0; i < oldNodes.getLength(); i++) { - IStructuredDocumentRegion flatNode = oldNodes.item(i); - - for (Iterator iter = getNodes().iterator(); iter.hasNext();) { - DTDNode node = (DTDNode) iter.next(); - if (node.getStructuredDTDDocumentRegion() == flatNode) { - removedDTDNodes.add(node); - } - } - } - - buildNodes(event.getNewStructuredDocumentRegions()); - - if (removedDTDNodes.getNodes().size() > 0) { - notifyNodesRemoved(removedDTDNodes); - removeNodes(removedDTDNodes.getNodes()); - } - } - - public void notifyNodeChanged(DTDNode node) { - Iterator iter = modelListeners.iterator(); - while (iter.hasNext()) { - IDTDFileListener listener = (IDTDFileListener) iter.next(); - listener.nodeChanged(node); - } - } - - public void notifyNodesAdded(NodesEvent addedNodes) { - Iterator iter = modelListeners.iterator(); - while (iter.hasNext()) { - IDTDFileListener listener = (IDTDFileListener) iter.next(); - listener.nodesAdded(addedNodes); - } - } - - protected void notifyNodesRemoved(NodesEvent event) { - Iterator iter = modelListeners.iterator(); - while (iter.hasNext()) { - IDTDFileListener listener = (IDTDFileListener) iter.next(); - listener.nodesRemoved(event); - } - } - - public void rebuildNodes(List nodes) { - // remove the old nodes - removeNodes(nodes); - - // now rebuild them - NodesEvent addedDTDNodes = new NodesEvent(); - Iterator dtdNodes = nodes.iterator(); - while (dtdNodes.hasNext()) { - DTDNode dtdNode = (DTDNode) dtdNodes.next(); - // System.out.println("rebuilding " + - // dtdNode.getStructuredDocumentRegion().getText()); - - DTDNode node = buildNode(dtdNode.getStructuredDTDDocumentRegion()); - if (node != null) { - addedDTDNodes.add(node); - } - } - if (addedDTDNodes.getNodes().size() > 0) { - // now tell people about the additions - notifyNodesAdded(addedDTDNodes); - } - } - - public void regionChanged(RegionChangedEvent event) { - ITextRegion changedRegion = event.getRegion(); - IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion(); - DTDNode affectedNode = (DTDNode) getNodeAt(flatNode.getStartOffset(changedRegion), flatNode.getEndOffset(changedRegion)); - if (affectedNode != null) { - // no need to resolve regions as it is just a change - // affectedNode.resolveRegions(); - notifyNodeChanged(affectedNode); - } - } - - public void regionsReplaced(RegionsReplacedEvent event) { - List nodesToRebuild = new ArrayList(); - IStructuredDocumentRegion flatNode = event.getStructuredDocumentRegion(); - DTDNode affectedNode = getNode(flatNode); - - if (!isSameTopLevelType(affectedNode)) { - nodesToRebuild.add(affectedNode); - rebuildNodes(nodesToRebuild); - } - else { - affectedNode.resolveRegions(); - notifyNodeChanged(affectedNode); - // now try and determine which ones were added - NodesEvent addedDTDNodes = new NodesEvent(); - ITextRegionList newRegions = event.getNewRegions(); - int size = newRegions.size(); - for (int i = 0; i < size; i++) { - ITextRegion region = newRegions.get(i); - DTDNode deepestNode = affectedNode.getDeepestNode(flatNode.getStartOffset(region), flatNode.getEndOffset(region)); - if (!addedDTDNodes.getNodes().contains(deepestNode)) { - addedDTDNodes.add(deepestNode); - } - } - if (addedDTDNodes.getNodes().size() > 0) { - notifyNodesAdded(addedDTDNodes); - } - } - } - - public void removeDTDFileListener(IDTDFileListener listener) { - modelListeners.remove(listener); - } - - protected void removeNodes(List nodes) { - getNodes().removeAll(nodes); - /* - * for (int i = 0; i < nodes.size(); i++) { - * removeChild((DTDNode)nodes.get(i)); } // end of for () - */ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDNode.java deleted file mode 100644 index b15037cbdb..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDNode.java +++ /dev/null @@ -1,330 +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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.document.DTDModelImpl; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.model.FactoryRegistry; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -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.text.TextRegionListImpl; -import org.eclipse.wst.xml.core.internal.document.NodeContainer; -import org.w3c.dom.Node; - - -public abstract class DTDNode extends NodeContainer implements IndexedRegion { - - // these are characteroffsets - protected DTDFile dtdFile; - - // flat node that contains this node - protected IStructuredDocumentRegion flatNode; - - protected TextRegionListImpl regions = new TextRegionListImpl(); - - protected TextRegionListImpl whitespace = new TextRegionListImpl(); - - public DTDNode(DTDFile dtdFile, IStructuredDocumentRegion flatNode) { - this.dtdFile = dtdFile; - this.flatNode = flatNode; - } - - public void addRegion(ITextRegion region) { - /* - * if (startRegion == null) { startRegion = region; } endRegion = - * region; - */ - regions.add(region); - } - - public void addWhitespaceRegion(ITextRegion region) { - whitespace.add(region); - } - - public void beginRecording(Object requestor, String label) { - getDTDFile().getDTDModel().beginRecording(requestor, label); - } - - public Node cloneNode(boolean deepest) { - return null; - } - - public boolean contains(int testPosition) { - return containsRange(testPosition, testPosition); - } - - public boolean containsRange(int start, int end) { - return getStartOffset() <= start && end <= getEndOffset(); - } - - public void delete(DTDNode child) { - beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_NODE_DELETE); //$NON-NLS-1$ - delete(this, child); - endRecording(this); - } - - public void delete(Object requestor, DTDNode child) { - replaceText(requestor, child.getStartOffset(), child.getFullNodeLength(), ""); //$NON-NLS-1$ - } - - public void endRecording(Object requestor) { - getDTDFile().getDTDModel().endRecording(requestor); - } - - public Object[] getChildren() { - return getChildrenList().toArray(); - } - - public List getChildrenList() { - Node child = getFirstChild(); - if (child != null) { - List children = new ArrayList(); - for (; child != null; child = child.getNextSibling()) { - children.add(child); - } - return children; - } - else { - return Collections.EMPTY_LIST; - } - } - - public DTDNode getDeepestNode(int offset) { - if (contains(offset)) { - // now see if a child contains this offset - Object[] children = getChildren(); - for (int i = 0; i < children.length; i++) { - DTDNode child = (DTDNode) children[i]; - DTDNode deepest = child.getDeepestNode(offset); - if (deepest != null) { - return deepest; - } - } // end of for () - return this; - } - return null; - } - - public DTDNode getDeepestNode(int start, int end) { - if (containsRange(start, end)) { - // now see if a child contains this offset - Object[] children = getChildren(); - for (int i = 0; i < children.length; i++) { - DTDNode child = (DTDNode) children[i]; - DTDNode deepest = child.getDeepestNode(start, end); - if (deepest != null) { - return deepest; - } - } // end of for () - return this; - } - return null; - } - - public DTDFile getDTDFile() { - return dtdFile; - } - - public int getEndOffset() { - return getStructuredDTDDocumentRegion().getEndOffset(getEndRegion()); - } - - public ITextRegion getEndRegion() { - return regions.get(regions.size() - 1);// endRegion; - } - - /** - */ - public FactoryRegistry getFactoryRegistry() { - DTDModelImpl model = dtdFile.getDTDModel(); - if (model != null) { - FactoryRegistry reg = model.getFactoryRegistry(); - if (reg != null) - return reg; - } - return null; - } - - public int getFullNodeLength() { - return getWhitespaceEndOffset() - getStartOffset(); - } - - public String getFullNodeText() { - String text = getNodeText(); - if (whitespace.size() > 0) { - RegionIterator iter = new RegionIterator(whitespace); - while (iter.hasNext()) { - ITextRegion region = iter.next(); - text += getStructuredDTDDocumentRegion().getText(region); - } - } - return text; - } - - abstract public Image getImage(); - - public String getName() { - ITextRegion region = getNameRegion(); - if (region != null) { - return getStructuredDTDDocumentRegion().getText(region); - } - return ""; //$NON-NLS-1$ - } - - public ITextRegion getNameRegion() { - RegionIterator iter = iterator(); - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType() == DTDRegionTypes.NAME) { - return region; - } - } - return null; - } - - // return the first token containing the specified token type - public ITextRegion getNextRegion(RegionIterator iter, String type) { - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType().equals(type)) { - return region; - } - } - return null; - } - - public int getNodeLength() { - return getEndOffset() - getStartOffset(); - } - - public String getNodeName() { - return getName(); - } - - public String getNodeText() { - StringBuffer sb = new StringBuffer(); - - RegionIterator iter = iterator(); - while (iter.hasNext()) { - ITextRegion region = iter.next(); - sb.append(getStructuredDTDDocumentRegion().getText(region)); - } - return sb.toString(); - } - - public short getNodeType() { - return -1; - } - - public int getStartOffset() { - return getStructuredDTDDocumentRegion().getStartOffset(getStartRegion()); - } - - // private Region startRegion,endRegion; - public ITextRegion getStartRegion() { - return regions.get(0); - // return startRegion; - } - - /** - * Get the value of flatNode. - * - * @return value of flatNode. - * - * ISSUE:named changed not to be confused with default access protected - * super class method, but should re-think if this is correct technique. - * Perhaps getFirstRegion? - */ - public IStructuredDocumentRegion getStructuredDTDDocumentRegion() { - return flatNode; - } - - // return end offset including whitespace - // or just the end offset if there is no whitespace - public int getWhitespaceEndOffset() { - if (whitespace.size() > 0) { - ITextRegion region = whitespace.get(whitespace.size() - 1); - return getStructuredDTDDocumentRegion().getEndOffset(region); - } - - return getEndOffset(); - } - - public boolean hasTrailingWhitespace() { - return whitespace.size() > 0; - } - - public RegionIterator iterator() { - // System.out.println("create region iter " + this.getClass() + " with - // start , end = " + getStartOffset() + ", " +getEndOffset()); - return new RegionIterator(regions); - } - - public void replaceText(Object requestor, int start, int length, String newText) { - getDTDFile().getStructuredDocument().replaceText(requestor, start, length, newText); - } - - public void resolveRegions() { - } - - public void setName(Object requestor, String name) { - if (!getName().equals(name)) { - ITextRegion nameRegion = getNameRegion(); - if (nameRegion != null) { - // nameToken.updateText(name); - getDTDFile().getDTDModel().getReferenceUpdater().nameAboutToChange(requestor, this, name); - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(nameRegion), nameRegion.getLength(), name); - } - } - } - - public void setName(String name) { - beginRecording(this, DTDCoreMessages._UI_LABEL_DTD_NODE_NAME_CHG); //$NON-NLS-1$ - setName(this, name); - endRecording(this); - } - - /** - * Set the value of flatNode. - * - * @param v - * Value to assign to flatNode. ISSUE:named changed not to be - * confused with default access protected super class method, - * but should re-think if this is correct technique - */ - void setStructuredDTDDocumentRegion(IStructuredDocumentRegion v) { - this.flatNode = v; - } - - // skips past next name token in the iterator - protected void skipPastName(RegionIterator iter) { - while (iter.hasNext()) { - ITextRegion currentRegion = iter.next(); - if (currentRegion.getType() == DTDRegionTypes.NAME) { - break; - } - } - } - - public boolean supports(java.lang.String feature, java.lang.String version) { - return false; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDResource.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDResource.java deleted file mode 100644 index c7d244050e..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/DTDResource.java +++ /dev/null @@ -1,56 +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.dtd.core.internal; - - -public interface DTDResource { - // Enumeration Constants - public static final String ANYICON = "icons/full/obj16/any.gif"; //$NON-NLS-1$ - public static final String ATTRIBUTEICON = "icons/full/obj16/attribute.gif"; //$NON-NLS-1$ - public static final String ATTRIBUTELISTICON = "icons/full/obj16/attribute_list.gif"; //$NON-NLS-1$ - public static final String COMMENTICON = "icons/full/obj16/comment.gif"; //$NON-NLS-1$ - - public static final String DTDFILEICON = "icons/full/obj16/DTDFile.gif"; //$NON-NLS-1$ - public static final String ELEMENTICON = "icons/full/obj16/element.gif"; //$NON-NLS-1$ - public static final String ELEMENTREFICON = "icons/full/obj16/element_ref.gif"; //$NON-NLS-1$ - public static final String EMPTYICON = "icons/full/obj16/emptycontent.gif"; //$NON-NLS-1$ - public static final String ENTITYICON = "icons/full/obj16/entity.gif"; //$NON-NLS-1$ - public static final String ENTITYREFERENCEICON = "icons/full/obj16/entity_reference.gif"; //$NON-NLS-1$ - public static final String FLDR_ATTLIST = "icons/full/obj16/folder_attlist_obj.gif"; //$NON-NLS-1$ - public static final String FLDR_COMM = "icons/full/obj16/folder_comments_obj.gif"; //$NON-NLS-1$ - - public static final String FLDR_EL = "icons/full/obj16/fldr_el.gif"; //$NON-NLS-1$ - public static final String FLDR_ENT = "icons/full/obj16/fldr_ent.gif"; //$NON-NLS-1$ - public static final String FLDR_NOT = "icons/full/obj16/fldr_not.gif"; //$NON-NLS-1$ - public static final String FLDR_UNREC = "icons/full/obj16/fldr_unrec.gif"; //$NON-NLS-1$ - - public static final String NEWHTMLFORM = "icons/full/obj16/genhtmform_wiz.gif"; //$NON-NLS-1$ - public static final String NOTATIONICON = "icons/full/obj16/notation.gif"; //$NON-NLS-1$ - - public static final String ONECHOICEICON = "icons/full/obj16/onechoice.gif"; //$NON-NLS-1$ - - public static final String ONEICON = "icons/full/obj16/one.gif"; //$NON-NLS-1$ - public static final String ONEORMORECHOICEICON = "icons/full/obj16/oneormorechoice.gif"; //$NON-NLS-1$ - public static final String ONEORMOREICON = "icons/full/obj16/oneormore.gif"; //$NON-NLS-1$ - public static final String ONEORMORESEQUENCEICON = "icons/full/obj16/oneormoresequence.gif"; //$NON-NLS-1$ - - public static final String ONESEQUENCEICON = "icons/full/obj16/onesequence.gif"; //$NON-NLS-1$ - public static final String OPTIONALCHOICEICON = "icons/full/obj16/optionalchoice.gif"; //$NON-NLS-1$ - public static final String OPTIONALICON = "icons/full/obj16/optional.gif"; //$NON-NLS-1$ - public static final String OPTIONALSEQUENCEICON = "icons/full/obj16/optionalsequence.gif"; //$NON-NLS-1$ - public static final String PCDATAICON = "icons/full/obj16/txtext.gif"; //$NON-NLS-1$ - public static final String UNRECOGNIZEDICON = "icons/full/obj16/unrecognized_content.gif"; //$NON-NLS-1$ - public static final String ZEROORMORECHOICEICON = "icons/full/obj16/zeroormorechoice.gif"; //$NON-NLS-1$ - public static final String ZEROORMOREICON = "icons/full/obj16/zeroormore.gif"; //$NON-NLS-1$ - public static final String ZEROORMORESEQUENCEICON = "icons/full/obj16/zeroormoresequence.gif"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Element.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Element.java deleted file mode 100644 index 04904e529b..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Element.java +++ /dev/null @@ -1,205 +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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; -import org.w3c.dom.Node; - - -public class Element extends NamedTopLevelNode { - - List attListList = new ArrayList(); - - List attributes = new ArrayList(); - - protected CMNode fContentModel; - - public Element(DTDFile dtdFile, IStructuredDocumentRegion flatNode) { - super(dtdFile, flatNode, DTDRegionTypes.ELEMENT_TAG); - } - - public void addAttribute(String name) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ELEMENT_ADD_ATTR); //$NON-NLS-1$ - List attLists = getAttributeLists(); - if (attLists.size() == 0) { - getDTDFile().createAttributeList(this, getName(), true); - attLists = getAttributeLists(); - } - if (attLists.size() > 0) { - AttributeList attList = (AttributeList) attLists.get(attLists.size() - 1); - attList.addAttribute(name); - } - endRecording(this); - } - - public void addChild() { - beginRecording(this, DTDCoreMessages._UI_LABEL_ELEMENT_ADD_CHILD); //$NON-NLS-1$ - addContent(this, " EMPTY"); //$NON-NLS-1$ - endRecording(this); - } - - protected void addContent(Object requestor, String content) { - ITextRegion whitespace = getWhitespaceAfterName(); - int startOffset = 0; - int length = 0; - if (whitespace != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(whitespace); - length = whitespace.getLength() >= 2 ? 1 : 0; - } - else { - ITextRegion nameRegion = getNameRegion(); - if (nameRegion != null) { - startOffset = getStructuredDTDDocumentRegion().getEndOffset(nameRegion); - } - else { - ITextRegion elementTag = getNextRegion(iterator(), DTDRegionTypes.ELEMENT_TAG); - startOffset = getStructuredDTDDocumentRegion().getEndOffset(elementTag); - } - } - replaceText(requestor, startOffset, length, content); - } - - public void addGroup() { - beginRecording(this, DTDCoreMessages._UI_LABEL_ELEMENT_ADD_GRP); //$NON-NLS-1$ - addContent(this, " ()"); //$NON-NLS-1$ - endRecording(this); - } - - public Node cloneNode(boolean deep) { - return new Element(dtdFile, flatNode); - } - - public List getAttributeLists() { - attListList.clear(); - String elementName = getName(); - Iterator iter = dtdFile.getNodes().iterator(); - while (iter.hasNext()) { - DTDNode node = (DTDNode) iter.next(); - if (node instanceof AttributeList && node.getName().equals(elementName)) { - attListList.add(node); - } - } - return attListList; - } - - - - public CMNode getContentModel() { - // Object[] children = getChildren() - return (CMNode) getFirstChild();// contentModel; - } - - public List getElementAttributes() { - attributes.clear(); - Iterator attLists = getAttributeLists().iterator(); - while (attLists.hasNext()) { - AttributeList attList = (AttributeList) attLists.next(); - - Object[] children = attList.getChildren(); - for (int i = 0; i < children.length; i++) { - attributes.add(children[i]); - } - } - return attributes; - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.ELEMENTICON); - } - - public short getNodeType() { - return Node.ELEMENT_NODE; - } - - public void replaceContentModel(Object requestor, CMNode node) { - replaceContentModel(requestor, node.getNodeText()); - } - - public void replaceContentModel(Object requestor, String nodeText) { - int offset = 0; - int length = 0; - CMNode contentModel = getContentModel(); - if (contentModel != null) { - offset = contentModel.getStartOffset(); - length = contentModel.getWhitespaceEndOffset() - offset; - replaceText(requestor, offset, length, nodeText); - } - else { - addContent(requestor, nodeText); - } - } - - public void resolveRegions() { - // System.out.println("element node stream = " + - // tokenStream.getString()); - fContentModel = null; - removeChildNodes(); - RegionIterator iter = iterator(); - - if (getNameRegion() != null) { - // we skip past the name token is our name - skipPastName(iter); - } - - while (iter.hasNext()) { - ITextRegion currentRegion = iter.next(); - - if (fContentModel == null) { - if (currentRegion.getType().equals(DTDRegionTypes.NAME)) { - fContentModel = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion()); - } - else if (currentRegion.getType().equals(DTDRegionTypes.CONTENT_PCDATA)) { - fContentModel = new CMBasicNode(getDTDFile(), getStructuredDTDDocumentRegion()); - } - else if (currentRegion.getType().equals(DTDRegionTypes.LEFT_PAREN)) { - fContentModel = new CMGroupNode(getDTDFile(), getStructuredDTDDocumentRegion()); - } - } - - if (fContentModel != null) { - if (!currentRegion.getType().equals(DTDRegionTypes.END_TAG)) { - // content model gets all regions except for the '>' - fContentModel.addRegion(currentRegion); - } - else { - // if it is equal to the end tag, then don't add anymore - // regions - // for the content model - break; - } - - } - - } - if (fContentModel != null) { - appendChild(fContentModel); - // this is the root element content so set it true - fContentModel.setRootElementContent(true); - // now tell the content model to resolve it's regions - fContentModel.resolveRegions(); - - } - } - - public void setContentModel(CMNode contentModel) { - this.fContentModel = contentModel; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Entity.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Entity.java deleted file mode 100644 index 2ed2f42156..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Entity.java +++ /dev/null @@ -1,333 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -// external node contains code to help set and get public ids -public class Entity extends ExternalNode { - - private static String setExternalEntity = DTDCoreMessages._UI_LABEL_ENTITY_SET_EXT_ENTITY; //$NON-NLS-1$ - private static String setGeneralEntity = DTDCoreMessages._UI_LABEL_ENTITY_SET_GENERAL_ENTITY; //$NON-NLS-1$ - private static String setInternalEntity = DTDCoreMessages._UI_LABEL_ENTITY_SET_INT_ENTITY; //$NON-NLS-1$ - - private static String setParameterEntity = DTDCoreMessages._UI_LABEL_ENTITY_SET_PARM_ENTITY; //$NON-NLS-1$ - - public Entity(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode, DTDRegionTypes.ENTITY_TAG); - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.ENTITYICON); - } - - - /** - * Get the value of notationName. - * - * @return value of notationName. - */ - public String getNotationName() { - ITextRegion ndataRegion = getNextRegion(iterator(), DTDRegionTypes.NDATA_VALUE); - if (ndataRegion != null) { - return getStructuredDTDDocumentRegion().getText(ndataRegion); - } - return ""; //$NON-NLS-1$ - } - - public ITextRegion getPercentRegion() { - return getNextRegion(iterator(), DTDRegionTypes.PERCENT); - } - - /** - * Get the value of value. - * - * @return value of value. - */ - public String getValue() { - if (!isExternalEntity()) { - ITextRegion valueRegion = getNextQuotedLiteral(iterator()); - if (valueRegion != null) { - return getValueFromQuotedRegion(valueRegion); - } - } - return ""; //$NON-NLS-1$ - } - - /** - * Get the value of externalEntity. - * - * @return value of externalEntity. - */ - public boolean isExternalEntity() { - return getPublicKeywordRegion(iterator()) != null || getSystemKeywordRegion(iterator()) != null; - } - - /** - * Get the value of isParameterEntity. - * - * @return value of isParameterEntity. - */ - public boolean isParameterEntity() { - return getPercentRegion() != null; - } - - private void removeNData(Object requestor) { - ITextRegion ndataRegion = null; - - // see if we have an NDATA keyword - ndataRegion = getNextRegion(iterator(), DTDRegionTypes.NDATA_KEYWORD); - int startOffset = 0, endOffset = 0; - if (ndataRegion != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(ndataRegion); - endOffset = getStructuredDTDDocumentRegion().getEndOffset(ndataRegion); - } - ITextRegion value = getNextRegion(iterator(), DTDRegionTypes.NDATA_VALUE); - if (value != null) { - if (startOffset == 0) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(value); - } - endOffset = getStructuredDTDDocumentRegion().getEndOffset(value); - } - replaceText(requestor, startOffset, endOffset - startOffset, ""); //$NON-NLS-1$ - } - - /** - * Set the value of externalEntity. - * - * @param v - * Value to assign to externalEntity. - */ - public void setExternalEntity(boolean isExternalEntity) { - if (isExternalEntity() != isExternalEntity) { - // externalEntity = v; - beginRecording(this, isExternalEntity ? setExternalEntity : setInternalEntity); - if (isExternalEntity) { - // we need to get rid of the value literal - ITextRegion quote = getNextRegion(iterator(), DTDRegionTypes.SINGLEQUOTED_LITERAL); - if (quote == null) { - quote = getNextRegion(iterator(), DTDRegionTypes.DOUBLEQUOTED_LITERAL); - } - if (quote != null) { - replaceText(this, getStructuredDTDDocumentRegion().getStartOffset(quote), quote.getLength(), ""); //$NON-NLS-1$ - } - setSystemID(""); //$NON-NLS-1$ - } - else { - // we need to get rid of text between end of name region and - // the last double quoted literal - RegionIterator iter = iterator(); - ITextRegion keyword = getSystemKeywordRegion(iter); - int startOffset = 0; - int length = 0; - if (keyword == null) { - // reset the iterator - iter = iterator(); - keyword = getPublicKeywordRegion(iter); - } - if (keyword != null) { - startOffset = getStructuredDTDDocumentRegion().getStartOffset(keyword); - // start with a length just equal to the keyword for now - length = keyword.getLength(); - } - else { - // reset the iterator since we didn't find the keyword - iter = iterator(); - // just go from after the name - startOffset = getStructuredDTDDocumentRegion().getEndOffset(getNameRegion()); - } - - // now that we have the start, look for the end - ITextRegion lastRegion = null; - - if (lastRegion == null) { - // then look for last quoted literal - while (iter.hasNext()) { - ITextRegion literal = getNextQuotedLiteral(iter); - if (literal != null) { - lastRegion = literal; - } - } - } - - if (lastRegion != null) { - length = getStructuredDTDDocumentRegion().getEndOffset(lastRegion) - startOffset; - } - replaceText(this, startOffset, length, "\"\""); //$NON-NLS-1$ - removeNData(this); - } - endRecording(this); - } - } - - public void setNotationName(Object requestor, String newNotation) { - if (!getNotationName().equals(newNotation)) { - if (!newNotation.equals("")) { //$NON-NLS-1$ - // - ITextRegion ndataRegion = getNextRegion(iterator(), DTDRegionTypes.NDATA_VALUE); - if (ndataRegion != null) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(ndataRegion), ndataRegion.getLength(), newNotation); - } - else { - // time to create one - int startOffset = 0; - String string = ""; //$NON-NLS-1$ - RegionIterator iter = iterator(); - ITextRegion ndataKeyword = getNextRegion(iter, DTDRegionTypes.NDATA_KEYWORD); - if (ndataKeyword == null) { - // we'll need to create one after the last quoted - // literal - // Reset iterator - string += " NDATA "; //$NON-NLS-1$ - iter = iterator(); - ITextRegion lastQuotedLiteral = null; - while (iter.hasNext()) { - ITextRegion literal = getNextQuotedLiteral(iter); - if (literal != null) { - lastQuotedLiteral = literal; - } - } - if (lastQuotedLiteral != null) { - startOffset = getStructuredDTDDocumentRegion().getEndOffset(lastQuotedLiteral); - } - else { - // created after the system or public keyword - ITextRegion keyword = getPublicKeywordRegion(iterator()); - if (keyword == null) { - keyword = getSystemKeywordRegion(iterator()); - } - // we shouldn't be null here since we check if we - // were external already - startOffset = getStructuredDTDDocumentRegion().getEndOffset(keyword); - } - - } - else { - startOffset = getStructuredDTDDocumentRegion().getEndOffset(ndataKeyword); - } - replaceText(requestor, startOffset, 0, string + newNotation); - } - } - else { - // need to remove the ndata stuff - removeNData(requestor); - } - } - } - - /** - * Set the value of notationName. - * - * @param newNotation - * Value to assign to notationName. - */ - public void setNotationName(String newNotation) { - beginRecording(this, "NDATA " + DTDCoreMessages._UI_LABEL_ENTITY_NDATA_CHANGE); //$NON-NLS-1$ //$NON-NLS-2$ - setNotationName(this, newNotation); - endRecording(this); - } - - /** - * Set the value of isParameterEntity. - * - * @param v - * Value to assign to isParameterEntity. - */ - public void setParameterEntity(boolean v) { - if (isParameterEntity() != v) { - beginRecording(this, v ? setParameterEntity : setGeneralEntity); - if (v) { - RegionIterator iter = iterator(); - ITextRegion startTag = getNextRegion(iter, DTDRegionTypes.ENTITY_TAG); - int startOffset = 0, length = 0; - - if (iter.hasNext()) { - ITextRegion region = iter.next(); - startOffset = getStructuredDTDDocumentRegion().getStartOffset(region); - if (region.getType() == DTDRegionTypes.WHITESPACE && region.getLength() > 1) { - length = 1; - } - } - else { - startOffset = getStructuredDTDDocumentRegion().getEndOffset(startTag); - } - replaceText(this, startOffset, length, " %"); //$NON-NLS-1$ - // now get rid of any NData since it is only allowed if the - // entity is a general entity and not a parameter entity - removeNData(this); - } - else { - // get rid of percent region - ITextRegion percentRegion = getPercentRegion(); - replaceText(this, getStructuredDTDDocumentRegion().getStartOffset(percentRegion), percentRegion.getLength(), ""); //$NON-NLS-1$ - } - - endRecording(this); - } - } - - /** - * Set the value of value. - * - * @param v - * Value to assign to value. - */ - public void setValue(Object requestor, String v) { - if (!isExternalEntity()) { - if (!getValue().equals(v)) { - // then it makes sense to change the value - ITextRegion valueRegion = getNextQuotedLiteral(iterator()); - String quoteChar = v.indexOf("\"") == -1 ? "\"" : "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (valueRegion != null) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(valueRegion), valueRegion.getLength(), quoteChar + v + quoteChar); - } - else { - int startOffset = 0; - RegionIterator iter = iterator(); - ITextRegion region = getNextRegion(iter, DTDRegionTypes.NAME); - if (region == null) { - // create it after the percent if there is one - region = getPercentRegion(); - } - if (region == null) { - // if still null, then create it after the element tag - region = getStartTag(iterator()); - } - - if (region != null) { - startOffset = getStructuredDTDDocumentRegion().getEndOffset(region); - replaceText(requestor, startOffset, 0, quoteChar + v + quoteChar); - } - } - } - } - } - - /** - * Set the value of value. - * - * @param v - * Value to assign to value. - */ - public void setValue(String v) { - beginRecording(this, DTDCoreMessages._UI_LABEL_ENTITY_VALUE_CHG); //$NON-NLS-1$ - setValue(this, v); - endRecording(this); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ExternalNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ExternalNode.java deleted file mode 100644 index bcf709d83b..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ExternalNode.java +++ /dev/null @@ -1,250 +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.dtd.core.internal; - -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -// base class for nodes that can contain external content -public abstract class ExternalNode extends NamedTopLevelNode { - - String publicID; - - String systemID; - - public ExternalNode(DTDFile file, IStructuredDocumentRegion flatNode, String tagType) { - super(file, flatNode, tagType); - } - - public ITextRegion getNextQuotedLiteral(RegionIterator iter) { - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType().equals(DTDRegionTypes.SINGLEQUOTED_LITERAL) || region.getType().equals(DTDRegionTypes.DOUBLEQUOTED_LITERAL)) { - return region; - } - } - return null; - } - - /** - * Get the value of publicID. - * - * @return value of publicID. - */ - public String getPublicID() { - ITextRegion publicValue = getPublicValueRegion(); - if (publicValue != null) { - return getValueFromQuotedRegion(publicValue); - } - return ""; //$NON-NLS-1$ - } - - public ITextRegion getPublicKeywordRegion(RegionIterator iter) { - return getNextRegion(iter, DTDRegionTypes.PUBLIC_KEYWORD); - } - - public ITextRegion getPublicValueRegion() { - RegionIterator iter = iterator(); - - ITextRegion publicKeyword = getPublicKeywordRegion(iter); - - if (publicKeyword != null && iter.hasNext()) { - ITextRegion quotedLiteral = getNextQuotedLiteral(iter); - if (quotedLiteral != null) { - return quotedLiteral; - } - } - return null; - } - - /** - * Get the value of systemID. - * - * @return value of systemID. - */ - public String getSystemID() { - ITextRegion systemValue = getSystemValueRegion(); - if (systemValue != null) { - return getValueFromQuotedRegion(systemValue); - } - return ""; //$NON-NLS-1$ - } - - public ITextRegion getSystemKeywordRegion(RegionIterator iter) { - return getNextRegion(iter, DTDRegionTypes.SYSTEM_KEYWORD); - } - - public ITextRegion getSystemValueRegion() { - RegionIterator iter = iterator(); - - ITextRegion systemKeyword = getSystemKeywordRegion(iter); - if (systemKeyword != null && iter.hasNext()) { - ITextRegion quotedLiteral = getNextQuotedLiteral(iter); - if (quotedLiteral != null) { - return quotedLiteral; - } - } - else { - // try and see if there is a second quoted literal after a public - // keyword - iter = iterator(); - ITextRegion publicKeyword = getPublicKeywordRegion(iter); - - if (publicKeyword != null && iter.hasNext()) { - ITextRegion quotedLiteral = getNextQuotedLiteral(iter); - if (quotedLiteral != null && iter.hasNext()) { - // now get the second quoted literal - quotedLiteral = getNextQuotedLiteral(iter); - if (quotedLiteral != null) { - // got it! - return quotedLiteral; - } - } - } - } - return null; - } - - public String getValueFromQuotedRegion(ITextRegion region) { - String type = region.getType(); - if (type.equals(DTDRegionTypes.SINGLEQUOTED_LITERAL) || type.equals(DTDRegionTypes.DOUBLEQUOTED_LITERAL)) { - String text = getStructuredDTDDocumentRegion().getText(region); - return text.substring(1, text.length() - 1); - } - return ""; //$NON-NLS-1$ - } - - /** - * Set the value of publicID. - * - * @param v - * Value to assign to publicID. - */ - public void setPublicID(Object requestor, String v) { - if (!v.equals(publicID)) { - publicID = v; - ITextRegion publicValue = getPublicValueRegion(); - ITextRegion publicKeyword = getPublicKeywordRegion(iterator()); - ITextRegion systemKeyword = getSystemKeywordRegion(iterator()); - ITextRegion systemValue = getSystemValueRegion(); - - if (v.equals("")) { //$NON-NLS-1$ - if (publicKeyword != null) { - // time to get rid of the public keyword and value - // and replace it with the system one - int startOffset = getStructuredDTDDocumentRegion().getStartOffset(publicKeyword); - String newString = "SYSTEM"; //$NON-NLS-1$ - if (systemValue == null) { - newString += " \"\""; //$NON-NLS-1$ - } - replaceText(requestor, startOffset, getStructuredDTDDocumentRegion().getEndOffset(publicValue) - startOffset, newString); - } - } - else { - // here were setting a non empty value - String quoteChar = v.indexOf("\"") == -1 ? "\"" : "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - if (publicValue != null) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(publicValue), publicValue.getLength(), quoteChar + publicID + quoteChar); - } - else { - // time to create stuff - if (publicKeyword != null) { - // then just put our new value after the keyword - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(publicKeyword), 0, " " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - else { - // we need the public keyword as well - if (systemKeyword != null) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(systemKeyword), systemKeyword.getLength(), "PUBLIC " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - else { - ITextRegion nameRegion = getNameRegion(); - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(nameRegion), 0, " PUBLIC " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - } - } - } - } - } - - - /** - * Set the value of publicID. - * - * @param v - * Value to assign to publicID. - */ - public void setPublicID(String v) { - beginRecording(this, DTDCoreMessages._UI_LABEL_EXT_NODE_PUBLIC_ID_CHG); //$NON-NLS-1$ - setPublicID(this, v); - endRecording(this); - } - - /** - * Set the value of systemID. - * - * @param v - * Value to assign to systemID. - */ - public void setSystemID(Object requestor, String v) { - if (!v.equals(systemID) || (getPublicKeywordRegion(iterator()) == null && getSystemKeywordRegion(iterator()) == null)) { - systemID = v; - String quoteChar = v.indexOf("\"") == -1 ? "\"" : "'"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - ITextRegion systemValue = getSystemValueRegion(); - if (systemValue != null) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(systemValue), systemValue.getLength(), quoteChar + systemID + quoteChar); - } - else { - ITextRegion systemKeyword = getSystemKeywordRegion(iterator()); - - // time to create stuff - if (systemKeyword != null) { - // then just put our new value after the keyword - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(systemKeyword), 0, " " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - else { - // see if we have a public keyword - ITextRegion publicKeyword = getPublicKeywordRegion(iterator()); - if (publicKeyword == null) { - ITextRegion nameRegion = getNameRegion(); - - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(nameRegion), 0, " SYSTEM " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - else { - // put it after the public value region - ITextRegion publicValueRegion = getPublicValueRegion(); - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(publicValueRegion), 0, " " + quoteChar + v + quoteChar); //$NON-NLS-1$ - } - - } - } - - } - } - - - /** - * Set the value of systemID. - * - * @param v - * Value to assign to systemID. - */ - public void setSystemID(String v) { - beginRecording(this, DTDCoreMessages._UI_LABEL_EXT_NODE_SYSTEM_ID_CHG); //$NON-NLS-1$ - setSystemID(this, v); - endRecording(this); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Logger.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Logger.java deleted file mode 100644 index 39c11cb279..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Logger.java +++ /dev/null @@ -1,143 +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.dtd.core.internal; - -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.Status; -import org.osgi.framework.Bundle; - -/** - * Small convenience class to log messages to plugin's log file and also, if - * desired, the console. This class should only be used by classes in this - * plugin. Other plugins should make their own copy, with appropriate ID. - */ -public class Logger { - private static final String PLUGIN_ID = "org.eclipse.wst.dtd.core"; //$NON-NLS-1$ - - public static final int ERROR = IStatus.ERROR; // 4 - public static final int ERROR_DEBUG = 200 + ERROR; - public static final int INFO = IStatus.INFO; // 1 - public static final int INFO_DEBUG = 200 + INFO; - - public static final int OK = IStatus.OK; // 0 - - public static final int OK_DEBUG = 200 + OK; - - private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$ - public static final int WARNING = IStatus.WARNING; // 2 - public static final int WARNING_DEBUG = 200 + WARNING; - - /** - * Adds message to log. - * - * @param level - * severity level of the message (OK, INFO, WARNING, ERROR, - * OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG) - * @param message - * text to add to the log - * @param exception - * exception thrown - */ - protected static void _log(int level, String message, Throwable exception) { - if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) { - if (!isDebugging()) - return; - } - - int severity = IStatus.OK; - switch (level) { - case INFO_DEBUG : - case INFO : - severity = IStatus.INFO; - break; - case WARNING_DEBUG : - case WARNING : - severity = IStatus.WARNING; - break; - case ERROR_DEBUG : - case ERROR : - severity = IStatus.ERROR; - } - Status statusObj = new Status(severity, PLUGIN_ID, severity, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - } - - /** - * Prints message to log if category matches /debug/tracefilter option. - * - * @param message - * text to print - * @param category - * category of the message, to be compared with - * /debug/tracefilter - */ - protected static void _trace(String category, String message, Throwable exception) { - if (!isDebugging()) - return; - - String traceFilter = Platform.getDebugOption(PLUGIN_ID + TRACEFILTER_LOCATION); - if (traceFilter != null) { - StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$ - while (tokenizer.hasMoreTokens()) { - String cat = tokenizer.nextToken().trim(); - if (category.equals(cat)) { - Status statusObj = new Status(IStatus.OK, PLUGIN_ID, IStatus.OK, message, exception); - Bundle bundle = Platform.getBundle(PLUGIN_ID); - if (bundle != null) - Platform.getLog(bundle).log(statusObj); - return; - } - } - } - } - - /** - * @return true if the platform is debugging - */ - public static boolean isDebugging() { - return Platform.inDebugMode(); - } - - public static void log(int level, String message) { - _log(level, message, null); - } - - public static void log(int level, String message, Throwable exception) { - _log(level, message, exception); - } - - public static void logException(String message, Throwable exception) { - _log(ERROR, message, exception); - } - - public static void logException(Throwable exception) { - _log(ERROR, exception.getMessage(), exception); - } - - public static void trace(String category, String message) { - _trace(category, message, null); - } - - public static void traceException(String category, String message, Throwable exception) { - _trace(category, message, exception); - } - - public static void traceException(String category, Throwable exception) { - _trace(category, exception.getMessage(), exception); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NamedTopLevelNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NamedTopLevelNode.java deleted file mode 100644 index a230cd2e16..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NamedTopLevelNode.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.dtd.core.internal; - -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -// interface for nodes that can exist at the top level in a dtdfile -// eg. entity, notation, element, comment, attlist, or unrecognized stuff (ie -// <junk dkfjdl> -public abstract class NamedTopLevelNode extends TopLevelNode { - - private String tagStartType; - - public NamedTopLevelNode(DTDFile dtdFile, IStructuredDocumentRegion flatNode, String type) { - super(dtdFile, flatNode); - tagStartType = type; - } - - public ITextRegion getNameRegion() { - // name region is located after the whitespace (which is after - // the elementtag - RegionIterator iter = iterator(); - getNextRegion(iter, tagStartType); - - if (!iter.hasNext()) { - return null; - } - - ITextRegion region = iter.next(); - if (!region.getType().equals(DTDRegionTypes.WHITESPACE)) { - return null; - } - - if (!iter.hasNext()) { - return null; - } - - region = iter.next(); - if (region.getType().equals(DTDRegionTypes.NAME)) { - return region; - } - - // we normally stop here, but for entities, we have to see if we are - // at a '%'. if so, we skip that and find the name after the - // whitespace again - if (tagStartType == DTDRegionTypes.ENTITY_TAG && region.getType().equals(DTDRegionTypes.PERCENT) && iter.hasNext()) { - region = iter.next(); - - if (!region.getType().equals(DTDRegionTypes.WHITESPACE)) { - return null; - } - - if (!iter.hasNext()) { - return null; - } - - region = iter.next(); - if (region.getType().equals(DTDRegionTypes.NAME)) { - return region; - } - } - - return null; - } - - public ITextRegion getStartTag(RegionIterator iter) { - return getNextRegion(iter, tagStartType); - } - - public ITextRegion getWhitespaceAfterName() { - ITextRegion nameRegion = getNameRegion(); - RegionIterator iter = iterator(); - // skip past the element tag region - getNextRegion(iter, tagStartType); - boolean foundName = false; - while (iter.hasNext()) { - ITextRegion region = iter.next(); - if (!foundName && nameRegion != null && region == nameRegion) { - foundName = true; - } - - if (region.getType().equals(DTDRegionTypes.WHITESPACE)) { - // there is no name region or we have already passed it - if (nameRegion == null || foundName) { - return region; - } - } - } - return null; - } - - public void setName(Object requestor, String name) { - ITextRegion nameRegion = getNameRegion(); - if (nameRegion != null) { - super.setName(requestor, name); - } - else { - RegionIterator iter = iterator(); - ITextRegion elementTagRegion = getNextRegion(iter, tagStartType); - int replaceLength = 0; - if (iter.hasNext()) { - ITextRegion region = iter.next(); - if (region.getType().equals(DTDRegionTypes.WHITESPACE)) { - if (region.getLength() >= 2) { - // there are 2 spaces between 'ELEMENT' and the - // content - // Change replace length to 1 so that the new name and - // the content are separated by a single space - replaceLength = 1; - } - } - } - - // beginRecording(requestor, "Name Change"); - String newText = " " + name; //$NON-NLS-1$ - replaceText(requestor, getStructuredDTDDocumentRegion().getEndOffset(elementTagRegion), replaceLength, newText); - // endRecording(requestor); - } - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NodeList.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NodeList.java deleted file mode 100644 index ba84128503..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/NodeList.java +++ /dev/null @@ -1,109 +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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; - - -public class NodeList { - protected DTDFile dtdFile; - - ArrayList listNodes = new ArrayList(); - - protected String listType; - - public NodeList(DTDFile dtdFile, String tokenType) { - listType = tokenType; - this.dtdFile = dtdFile; - } - - public Image getImage() { - if (listType == DTDRegionTypes.ELEMENT_TAG) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_EL); - } - else if (listType == DTDRegionTypes.ENTITY_TAG) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_ENT); - } - else if (listType == DTDRegionTypes.NOTATION_TAG) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_NOT); - } - else if (listType == DTDRegionTypes.COMMENT_START) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_COMM); - } - else if (listType == DTDRegionTypes.ATTLIST_TAG) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_ATTLIST); - } - else if (listType == DTDRegionTypes.UNKNOWN_CONTENT) { - return DTDCorePlugin.getInstance().getImage(DTDResource.FLDR_UNREC); - } - else - return null; - } - - public String getListType() { - return listType; - } - - public String getName() { - if (listType == DTDRegionTypes.ELEMENT_TAG) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_ELEMENTS; //$NON-NLS-1$ - } - else if (listType == DTDRegionTypes.ENTITY_TAG) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_ENTITIES; //$NON-NLS-1$ - } - else if (listType == DTDRegionTypes.NOTATION_TAG) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_NOTATIONS; //$NON-NLS-1$ - } - else if (listType == DTDRegionTypes.COMMENT_START) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_COMMENTS; //$NON-NLS-1$ - } - else if (listType == DTDRegionTypes.ATTLIST_TAG) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_ATTRIBUTES; //$NON-NLS-1$ - } - else if (listType == DTDRegionTypes.UNKNOWN_CONTENT) { - return DTDCoreMessages._UI_LABEL_NODE_LIST_OTHER; //$NON-NLS-1$ - } - return ""; //$NON-NLS-1$ - } - - public ArrayList getNodes() { - listNodes.clear(); - Iterator iter = dtdFile.getNodes().iterator(); - while (iter.hasNext()) { - DTDNode node = (DTDNode) iter.next(); - if (listType == DTDRegionTypes.ELEMENT_TAG && (node instanceof Element || node instanceof ParameterEntityReference)) { - listNodes.add(node); - } - else if (listType == DTDRegionTypes.ATTLIST_TAG && node instanceof AttributeList) { - listNodes.add(node); - } - else if (listType == DTDRegionTypes.ENTITY_TAG && node instanceof Entity) { - listNodes.add(node); - } - else if (listType == DTDRegionTypes.NOTATION_TAG && node instanceof Notation) { - listNodes.add(node); - } - else if (listType == DTDRegionTypes.COMMENT_START && node instanceof Comment) { - listNodes.add(node); - } - else if (listType == DTDRegionTypes.UNKNOWN_CONTENT && node instanceof Unrecognized) { - listNodes.add(node); - } - } - return listNodes; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Notation.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Notation.java deleted file mode 100644 index e9a1ac5f91..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Notation.java +++ /dev/null @@ -1,29 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - - -public class Notation extends ExternalNode { - - public Notation(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode, DTDRegionTypes.NOTATION_TAG); - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.NOTATIONICON); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ParameterEntityReference.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ParameterEntityReference.java deleted file mode 100644 index cd51a05129..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/ParameterEntityReference.java +++ /dev/null @@ -1,112 +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.dtd.core.internal; - -import java.util.List; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class ParameterEntityReference extends NamedTopLevelNode { - - - - public class StartEndPair { - public int startOffset, endOffset; - } - - private Entity cachedEntity = null; - - public ParameterEntityReference(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode, DTDRegionTypes.COMMENT_START); - } - - public Entity getEntityObject() { - if (cachedEntity != null && !cachedEntity.getName().equals(getReferencedEntity())) { - // if we have a cached entity, but the name doesnt match, - // null it now, so we perform a lookup - cachedEntity = null; - } - - if (cachedEntity == null) { - List nodes = getDTDFile().getNodes(); - for (int i = 0; i < nodes.size(); i++) { - DTDNode node = (DTDNode) nodes.get(i); - if (node instanceof Entity) { - Entity entity = (Entity) node; - if (entity.isParameterEntity() && entity.getName().equals(getReferencedEntity())) { - cachedEntity = entity; - } - } - } - } - return cachedEntity; - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.ENTITYREFERENCEICON); - } - - public String getName() { - return getStructuredDTDDocumentRegion().getText(); - } - - public String getReferencedEntity() { - String text = getName(); - return getName().substring(1, text.length() - 1); - } - - private void getStartAndEndOffsetForText(StartEndPair pair) { - RegionIterator iter = iterator(); - ITextRegion commentStartTag = getStartTag(iter); - ITextRegion endCommentTag = getNextRegion(iter, DTDRegionTypes.COMMENT_END); - pair.endOffset = getStructuredDTDDocumentRegion().getEndOffset(); - if (commentStartTag != null) { - pair.startOffset = getStructuredDTDDocumentRegion().getEndOffset(commentStartTag); - } - if (endCommentTag != null) { - pair.endOffset = getStructuredDTDDocumentRegion().getEndOffset(endCommentTag); - } - } - - public String getText() { - String text = getStructuredDTDDocumentRegion().getText(); - int flatNodeStart = getStructuredDTDDocumentRegion().getStartOffset(); - StartEndPair pair = new StartEndPair(); - getStartAndEndOffsetForText(pair); - return text.substring(pair.startOffset - flatNodeStart, pair.endOffset - flatNodeStart); - } - - public void setReferencedEntity(Object requestor, String name) { - replaceText(requestor, getStructuredDTDDocumentRegion().getStartOffset(), getStructuredDTDDocumentRegion().getLength(), "%" + name + ";"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public void setReferencedEntity(String name) { - beginRecording(this, DTDCoreMessages._UI_LABEL_PARM_ENTITY_REF_CHG_ENTITY_REF); //$NON-NLS-1$ - setReferencedEntity(this, name); - endRecording(this); - } - - public void setText(String newText) { - beginRecording(this, DTDCoreMessages._UI_LABEL_PARM_ENTITY_REF_COMMENT_CHG); //$NON-NLS-1$ - StartEndPair pair = new StartEndPair(); - getStartAndEndOffsetForText(pair); - replaceText(this, pair.startOffset, pair.endOffset - pair.startOffset, newText); - endRecording(this); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/TopLevelNode.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/TopLevelNode.java deleted file mode 100644 index 9ff2c8b3b2..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/TopLevelNode.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.dtd.core.internal; - -import java.util.ArrayList; -import java.util.Iterator; - -import org.eclipse.wst.dtd.core.internal.text.RegionIterator; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -// interface for nodes that can exist at the top level in a dtdfile -// eg. entity, notation, element, comment, attlist, or unrecognized stuff (ie -// <junk dkfjdl> -public abstract class TopLevelNode extends DTDNode { - - private ArrayList flatNodes = new ArrayList(); - - public TopLevelNode(DTDFile dtdFile, IStructuredDocumentRegion flatNode) { - super(dtdFile, flatNode); - flatNodes.add(flatNode); - } - - public void addWhitespaceStructuredDocumentRegion(IStructuredDocumentRegion node) { - flatNodes.add(node); - } - - // specialize this so we delete the objects flat node range - // AND any whitespace - public void delete() { - beginRecording(getDTDFile(), DTDCoreMessages._UI_LABEL_TOP_LEVEL_NODE_DELETE); //$NON-NLS-1$ - IStructuredDocumentRegion first = (IStructuredDocumentRegion) flatNodes.get(0); - IStructuredDocumentRegion last = (IStructuredDocumentRegion) flatNodes.get(flatNodes.size() - 1); - int startOffset = first.getStartOffset(); - int endOffset = last.getEndOffset(); - - replaceText(getDTDFile(), startOffset, endOffset - startOffset, ""); //$NON-NLS-1$ - endRecording(getDTDFile()); - } - - public ITextRegion getEndRegion() { - int size = flatNode.getRegions().size(); - if (size > 0) { - return flatNode.getRegions().get(size - 1); - } - return null; - } - - // includes what gettext gives us plus any whitespace - // trailing it - public String getFullText() { - StringBuffer sb = new StringBuffer(); - Iterator iter = flatNodes.iterator(); - while (iter.hasNext()) { - IStructuredDocumentRegion fNode = (IStructuredDocumentRegion) iter.next(); - sb.append(fNode.getText()); - } - return sb.toString(); - } - - public ITextRegion getStartRegion() { - if (flatNode.getRegions().size() > 0) { - return flatNode.getRegions().get(0); - } - return null; - } - - public RegionIterator iterator() { - // System.out.println("create region iter " + this.getClass() + " with - // start , end = " + getStartOffset() + ", " +getEndOffset()); - return new RegionIterator(flatNode, getStartOffset(), getEndOffset()); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Unrecognized.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Unrecognized.java deleted file mode 100644 index b144b4fb4f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/Unrecognized.java +++ /dev/null @@ -1,39 +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.dtd.core.internal; - -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - - -public class Unrecognized extends TopLevelNode { - - public Unrecognized(DTDFile file, IStructuredDocumentRegion flatNode) { - super(file, flatNode); - } - - public Image getImage() { - return DTDCorePlugin.getInstance().getImage(DTDResource.UNRECOGNIZEDICON); - } - - public String getName() { - String text = getStructuredDTDDocumentRegion().getText(); - if (text.length() <= 30) { - return text; - } - else { - return text.substring(0, 29) + "..."; //$NON-NLS-1$ - } - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/content/ContentDescriberForDTD.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/content/ContentDescriberForDTD.java deleted file mode 100644 index 0fad93499c..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/content/ContentDescriberForDTD.java +++ /dev/null @@ -1,211 +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.dtd.core.internal.content; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -import org.eclipse.core.runtime.QualifiedName; -import org.eclipse.core.runtime.content.IContentDescriber; -import org.eclipse.core.runtime.content.IContentDescription; -import org.eclipse.core.runtime.content.ITextContentDescriber; -import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento; -import org.eclipse.wst.sse.core.internal.encoding.IContentDescriptionExtended; -import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector; -import org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector; - - - -public final class ContentDescriberForDTD implements ITextContentDescriber { - final private static QualifiedName[] SUPPORTED_OPTIONS = {IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK, IContentDescriptionExtended.DETECTED_CHARSET, IContentDescriptionExtended.UNSUPPORTED_CHARSET, IContentDescriptionExtended.APPROPRIATE_DEFAULT}; - private IResourceCharsetDetector resourceCharsetDetector; - - public int describe(InputStream contents, IContentDescription description) throws IOException { - int result = IContentDescriber.INDETERMINATE; - - if (description == null) { - result = computeValidity(contents); - } - else { - calculateSupportedOptions(contents, description); - result = computeValidity(contents); - } - return result; - } - - public int describe(Reader contents, IContentDescription description) throws IOException { - int result = IContentDescriber.INDETERMINATE; - - if (description == null) { - result = computeValidity(contents); - } - else { - calculateSupportedOptions(contents, description); - result = computeValidity(contents); - } - return result; - } - - public QualifiedName[] getSupportedOptions() { - - return SUPPORTED_OPTIONS; - } - - private void calculateSupportedOptions(InputStream contents, IContentDescription description) throws IOException { - if (isRelevent(description)) { - IResourceCharsetDetector detector = getDetector(); - detector.set(contents); - handleCalculations(description, detector); - } - } - - /** - * @param contents - * @param description - * @throws IOException - */ - private void calculateSupportedOptions(Reader contents, IContentDescription description) throws IOException { - if (isRelevent(description)) { - IResourceCharsetDetector detector = getDetector(); - detector.set(contents); - handleCalculations(description, detector); - } - } - - private int computeValidity(InputStream inputStream) { - // currently no specific check for validilty - // based on contents. - return IContentDescriber.INDETERMINATE; - } - - private int computeValidity(Reader reader) { - // currently no specific check for validilty - // based on contents. - return IContentDescriber.INDETERMINATE; - } - - // same rules as for XML - private IResourceCharsetDetector getDetector() { - if (resourceCharsetDetector == null) { - resourceCharsetDetector = new XMLResourceEncodingDetector(); - } - return resourceCharsetDetector; - } - - /** - * @param description - * @param detector - * @throws IOException - */ - private void handleCalculations(IContentDescription description, IResourceCharsetDetector detector) throws IOException { - // note: if we're asked for one, we set them all. I need to be sure if - // called - // mulitiple times (one for each, say) that we don't waste time - // processing same - // content again. - EncodingMemento encodingMemento = ((XMLResourceEncodingDetector) detector).getEncodingMemento(); - // TODO: I need to verify to see if this BOM work is always done - // by text type. - Object detectedByteOrderMark = encodingMemento.getUnicodeBOM(); - if (detectedByteOrderMark != null) { - Object existingByteOrderMark = description.getProperty(IContentDescription.BYTE_ORDER_MARK); - // not sure why would ever be different, so if is different, may - // need to "push" up into base. - if (!detectedByteOrderMark.equals(existingByteOrderMark)) - description.setProperty(IContentDescription.BYTE_ORDER_MARK, detectedByteOrderMark); - } - - - if (!encodingMemento.isValid()) { - // note: after setting here, its the mere presence of - // IContentDescriptionExtended.UNSUPPORTED_CHARSET - // in the resource's description that can be used to determine if - // invalid - // in those cases, the "detected" property contains an - // "appropriate default" to use. - description.setProperty(IContentDescriptionExtended.UNSUPPORTED_CHARSET, encodingMemento.getInvalidEncoding()); - description.setProperty(IContentDescriptionExtended.APPROPRIATE_DEFAULT, encodingMemento.getAppropriateDefault()); - } - - Object detectedCharset = encodingMemento.getDetectedCharsetName(); - Object javaCharset = encodingMemento.getJavaCharsetName(); - - // we always include detected, if its different than java - handleDetectedSpecialCase(description, detectedCharset, javaCharset); - - if (javaCharset != null) { - Object existingCharset = description.getProperty(IContentDescription.CHARSET); - if (javaCharset.equals(existingCharset)) { - handleDetectedSpecialCase(description, detectedCharset, javaCharset); - } - else { - // we may need to add what we found, but only need to add - // if different from default.the - Object defaultCharset = getDetector().getSpecDefaultEncoding(); - if (defaultCharset != null) { - if (!defaultCharset.equals(javaCharset)) { - description.setProperty(IContentDescription.CHARSET, javaCharset); - } - } - else { - // assuming if there is no spec default, we always need to - // add, I'm assuming - description.setProperty(IContentDescription.CHARSET, javaCharset); - } - } - } - - } - - private void handleDetectedSpecialCase(IContentDescription description, Object detectedCharset, Object javaCharset) { - // since equal, we don't need to add, but if our detected version is - // different than - // javaCharset, then we should add it. This will happen, for example, - // if there's - // differences in case, or differences due to override properties - if (detectedCharset != null) { - // if (!detectedCharset.equals(javaCharset)) { - // description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, - // detectedCharset); - // } - - // Once we detected a charset, we should set the property even - // though it's the same as javaCharset - // because there are clients that rely on this property to - // determine if the charset is actually detected in file or not. - description.setProperty(IContentDescriptionExtended.DETECTED_CHARSET, detectedCharset); - } - } - - /** - * @param description - * @return - */ - private boolean isRelevent(IContentDescription description) { - boolean result = false; - if (description == null) - result = false; - else if (description.isRequested(IContentDescription.BYTE_ORDER_MARK)) - result = true; - else if (description.isRequested(IContentDescription.CHARSET)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.APPROPRIATE_DEFAULT)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.DETECTED_CHARSET)) - result = true; - else if (description.isRequested(IContentDescriptionExtended.UNSUPPORTED_CHARSET)) - result = true; - return result; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/document/DTDModelImpl.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/document/DTDModelImpl.java deleted file mode 100644 index 799eb70b1d..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/document/DTDModelImpl.java +++ /dev/null @@ -1,273 +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.dtd.core.internal.document; - -import java.io.File; -import java.util.Iterator; -import java.util.Vector; - -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Entity; -import org.eclipse.wst.dtd.core.internal.NodeList; -import org.eclipse.wst.dtd.core.internal.event.IDTDFileListener; -import org.eclipse.wst.dtd.core.internal.event.NodesEvent; -import org.eclipse.wst.dtd.core.internal.provisional.document.DTDModel; -import org.eclipse.wst.dtd.core.internal.util.DTDReferenceUpdater; -import org.eclipse.wst.dtd.core.internal.util.LabelValuePair; -import org.eclipse.wst.sse.core.internal.model.AbstractStructuredModel; -import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion; -import org.eclipse.wst.sse.core.internal.provisional.events.IStructuredDocumentListener; -import org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; - - -public final class DTDModelImpl extends AbstractStructuredModel implements IStructuredDocumentListener, DTDModel { - - public static boolean deleteFile(String fileName) { - boolean result = false; - - // create the temp File object - File file = new File(fileName); - if (file.exists()) - result = file.delete(); - return result; - } - - private DTDFile document; - - // private List errorMessages = new ArrayList(); - - // entity reference names found in the conditional IGNORE sections - private Vector ignoredEntityRefs; - - private boolean refreshRequired = false; - - protected DTDReferenceUpdater refUpdater = new DTDReferenceUpdater(); - - public DTDModelImpl() { - super(); - document = new DTDFile(this); - document.addDTDFileListener(new IDTDFileListener() { - - public void nodeChanged(DTDNode node) { - if (node instanceof Entity) { - Entity entity = (Entity) node; - if (entity.isParameterEntity() && entity.isExternalEntity()) { - // just say they have changed for now - setReferencedModelsChanged(); - } - } - } - - public void nodesAdded(NodesEvent event) { - checkIfExternalReferencesChanged(event); - } - - public void nodesRemoved(NodesEvent event) { - checkIfExternalReferencesChanged(event); - } - }); - } - - public void beginRecording(Object requester, String label) { - super.beginRecording(requester, label); - // clear reference updater cache - getReferenceUpdater().clearCache(); - } - - void checkIfExternalReferencesChanged(NodesEvent event) { - Iterator iter = event.getNodes().iterator(); - while (iter.hasNext()) { - DTDNode node = (DTDNode) iter.next(); - if (node instanceof Entity) { - Entity entity = (Entity) node; - if (entity.isParameterEntity() && entity.isExternalEntity()) { - // just say they have changed for now - setReferencedModelsChanged(); - } - } - } - } - - // - // The following function helps determine the list of things that - // can be used in a parameter entity reference content - // Optional parameter is to allow the currently used DTDEntity to - // be included in the combobox. - // - public LabelValuePair[] createParmEntityContentItems(Entity entity) { - NodeList entities = getDTDFile().getEntities(); - - Vector items = new Vector(); - - if (entity != null) { - String name = "%" + entity.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ - items.addElement(new LabelValuePair(name, name)); - } - - for (Iterator i = entities.getNodes().iterator(); i.hasNext();) { - Entity entityAt = (Entity) i.next(); - if (entityAt.isParameterEntity() && entityAt.isExternalEntity()) { - String name = "%" + entityAt.getName() + ";"; //$NON-NLS-1$ //$NON-NLS-2$ - items.addElement(new LabelValuePair(name, name)); - } - } - LabelValuePair[] comboArray = new LabelValuePair[items.size()]; - items.copyInto(comboArray); - return comboArray; - } - - public void endRecording(Object requester) { - super.endRecording(requester); - // clear reference updater cache - getReferenceUpdater().clearCache(); - } - - - public DTDFile getDTDFile() { - return document; - } - - // Returns entity reference names that are in - // the conditional IGNORE sections. - public Vector getIgnoredEntityRefs() { - if (ignoredEntityRefs == null) - ignoredEntityRefs = new Vector(); - return ignoredEntityRefs; - } - - public IndexedRegion getIndexedRegion(int offset) { - if (this.document == null) - return null; - // System.out.println("getNode at " + offset + " returning = " + - // this.document.getNodeAt(offset)); - - return this.document.getNodeAt(offset); - } - - public DTDReferenceUpdater getReferenceUpdater() { - return refUpdater; - } - - public boolean isReferencedModelsChanged() { - return refreshRequired; - } - - public boolean isRefreshRequired() { - return refreshRequired; - } - - public void newModel(NewDocumentEvent flatModelEvent) { - document.newModel(flatModelEvent); - // System.out.println("\nnewmodel"); - outputStructuredDocument(flatModelEvent); - } - - public void noChange(NoChangeEvent flatModelEvent) { - // System.out.println("\nnochange"); - outputStructuredDocument(flatModelEvent); - - } - - public void nodesReplaced(StructuredDocumentRegionsReplacedEvent flatModelEvent) { - // System.out.println("\nnodesreplaced"); - document.nodesReplaced(flatModelEvent); - outputStructuredDocument(flatModelEvent); - - } - - public void outputStructuredDocument(StructuredDocumentEvent flatModelEvent) { - // System.out.println("structuredDocument source = '" + - // flatModelEvent.getStructuredDocument().getText() + "'"); - // System.out.println("new String = '" + - // flatModelEvent.getOriginalChanges() +"'"); - // System.out.println("deleted String = '" + - // flatModelEvent.getDeletedText() +"'"); - // Enumeration e = - // flatModelEvent.getStructuredDocument().getNodes().elements(); - // int i = 0; - // for (; e.hasMoreElements(); i++) - // { - // BasicStructuredDocumentRegion node = - // (BasicStructuredDocumentRegion) e.nextElement(); - // outputStructuredDocumentRegion(node); - // System.out.println(" " + i +". " + node.hashCode() + " '" - // +node.getText() + "'"); - // } - } - - public void outputStructuredDocumentRegion(IStructuredDocumentRegion flatNode) { - // int size = flatNode.getNumberOfRegions(); - // for (int i = 0; i < size; i++) - // { - // Region region = (Region) flatNode.getRegions().get(i); - // System.out.println(i + ". " + region.getType()); - - // } // end of for () - - } - - public void regionChanged(RegionChangedEvent flatModelEvent) { - // System.out.println("\nregion changed"); - document.regionChanged(flatModelEvent); - // System.out.println("= " + - // flatModelEvent.getStructuredDocumentRegion().getText()); - // System.out.println("region changed " + - // flatModelEvent.getRegion().hashCode() + " = " + - // flatModelEvent.getRegion()); - - outputStructuredDocument(flatModelEvent); - } - - public void regionsReplaced(RegionsReplacedEvent flatModelEvent) { - // System.out.println("\nregion replaced"); - document.regionsReplaced(flatModelEvent); - outputStructuredDocument(flatModelEvent); - } - - public void setReferencedModelsChanged() { - refreshRequired = true; - } - - public void setRefreshRequired(boolean value) { - refreshRequired = value; - } - - - /** - * @param newStructuredDocument - * org.eclipse.wst.sse.core.text.IStructuredDocument - */ - public void setStructuredDocument(IStructuredDocument newStructuredDocument) { - IStructuredDocument oldStructuredDocument = super.getStructuredDocument(); - if (newStructuredDocument == oldStructuredDocument) - return; // noting to do - - if (oldStructuredDocument != null) - oldStructuredDocument.removeDocumentChangingListener(this); - super.setStructuredDocument(newStructuredDocument); - if (newStructuredDocument != null) { - if (newStructuredDocument.getLength() > 0) { - newModel(new NewDocumentEvent(newStructuredDocument, this)); - } - newStructuredDocument.addDocumentChangingListener(this); - } - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/AbstractResourceEncodingDetector.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/AbstractResourceEncodingDetector.java deleted file mode 100644 index 07937e3ff2..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/AbstractResourceEncodingDetector.java +++ /dev/null @@ -1,261 +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.dtd.core.internal.encoding; - -import java.io.BufferedInputStream; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; -import java.nio.charset.Charset; -import java.nio.charset.IllegalCharsetNameException; -import java.nio.charset.UnsupportedCharsetException; - -import org.eclipse.core.resources.IStorage; -import org.eclipse.core.runtime.CoreException; -import org.eclipse.wst.sse.core.internal.encoding.CodedIO; -import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento; -import org.eclipse.wst.sse.core.internal.encoding.IResourceCharsetDetector; - - -public abstract class AbstractResourceEncodingDetector implements IResourceCharsetDetector { - - protected EncodingMemento fEncodingMemento; - - protected boolean fHeaderParsed; - - protected Reader fReader; - - /** - * - */ - public AbstractResourceEncodingDetector() { - super(); - } - - /** - * Note: once this instance is created, trace info still needs to be - * appended by caller, depending on the context its created. - */ - private void createEncodingMemento(String detectedCharsetName) { - fEncodingMemento = new EncodingMemento(); - fEncodingMemento.setJavaCharsetName(getAppropriateJavaCharset(detectedCharsetName)); - fEncodingMemento.setDetectedCharsetName(detectedCharsetName); - // TODO: if detectedCharset and spec default is - // null, need to use "work - // bench based" defaults. - fEncodingMemento.setAppropriateDefault(getSpecDefaultEncoding()); - } - - /** - * convience method all subclasses can use (but not override) - * - * @param detectedCharsetName - * @param reason - */ - final protected void createEncodingMemento(String detectedCharsetName, String reason) { - createEncodingMemento(detectedCharsetName); - } - - /** - * convience method all subclasses can use (but not override) - */ - final protected void ensureInputSet() { - if (fReader == null) { - throw new IllegalStateException("input must be set before use"); //$NON-NLS-1$ - } - } - - /** - * This method can return null, if invalid charset name (in which case - * "appropriateDefault" should be used, if a name is really need for some - * "save anyway" cases). - * - * @param detectedCharsetName - * @return - */ - private String getAppropriateJavaCharset(String detectedCharsetName) { - String result = null; - // 1. Check explicit mapping overrides from - // property file -- its here we pick up "rules" for cases - // that are not even in Java - result = CodedIO.checkMappingOverrides(detectedCharsetName); - // 2. Use the "canonical" name from JRE mappings - // Note: see Charset JavaDoc, the name you get one - // with can be alias, - // the name you get back is "standard" name. - Charset javaCharset = null; - try { - javaCharset = Charset.forName(detectedCharsetName); - } - catch (UnsupportedCharsetException e) { - // only set invalid, if result is same as detected -- they won't - // be equal if - // overridden - if (result != null && result.equals(detectedCharsetName)) { - fEncodingMemento.setInvalidEncoding(detectedCharsetName); - } - } - catch (IllegalCharsetNameException e) { - // only set invalid, if result is same as detected -- they won't - // be equal if - // overridden - if (result != null && result.equals(detectedCharsetName)) { - fEncodingMemento.setInvalidEncoding(detectedCharsetName); - } - } - // give priority to java cononical name, if present - if (javaCharset != null) { - result = javaCharset.name(); - // but still allow overrides - result = CodedIO.checkMappingOverrides(result); - } - return result; - } - - public String getEncoding() throws IOException { - return getEncodingMemento().getDetectedCharsetName(); - } - - // to ensure consist overall rules used, we'll mark as - // final, - // and require subclasses to provide certain pieces of - // the - // implementation - public EncodingMemento getEncodingMemento() throws IOException { - ensureInputSet(); - if (!fHeaderParsed) { - parseInput(); - // we keep track of if header's already been - // parse, so can make - // multiple 'get' calls, without causing - // reparsing. - fHeaderParsed = true; - // Note: there is a "hidden assumption" here - // that an empty - // string in content should be treated same as - // not present. - } - if (fEncodingMemento == null) { - handleSpecDefault(); - } - if (fEncodingMemento == null) { - // safty net - fEncodingMemento = new NullMemento(); - } - return fEncodingMemento; - } - - /** - * This is to return a default encoding -- as specified by an industry - * content type spec -- when not present in the stream, for example, XML - * specifies UTF-8, JSP specifies ISO-8859-1. This method should return - * null if there is no such "spec default". - */ - abstract public String getSpecDefaultEncoding(); - - public EncodingMemento getSpecDefaultEncodingMemento() { - resetAll(); - EncodingMemento result = null; - String enc = getSpecDefaultEncoding(); - if (enc != null) { - createEncodingMemento(enc, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT); - fEncodingMemento.setAppropriateDefault(enc); - result = fEncodingMemento; - } - return result; - } - - private void handleSpecDefault() { - String encodingName; - encodingName = getSpecDefaultEncoding(); - if (encodingName != null) { - // createEncodingMemento(encodingName, - // EncodingMemento.USED_CONTENT_TYPE_DEFAULT); - fEncodingMemento = new EncodingMemento(); - fEncodingMemento.setJavaCharsetName(encodingName); - fEncodingMemento.setAppropriateDefault(encodingName); - } - } - - /** - * Every subclass must provide a way to parse the input. This method has - * several critical responsibilities: - * <li>set the fEncodingMemento field appropriately, according to the - * results of the parse of fReader.</li> - * <li>set fHarderParsed to true, to avoid wasted re-parsing.</li> - */ - abstract protected void parseInput() throws IOException; - - /** - * - */ - private void resetAll() { - fReader = null; - fHeaderParsed = false; - fEncodingMemento = null; - } - - /** - * - */ - public void set(InputStream inputStream) { - resetAll(); - fReader = new ByteReader(inputStream); - try { - fReader.mark(CodedIO.MAX_MARK_SIZE); - } - catch (IOException e) { - // impossible, since we know ByteReader - // supports marking - throw new Error(e); - } - } - - /** - * - */ - public void set(IStorage iStorage) throws CoreException { - resetAll(); - InputStream inputStream = iStorage.getContents(); - InputStream resettableStream = new BufferedInputStream(inputStream, CodedIO.MAX_BUF_SIZE); - resettableStream.mark(CodedIO.MAX_MARK_SIZE); - set(resettableStream); - // TODO we'll need to "remember" IFile, or - // get its (or its project's) settings, in case - // those are needed to handle cases when the - // encoding is not in the file stream. - } - - /** - * Note: this is not part of interface to help avoid confusion ... it - * expected this Reader is a well formed character reader ... that is, its - * all ready been determined to not be a unicode marked input stream. And, - * its assumed to be in the correct position, at position zero, ready to - * read first character. - */ - public void set(Reader reader) { - resetAll(); - fReader = reader; - if (!fReader.markSupported()) { - fReader = new BufferedReader(fReader); - } - try { - fReader.mark(CodedIO.MAX_MARK_SIZE); - } - catch (IOException e) { - // impossble, since we just checked if markable - throw new Error(e); - } - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/ByteReader.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/ByteReader.java deleted file mode 100644 index 1550a62340..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/ByteReader.java +++ /dev/null @@ -1,109 +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.dtd.core.internal.encoding; - -import java.io.IOException; -import java.io.InputStream; -import java.io.Reader; - -import org.eclipse.wst.sse.core.internal.encoding.CodedIO; - -/** - * This is an "adapter" class, simply to get in input stream to act like a - * reader. We could not use InputStreamReader directly because its internal - * buffers are not controllable, and it sometimes pulls too much out of input - * stream (even when it wasn't needed for our purposes). - * - * The use of this class is highly specialized and by not means meant to be - * general purpose. Its use is restricted to those cases where the input - * stream can be regarded as ascii just long enough to determine what the real - * encoding should be. - */ - -public class ByteReader extends Reader { - - - public static final int DEFAULT_BUFFER_SIZE = CodedIO.MAX_BUF_SIZE; - - protected byte[] fBuffer; - - protected InputStream fInputStream; - - protected ByteReader() { - super(); - } - - public ByteReader(InputStream inputStream) { - this(inputStream, DEFAULT_BUFFER_SIZE); - if (!inputStream.markSupported()) { - throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$ - } - } - - public ByteReader(InputStream inputStream, int size) { - this.fInputStream = inputStream; - if (!inputStream.markSupported()) { - throw new IllegalArgumentException("ByteReader is required to have a resettable stream"); //$NON-NLS-1$ - } - this.fBuffer = new byte[size]; - - } - - public void close() throws IOException { - this.fInputStream.close(); - } - - public void mark(int readAheadLimit) { - this.fInputStream.mark(readAheadLimit); - } - - public boolean markSupported() { - return true; - } - - public int read() throws IOException { - int b0 = this.fInputStream.read(); - return (b0 & 0x00FF); - } - - public int read(char ch[], int offset, int length) throws IOException { - if (length > this.fBuffer.length) { - length = this.fBuffer.length; - } - - int count = this.fInputStream.read(this.fBuffer, 0, length); - - for (int i = 0; i < count; i++) { - int b0 = this.fBuffer[i]; - // the 0x00FF is to "lose" the negative bits filled in the byte to - // int conversion - // (and which would be there if cast directly from byte to char). - char c0 = (char) (b0 & 0x00FF); - ch[offset + i] = c0; - } - return count; - } - - public boolean ready() throws IOException { - return this.fInputStream.available() > 0; - } - - public void reset() throws IOException { - this.fInputStream.reset(); - } - - public long skip(long n) throws IOException { - return this.fInputStream.skip(n); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentCharsetDetector.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentCharsetDetector.java deleted file mode 100644 index 11ae9f8db0..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentCharsetDetector.java +++ /dev/null @@ -1,61 +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 - * - *******************************************************************************/ -/* - * Created on 28-Aug-03 - * - * To change the template for this generated file go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -package org.eclipse.wst.dtd.core.internal.encoding; - -import java.io.IOException; - -import org.eclipse.jface.text.IDocument; -import org.eclipse.wst.sse.core.internal.document.DocumentReader; -import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector; -import org.eclipse.wst.xml.core.internal.contenttype.XMLResourceEncodingDetector; -import org.eclipse.wst.xml.core.internal.encoding.XMLDocumentCharsetDetector; - - -/** - * @author kboo - * - * To change the template for this generated type comment go to - * Window>Preferences>Java>Code Generation>Code and Comments - */ -public final class DTDDocumentCharsetDetector extends AbstractResourceEncodingDetector implements IDocumentCharsetDetector { - - public String getSpecDefaultEncoding() { - // by default, UTF-8 as per XML spec - final String enc = "UTF-8"; //$NON-NLS-1$ - return enc; - } - - /** - * - */ - - protected void parseInput() throws IOException { - IDocumentCharsetDetector documentEncodingDetector = new XMLDocumentCharsetDetector(); - documentEncodingDetector.set(fReader); - fEncodingMemento = ((XMLResourceEncodingDetector)documentEncodingDetector).getEncodingMemento(); - - } - - public void set(IDocument document) { - set(new DocumentReader(document, 0)); - - - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentLoader.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentLoader.java deleted file mode 100644 index 9ab8cc24ce..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/DTDDocumentLoader.java +++ /dev/null @@ -1,64 +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.dtd.core.internal.encoding; - -import org.eclipse.jface.text.IDocumentPartitioner; -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionParser; -import org.eclipse.wst.dtd.core.internal.text.DTDStructuredDocumentReParser; -import org.eclipse.wst.dtd.core.internal.text.StructuredTextPartitionerForDTD; -import org.eclipse.wst.sse.core.internal.document.AbstractDocumentLoader; -import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector; -import org.eclipse.wst.sse.core.internal.document.StructuredDocumentFactory; -import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; -import org.eclipse.wst.sse.core.internal.provisional.document.IEncodedDocument; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument; - - -public final class DTDDocumentLoader extends AbstractDocumentLoader { - - public DTDDocumentLoader() { - super(); - } - - public IDocumentPartitioner getDefaultDocumentPartitioner() { - return new StructuredTextPartitionerForDTD(); - } - - public IDocumentCharsetDetector getDocumentEncodingDetector() { - if (fDocumentEncodingDetector == null) { - fDocumentEncodingDetector = new DTDDocumentCharsetDetector(); - } - return fDocumentEncodingDetector; - } - - public RegionParser getParser() { - return new DTDRegionParser(); - } - - protected String getSpecDefaultEncoding() { - String enc = "UTF-8"; //$NON-NLS-1$ - return enc; - } - - protected IEncodedDocument newEncodedDocument() { - IStructuredDocument document = StructuredDocumentFactory.getNewStructuredDocumentInstance(getParser()); - DTDStructuredDocumentReParser reParser = new DTDStructuredDocumentReParser(); - reParser.setStructuredDocument(document); - if (document instanceof BasicStructuredDocument) { - ((BasicStructuredDocument) document).setReParser(reParser); - } - return document; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/NullMemento.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/NullMemento.java deleted file mode 100644 index 0cd01fc9b1..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/encoding/NullMemento.java +++ /dev/null @@ -1,36 +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.dtd.core.internal.encoding; - -import org.eclipse.wst.sse.core.internal.encoding.EncodingMemento; -import org.eclipse.wst.sse.core.internal.encoding.NonContentBasedEncodingRules; - - - -/** - * This class can be used in place of an EncodingMemento (its super class), - * when there is not in fact ANY encoding information. For example, when a - * structuredDocument is created directly from a String - */ -public class NullMemento extends EncodingMemento { - /** - * - */ - public NullMemento() { - super(); - String defaultCharset = NonContentBasedEncodingRules.useDefaultNameRules(null); - setJavaCharsetName(defaultCharset); - setAppropriateDefault(defaultCharset); - setDetectedCharsetName(null); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/IDTDFileListener.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/IDTDFileListener.java deleted file mode 100644 index fe29fb5dd9..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/IDTDFileListener.java +++ /dev/null @@ -1,24 +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.dtd.core.internal.event; - -import org.eclipse.wst.dtd.core.internal.DTDNode; - -public interface IDTDFileListener { - - public void nodeChanged(DTDNode node); - - public void nodesAdded(NodesEvent event); - - public void nodesRemoved(NodesEvent event); -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/NodesEvent.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/NodesEvent.java deleted file mode 100644 index 89974e81df..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/event/NodesEvent.java +++ /dev/null @@ -1,32 +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.dtd.core.internal.event; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.DTDNode; - - -public final class NodesEvent { - private ArrayList changedNodes = new ArrayList(); - - public void add(DTDNode changedNode) { - changedNodes.add(changedNode); - } - - public List getNodes() { - return changedNodes; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/DTDModelLoader.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/DTDModelLoader.java deleted file mode 100644 index 8db31f050e..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/DTDModelLoader.java +++ /dev/null @@ -1,47 +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.dtd.core.internal.modelhandler; - -import org.eclipse.wst.dtd.core.internal.document.DTDModelImpl; -import org.eclipse.wst.dtd.core.internal.encoding.DTDDocumentLoader; -import org.eclipse.wst.sse.core.internal.document.IDocumentLoader; -import org.eclipse.wst.sse.core.internal.model.AbstractModelLoader; -import org.eclipse.wst.sse.core.internal.provisional.IModelLoader; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; - - - -public final class DTDModelLoader extends AbstractModelLoader { - public DTDModelLoader() { - super(); - } - - public IDocumentLoader getDocumentLoader() { - if (documentLoaderInstance == null) { - documentLoaderInstance = new DTDDocumentLoader(); - } - return documentLoaderInstance; - } - - public IModelLoader newInstance() { - return new DTDModelLoader(); - } - - public IStructuredModel newModel() { - IStructuredModel model = new DTDModelImpl(); - // now done in create - // model.setStructuredDocument(createNewStructuredDocument()); - // model.setFactoryRegistry(defaultFactoryRegistry()); - return model; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/ModelHandlerForDTD.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/ModelHandlerForDTD.java deleted file mode 100644 index b17a55aa68..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/modelhandler/ModelHandlerForDTD.java +++ /dev/null @@ -1,46 +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.dtd.core.internal.modelhandler; - -import org.eclipse.wst.dtd.core.internal.encoding.DTDDocumentCharsetDetector; -import org.eclipse.wst.dtd.core.internal.encoding.DTDDocumentLoader; -import org.eclipse.wst.sse.core.internal.document.IDocumentCharsetDetector; -import org.eclipse.wst.sse.core.internal.document.IDocumentLoader; -import org.eclipse.wst.sse.core.internal.ltk.modelhandler.AbstractModelHandler; -import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IModelHandler; -import org.eclipse.wst.sse.core.internal.provisional.IModelLoader; - - -public final class ModelHandlerForDTD extends AbstractModelHandler implements IModelHandler { - private static String AssociatedContentTypeId = "org.eclipse.wst.dtd.core.dtdsource"; //$NON-NLS-1$ - private static String ModelHandlerID = "org.eclipse.wst.dtd.core.internal.modelhandler"; //$NON-NLS-1$ - - public ModelHandlerForDTD() { - super(); - setId(ModelHandlerID); - setAssociatedContentTypeId(AssociatedContentTypeId); - } - - public IDocumentLoader getDocumentLoader() { - return new DTDDocumentLoader(); - } - - public IDocumentCharsetDetector getEncodingDetector() { - return new DTDDocumentCharsetDetector(); - } - - public IModelLoader getModelLoader() { - return new DTDModelLoader(); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionFactory.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionFactory.java deleted file mode 100644 index 2b018b1276..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionFactory.java +++ /dev/null @@ -1,28 +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.dtd.core.internal.parser; - -import org.eclipse.wst.sse.core.internal.parser.ContextRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - -public class DTDRegionFactory { - public static ITextRegion createRegion(String tokenKind, int start, int length) { - ITextRegion region = null; - if (tokenKind != null) { - // ISSUE: DTD regions don't distinguish text from white space - region = new ContextRegion(tokenKind, start, length, length); - } - return region; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionParser.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionParser.java deleted file mode 100644 index 553ea59a6f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionParser.java +++ /dev/null @@ -1,271 +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.dtd.core.internal.parser; - -import java.io.Reader; -import java.io.StringReader; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.List; -import java.util.ListIterator; -import java.util.Vector; - -import org.eclipse.wst.dtd.core.internal.text.DTDStructuredDocumentRegionFactory; -import org.eclipse.wst.dtd.core.internal.tokenizer.DTDTokenizer; -import org.eclipse.wst.dtd.core.internal.tokenizer.Token; -import org.eclipse.wst.sse.core.internal.ltk.parser.RegionParser; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion; - - -public class DTDRegionParser implements RegionParser { - private Vector cachedRegions = null; - private DTDTokenizer tokenizer = null; - private IStructuredDocumentRegion cachedNode = null; // top of node - // chain - - public RegionParser newInstance() { - return new DTDRegionParser(); - } - - private IStructuredDocumentRegion addNewNodes(IStructuredDocumentRegion lastNode, Vector regions) { - IStructuredDocumentRegion leadingSpaceNode = null; - IStructuredDocumentRegion contentNode = null; - IStructuredDocumentRegion trailingSpaceNode = null; - LinkedList nodeSeeds = new LinkedList(); - int nRegions = regions.size(); - int leadingSpaceEnd = -1; - int trailingSpaceBegin = nRegions; - - // find leading space - nodeSeeds.clear(); - for (int i = 0; i < nRegions; i++) { - ITextRegion region = (ITextRegion) regions.get(i); - String type = region.getType(); - if (isBlankRegion(type)) { - leadingSpaceEnd = i; - nodeSeeds.addLast(region); - } - else { - break; - } - } - if (!nodeSeeds.isEmpty()) { - leadingSpaceNode = createNode(nodeSeeds); - if (lastNode != null) { - lastNode.setNext(leadingSpaceNode); - leadingSpaceNode.setPrevious(lastNode); - } - lastNode = leadingSpaceNode; - } - - // find trailing space - if (leadingSpaceEnd < nRegions - 1) { - nodeSeeds.clear(); - for (int i = nRegions - 1; 0 <= i; i--) { - ITextRegion region = (ITextRegion) regions.get(i); - String type = ((ITextRegion) regions.get(i)).getType(); - if (isBlankRegion(type)) { - trailingSpaceBegin = i; - nodeSeeds.addFirst(region); - } - else { - break; - } - } - if (!nodeSeeds.isEmpty()) { - trailingSpaceNode = createNode(nodeSeeds); - } - - nodeSeeds.clear(); - for (int i = leadingSpaceEnd + 1; i < trailingSpaceBegin; i++) { - nodeSeeds.addLast(regions.get(i)); - } - if (!nodeSeeds.isEmpty()) { - contentNode = createNode(nodeSeeds); - if (lastNode != null) { - lastNode.setNext(contentNode); - contentNode.setPrevious(lastNode); - } - lastNode = contentNode; - } - if (trailingSpaceNode != null) { - lastNode.setNext(trailingSpaceNode); - trailingSpaceNode.setPrevious(lastNode); - lastNode = trailingSpaceNode; - } - } - - return lastNode; - } - - private IStructuredDocumentRegion createNode(LinkedList regions) { - if (regions.size() == 0) { - return null; - } - - IStructuredDocumentRegion node = DTDStructuredDocumentRegionFactory.createStructuredDocumentRegion(DTDStructuredDocumentRegionFactory.DTD_GENERIC); - int start = ((ITextRegion) regions.getFirst()).getStart(); - int length = ((ITextRegion) regions.getLast()).getEnd() - start; - node.setStart(start); - node.setLength(length); - for (ListIterator i = regions.listIterator(0); i.hasNext();) { - ITextRegion region = (ITextRegion) i.next(); - node.addRegion(region); - region.adjustStart(-start); - } - node.setEnded(true); - - return node; - } - - private IStructuredDocumentRegion createNodeChain(List regions) { - IStructuredDocumentRegion headNode = null; - IStructuredDocumentRegion lastNode = null; - Vector nodeSeeds = new Vector(); - - for (Iterator e = regions.iterator(); e.hasNext();) { - ITextRegion region = (ITextRegion) e.next(); - String type = region.getType(); - // If the following regions appear, - // a previous node is closed in front of it. - if (!nodeSeeds.isEmpty() && isBeginningRegion(type)) { - lastNode = addNewNodes(lastNode, nodeSeeds); - nodeSeeds.clear(); - } - nodeSeeds.addElement(region); - - // The following regions close the current node. - if (!nodeSeeds.isEmpty() && isEndingRegion(type)) { - lastNode = addNewNodes(lastNode, nodeSeeds); - nodeSeeds.clear(); - } - - if (headNode == null && lastNode != null) { - headNode = findFirstNode(lastNode); - } - } - - // close current node forcibly. - if (!nodeSeeds.isEmpty()) { - lastNode = addNewNodes(lastNode, nodeSeeds); - if (headNode == null && lastNode != null) { - headNode = findFirstNode(lastNode); - } - } - return headNode; - } - - private IStructuredDocumentRegion findFirstNode(IStructuredDocumentRegion node) { - IStructuredDocumentRegion firstNode = node; - IStructuredDocumentRegion prevNode = null; - while ((prevNode = firstNode.getPrevious()) != null) { - firstNode = prevNode; - } - return firstNode; - } - - public IStructuredDocumentRegion getDocumentRegions() { - if (cachedNode != null) { - return cachedNode; - } - - List regions = getRegions(); - IStructuredDocumentRegion headNode = createNodeChain(regions); - cachedNode = headNode; - - return headNode; - } - - public List getRegions() { - if (cachedRegions != null) { - return cachedRegions; - } - - Vector regions = new Vector(); - Token currentToken = null; - do { - try { - currentToken = (Token) tokenizer.yylex(); - if (currentToken != null) { - ITextRegion region = DTDRegionFactory.createRegion(currentToken.getType(), currentToken.getStartOffset(), currentToken.getLength()); - regions.add(region); - } - } - catch (java.io.FileNotFoundException e) { - System.out.println("File not found"); //$NON-NLS-1$ - } - catch (java.io.IOException e) { - System.out.println("Error opening file"); //$NON-NLS-1$ - } - } - while (currentToken != null); - - cachedRegions = regions; - return regions; - } - - public void reset(Reader reader) { - if (tokenizer == null) { - try { - tokenizer = new DTDTokenizer(reader); - } - catch (ArrayIndexOutOfBoundsException e) { - System.out.println("Usage : java DTDTokenizer <inputfile>"); //$NON-NLS-1$ - } - } - else { - try { - tokenizer.yyreset(reader); - } - catch (java.io.IOException e) { - System.out.println("Error opening file"); //$NON-NLS-1$ - } - } - - cachedNode = null; - cachedRegions = null; - } - - /** - * An additional offset for use with any position-dependant parsing rules - */ - public void reset(Reader reader, int offset) { - reset(reader); - } - - public void reset(String input) { - reset(new StringReader(input)); - } - - public void reset(String input, int offset) { - reset(input); - } - - // never used - DTDTokenizer getTokenizer() { - return tokenizer; - } - - private boolean isBeginningRegion(String type) { - return (type == DTDRegionTypes.START_TAG) || (type == DTDRegionTypes.ENTITY_PARM); - } - - private boolean isBlankRegion(String type) { - return (type == DTDRegionTypes.WHITESPACE); - } - - private boolean isEndingRegion(String type) { - return (type == DTDRegionTypes.END_TAG) || (type == DTDRegionTypes.ENTITY_PARM) || (type == DTDRegionTypes.COMMENT_END); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionTypes.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionTypes.java deleted file mode 100644 index 50ecd6b190..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/parser/DTDRegionTypes.java +++ /dev/null @@ -1,76 +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.dtd.core.internal.parser; - -public interface DTDRegionTypes { - public static final String regionPrefix = "org.eclipse.wst.dtd.core.internal.util.parser.DTDRegionTypes."; //$NON-NLS-1$ - - public static final String NAME = regionPrefix + "NAME"; //$NON-NLS-1$ - public static final String START_TAG = regionPrefix + "START_TAG"; //$NON-NLS-1$ - public static final String END_TAG = regionPrefix + "END_TAG"; //$NON-NLS-1$ - public static final String LEFT_PAREN = regionPrefix + "LEFT_PAREN"; //$NON-NLS-1$ - public static final String RIGHT_PAREN = regionPrefix + "RIGHT_PAREN"; //$NON-NLS-1$ - public static final String WHITESPACE = regionPrefix + "WHITESPACE"; //$NON-NLS-1$ - public static final String CONNECTOR = regionPrefix + "CONNECTOR"; //$NON-NLS-1$ - - public static final String OCCUR_TYPE = regionPrefix + "OCCUR_TYPE"; //$NON-NLS-1$ - public static final String EXCLAMATION = regionPrefix + "EXCLAMATION"; //$NON-NLS-1$ - public static final String PERCENT = regionPrefix + "PERCENT"; //$NON-NLS-1$ - public static final String SEMICOLON = regionPrefix + "SEMICOLON"; //$NON-NLS-1$ - public static final String COMMENT_START = regionPrefix + "COMMENT"; //$NON-NLS-1$ - public static final String COMMENT_CONTENT = regionPrefix + "COMMENT_CONTENT"; //$NON-NLS-1$ - public static final String COMMENT_END = regionPrefix + "COMMENT_END"; //$NON-NLS-1$ - - public static final String NOTATION_TAG = regionPrefix + "NOTATION_TAG"; //$NON-NLS-1$ - public static final String NOTATION_CONTENT = regionPrefix + "NOTATION_CONTENT"; //$NON-NLS-1$ - - public static final String ENTITY_TAG = regionPrefix + "ENTITY_TAG"; //$NON-NLS-1$ - public static final String ENTITY_PARM = regionPrefix + "ENTITY_PARM"; //$NON-NLS-1$ - public static final String ENTITY_CONTENT = regionPrefix + "ENTITY_CONTENT"; //$NON-NLS-1$ - public static final String NDATA_VALUE = regionPrefix + "NDATA_VALUE"; //$NON-NLS-1$ - - public static final String ELEMENT_TAG = regionPrefix + "ELEMENT_TAG"; //$NON-NLS-1$ - public static final String ELEMENT_CONTENT = regionPrefix + "ELEMENT_CONTENT"; //$NON-NLS-1$ - public static final String CONTENT_EMPTY = regionPrefix + "CONTENT_EMPTY"; //$NON-NLS-1$ - public static final String CONTENT_ANY = regionPrefix + "CONTENT_ANY"; //$NON-NLS-1$ - public static final String CONTENT_PCDATA = regionPrefix + "CONTENT_PCDATA"; //$NON-NLS-1$ - - public static final String ATTLIST_TAG = regionPrefix + "ATTLIST_TAG"; //$NON-NLS-1$ - - public static final String SYSTEM_KEYWORD = regionPrefix + "SYSTEM_KEYWORD"; //$NON-NLS-1$ - public static final String PUBLIC_KEYWORD = regionPrefix + "PUBLIC_KEYWORD"; //$NON-NLS-1$ - public static final String NDATA_KEYWORD = regionPrefix + "NDATA_KEYWORD"; //$NON-NLS-1$ - public static final String SINGLEQUOTED_LITERAL = regionPrefix + "SINGLEQUOTED_LITERAL"; //$NON-NLS-1$ - public static final String DOUBLEQUOTED_LITERAL = regionPrefix + "DOUBLEQUOTED_LITERAL"; //$NON-NLS-1$ - public static final String UNKNOWN_CONTENT = regionPrefix + "UNKNOWN_CONTENT"; //$NON-NLS-1$ - - public static final String ATTRIBUTE_NAME = regionPrefix + "ATTRIBUTE_NAME"; //$NON-NLS-1$ - - // attribute type keywords - public static final String CDATA_KEYWORD = regionPrefix + "CDATA_KEYWORD"; //$NON-NLS-1$ - public static final String ID_KEYWORD = regionPrefix + "ID_KEYWORD"; //$NON-NLS-1$ - public static final String IDREF_KEYWORD = regionPrefix + "IDREF_KEYWORD"; //$NON-NLS-1$ - public static final String IDREFS_KEYWORD = regionPrefix + "IDREFS_KEYWORD"; //$NON-NLS-1$ - public static final String ENTITY_KEYWORD = regionPrefix + "ENTITY_KEYWORD"; //$NON-NLS-1$ - public static final String ENTITIES_KEYWORD = regionPrefix + "ENTITIES_KEYWORD"; //$NON-NLS-1$ - public static final String NMTOKEN_KEYWORD = regionPrefix + "NMTOKEN_KEYWORD"; //$NON-NLS-1$ - public static final String NMTOKENS_KEYWORD = regionPrefix + "NMTOKENS_KEYWORD"; //$NON-NLS-1$ - public static final String NOTATION_KEYWORD = regionPrefix + "NOTATION_KEYWORD"; //$NON-NLS-1$ - public static final String ENUM_CHOICE = regionPrefix + "ENUM_CHOICE"; //$NON-NLS-1$ - public static final String PARM_ENTITY_TYPE = regionPrefix + "PARM_ENTITY_TYPE"; //$NON-NLS-1$ - - // attribute defaults keywords - public static final String REQUIRED_KEYWORD = regionPrefix + "REQUIRED_KEYWORD"; //$NON-NLS-1$ - public static final String IMPLIED_KEYWORD = regionPrefix + "IMPLIED_KEYWORD"; //$NON-NLS-1$ - public static final String FIXED_KEYWORD = regionPrefix + "FIXED_KEYWORD"; //$NON-NLS-1$ -}// DTDRegionTypes diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/contenttype/ContentTypeIdForDTD.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/contenttype/ContentTypeIdForDTD.java deleted file mode 100644 index 9795522930..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/contenttype/ContentTypeIdForDTD.java +++ /dev/null @@ -1,47 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - * - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.provisional.contenttype; - -/** - * <p> - * This class, with its one field, is a convenience to provide compile-time - * safety when referring to the DTD contentType ID. - * </p> - * - * <p> - * This class is not meant to be instantiated or subclassed. - * </p> - */ - -public final class ContentTypeIdForDTD { - /** - * The value of the ContentTypeID_DTD id field will match what is - * specified in org.eclipse.wst.dtd.core/plugin.xml for the DTD content - * type. - * - * This value is intentionally set through a default protected method so - * that it will not be inlined. - */ - public final static String ContentTypeID_DTD = getConstantString(); - - private ContentTypeIdForDTD() { - super(); - } - - /** - * @return the DTD Content Type Identifier ID as a String - */ - static String getConstantString() { - return "org.eclipse.wst.dtd.core.dtdsource"; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/document/DTDModel.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/document/DTDModel.java deleted file mode 100644 index 623ca492a0..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/document/DTDModel.java +++ /dev/null @@ -1,27 +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.dtd.core.internal.provisional.document; - -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; - -/** - * <p> - * An interface implemented by the SSE-based DTD model. - * </p> - * - * <p> - * This interface is not intended to be implemented by clients. - * </p> - */ -public interface DTDModel extends IStructuredModel{ -}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/text/IDTDPartitionTypes.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/text/IDTDPartitionTypes.java deleted file mode 100644 index 1de81194ec..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/provisional/text/IDTDPartitionTypes.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 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.dtd.core.internal.provisional.text; - -/** - * This interface is not intended to be implemented. - * It defines the partition types DTD. - * Clients should reference the partition type Strings defined here directly. - * - * @plannedfor 1.0 - */ -public interface IDTDPartitionTypes { - - String DTD_DEFAULT = "org.eclipse.wst.dtd.DEFAULT"; //$NON-NLS-1$ -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tasks/DTDFileTaskScanner.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tasks/DTDFileTaskScanner.java deleted file mode 100644 index 7b3269e559..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tasks/DTDFileTaskScanner.java +++ /dev/null @@ -1,28 +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.dtd.core.internal.tasks; - -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; -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.tasks.StructuredFileTaskScanner; - -public class DTDFileTaskScanner extends StructuredFileTaskScanner { - public DTDFileTaskScanner() { - super(); - } - - protected boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion) { - return textRegion.getType().equals(DTDRegionTypes.COMMENT_CONTENT); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java deleted file mode 100644 index 741b5b6256..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentReParser.java +++ /dev/null @@ -1,41 +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.dtd.core.internal.text; - -import org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentEvent; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredTextReParser; -import org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser; - - -public class DTDStructuredDocumentReParser extends StructuredDocumentReParser { - - public StructuredDocumentEvent checkForCrossStructuredDocumentRegionBoundryCases() { - IStructuredDocumentRegion startNode = fStructuredDocument.getRegionAtCharacterOffset(fStart); - IStructuredDocumentRegion endNode = fStructuredDocument.getRegionAtCharacterOffset(fStart + fLengthToReplace - 1); - return reparse(startNode.getStart(), endNode.getEnd()); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.internal.text.StructuredDocumentReParser#newInstance() - */ - public IStructuredTextReParser newInstance() { - return new DTDStructuredDocumentReParser(); - } - - protected StructuredDocumentEvent reparse(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) { - return super.reparse(dirtyStart, dirtyEnd); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java deleted file mode 100644 index e15b0e6d37..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/DTDStructuredDocumentRegionFactory.java +++ /dev/null @@ -1,33 +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.dtd.core.internal.text; - -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion; -import org.eclipse.wst.sse.core.internal.text.BasicStructuredDocumentRegion; - - -public class DTDStructuredDocumentRegionFactory { - public static final int DTD_GENERIC = 5; - - public static IStructuredDocumentRegion createStructuredDocumentRegion(int type) { - IStructuredDocumentRegion instance = null; - switch (type) { - case DTD_GENERIC : - instance = new BasicStructuredDocumentRegion(); - break; - default : - break; - } - return instance; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.java deleted file mode 100644 index 7f7dcf7cad..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/RegionIterator.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.dtd.core.internal.text; - -import java.util.NoSuchElementException; - -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; - - -public class RegionIterator { - - private int currentIndex; - - // private IStructuredDocumentRegion flatNode; - private ITextRegionList regions; - // private int startOffset, endOffset; - private ITextRegion startRegion, endRegion; - - public RegionIterator(IStructuredDocumentRegion node) { - this(node, node.getStart(), node.getEnd()); - } - - public RegionIterator(IStructuredDocumentRegion node, int startOffset, int endOffset) { - regions = node.getRegions(); - startRegion = node.getRegionAtCharacterOffset(startOffset); - endRegion = node.getRegionAtCharacterOffset(endOffset - 1); - - for (int i = 0; i < regions.size(); i++) { - ITextRegion region = regions.get(i); - if (startRegion == region) { - currentIndex = i; - break; - } - } - } - - public RegionIterator(ITextRegionList regions) { - this.regions = regions; - startRegion = regions.get(0); - endRegion = regions.get(regions.size() - 1); - currentIndex = 0; - // this(node, node.getStart(), node.getEnd()); - } - - public boolean hasNext() { - if (currentIndex < regions.size()) { - return currentIndex <= regions.indexOf(endRegion); - } - return false; - } - - public boolean hasPrevious() { - if (currentIndex >= 0) { - return currentIndex >= regions.indexOf(startRegion); - } - return false; - } - - public ITextRegion next() { - if (hasNext()) { - return regions.get(currentIndex++); - } - throw new NoSuchElementException(); - } - - public ITextRegion previous() { - if (hasPrevious()) { - return regions.get(--currentIndex); - } - throw new NoSuchElementException(); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/StructuredTextPartitionerForDTD.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/StructuredTextPartitionerForDTD.java deleted file mode 100644 index 0dadbc9a3a..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/text/StructuredTextPartitionerForDTD.java +++ /dev/null @@ -1,42 +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.dtd.core.internal.text; - -import org.eclipse.wst.dtd.core.internal.provisional.text.IDTDPartitionTypes; -import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredPartitionTypes; -import org.eclipse.wst.sse.core.internal.text.rules.StructuredTextPartitioner; - -public class StructuredTextPartitionerForDTD extends StructuredTextPartitioner { - - public StructuredTextPartitionerForDTD() { - super(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner#getDefault() - */ - public String getDefaultPartitionType() { - return IDTDPartitionTypes.DTD_DEFAULT; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner#initLegalContentTypes() - */ - protected void initLegalContentTypes() { - fSupportedTypes = new String[]{IDTDPartitionTypes.DTD_DEFAULT, IStructuredPartitionTypes.UNKNOWN_PARTITION}; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/DTDTokenizer.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/DTDTokenizer.java deleted file mode 100644 index c2206b3476..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/DTDTokenizer.java +++ /dev/null @@ -1,1091 +0,0 @@ -/* The following code was generated by JFlex 1.3.5 on 3/14/05 9:37 PM */ - -/******************************************************************************* - * 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 - * - *******************************************************************************/ -/*nlsXXX*/ -package org.eclipse.wst.dtd.core.internal.tokenizer; - -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; - -/** - * Generate with "dtdskeleton". - * - * It removes some unused fields and avoids some compiler warnings - */ - - -/** - * This class is a scanner generated by - * <a href="http://www.jflex.de/">JFlex</a> 1.3.5 - * on 3/14/05 9:37 PM from the specification file - * <tt>file:/D:/eclipse.wtp/workspace/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtd.flex</tt> - */ -public class DTDTokenizer { - - /** This character denotes the end of file */ - final public static int YYEOF = -1; - - /** initial size of the lookahead buffer */ - final private static int YY_BUFFERSIZE = 16384; - - /** lexical states */ - final public static int ATTRIBUTE_ENUMERATION = 13; - final public static int NOTATION_NAME = 6; - final public static int ELEMENT_CHILD = 1; - final public static int ENTITY_CONTENT = 4; - final public static int COMMENT_CONTENT = 8; - final public static int ATTLIST_NAME = 9; - final public static int EXTERNALID_CONTENT = 7; - final public static int ELEMENT_CONTENT = 1; - final public static int ELEMENT_MIXED = 1; - final public static int ELEMENT_MIXED_OR_CHILD = 1; - final public static int ATTRIBUTE_CONTENT = 11; - final public static int ENTITY_NAME = 3; - final public static int ATTRIBUTE_DEFAULT = 12; - final public static int ELEMENT_NAME = 2; - final public static int YYINITIAL = 0; - final public static int NDATA_CONTENT = 5; - final public static int ATTLIST_CONTENT = 10; - final public static int NODE = 1; - - /** - * Translates characters to character classes - */ - final private static String yycmap_packed = - "\10\0\1\0\1\5\1\3\1\0\1\0\1\2\22\0\1\5\1\6"+ - "\1\1\1\37\1\0\1\23\1\0\1\46\1\42\1\43\1\4\1\7"+ - "\1\45\1\12\1\0\1\0\12\0\1\0\1\10\1\11\1\0\1\13"+ - "\1\4\1\0\1\25\1\31\1\32\1\33\1\14\1\35\2\0\1\21"+ - "\1\0\1\36\1\15\1\16\1\17\1\24\1\27\1\40\1\34\1\26"+ - "\1\20\1\30\2\0\1\41\1\22\1\0\1\0\1\0\2\0\1\0"+ - "\1\0\32\0\1\0\1\44\uff83\0"; - - /** - * Translates characters to character classes - */ - final private static char [] yycmap = yy_unpack_cmap(yycmap_packed); - - /** - * Translates a state to a row index in the transition table - */ - final private static int yy_rowMap [] = { - 0, 39, 78, 117, 156, 195, 234, 273, 312, 351, - 390, 429, 468, 507, 546, 585, 624, 39, 39, 39, - 663, 702, 741, 780, 819, 39, 39, 858, 897, 39, - 39, 936, 936, 975, 1014, 1053, 1092, 1131, 1170, 1209, - 1248, 1287, 1326, 1365, 1404, 1443, 39, 1482, 1521, 1560, - 1599, 1638, 39, 1677, 1716, 1755, 1794, 1833, 1872, 39, - 39, 1911, 1950, 1989, 2028, 2067, 2106, 39, 39, 39, - 2145, 2184, 2223, 2262, 2301, 2340, 2379, 897, 2418, 975, - 2457, 2496, 2535, 2574, 975, 2613, 2652, 2691, 2730, 1560, - 2769, 2808, 2847, 2886, 2925, 2964, 3003, 3042, 3081, 3120, - 1950, 3159, 3198, 3237, 3276, 3315, 1950, 39, 3354, 3393, - 3432, 39, 3471, 3510, 3549, 39, 3588, 3627, 39, 3666, - 3705, 3744, 39, 39, 3783, 3822, 3861, 3900, 3939, 3978, - 4017, 4056, 39, 4095, 4134, 4173, 39, 4212, 4251, 4290, - 4329, 4368, 4407, 4446, 4485, 4524, 4563, 4602, 4641, 4680, - 4719, 4758, 4797, 4836, 4875, 4914, 4953, 4992, 5031, 5070, - 5109, 5148, 5187, 5226, 5265, 5304, 5343, 975, 5382, 5421, - 5460, 5499, 5538, 5577, 1560, 5616, 5655, 5694, 5733, 5772, - 5811, 5850, 546, 5889, 5928, 5967, 6006, 975, 975, 975, - 6045, 1560, 6084, 6123, 1560, 6162, 6201, 6240, 1950, 546, - 6279, 546, 819, 6318, 6357, 6396, 6435, 6474, 6513, 546, - 6552, 1560, 1560, 1560, 1950, 6591, 39, 1950 - }; - - /** - * The packed transition table of the DFA (part 0) - */ - final private static String yy_packed0 = - "\2\17\2\20\1\17\1\20\1\21\1\17\1\22\1\23"+ - "\1\17\1\24\1\25\2\17\1\26\3\17\1\27\1\17"+ - "\1\30\21\17\47\0\2\31\2\20\1\32\1\20\1\0"+ - "\1\32\1\31\1\33\1\31\1\33\23\31\1\34\2\31"+ - "\1\35\1\36\2\37\1\31\2\40\2\20\1\0\1\20"+ - "\3\40\1\33\1\40\1\33\7\40\1\41\16\40\4\0"+ - "\1\40\1\42\1\43\2\20\1\42\1\20\3\42\1\33"+ - "\1\42\1\33\12\42\1\44\1\45\16\42\1\46\2\47"+ - "\2\20\1\47\1\20\3\47\1\33\1\47\1\33\33\47"+ - "\2\50\2\20\1\0\1\20\2\0\1\50\1\33\1\50"+ - "\1\33\26\50\4\0\1\50\1\42\1\43\2\20\1\42"+ - "\1\20\3\42\1\33\1\42\1\33\3\42\1\51\6\42"+ - "\1\52\1\53\16\42\1\46\2\54\2\55\1\54\1\55"+ - "\4\54\1\56\1\57\33\54\2\60\2\20\1\42\1\20"+ - "\2\42\1\60\1\33\1\60\1\33\26\60\4\42\1\60"+ - "\2\61\2\20\1\42\1\20\2\42\1\61\1\33\1\61"+ - "\1\33\26\61\4\42\1\61\1\62\1\63\1\64\1\65"+ - "\1\62\1\66\3\62\1\33\1\62\1\33\1\67\2\62"+ - "\1\70\1\62\1\71\10\62\1\72\4\62\1\73\2\62"+ - "\1\74\2\75\1\62\1\76\1\77\1\100\2\20\1\77"+ - "\1\20\3\77\1\33\1\77\1\33\23\77\1\101\6\77"+ - "\1\102\2\103\2\20\1\103\1\20\3\103\1\33\1\103"+ - "\1\33\26\103\1\104\1\105\1\106\2\103\2\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\7\17\1\0"+ - "\23\17\2\0\2\20\1\0\1\20\53\0\1\107\34\0"+ - "\2\17\2\0\1\17\2\0\1\17\2\0\1\17\1\0"+ - "\1\17\1\110\1\17\1\111\3\17\1\0\25\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\7\17\1\0"+ - "\1\112\22\17\2\113\2\0\1\113\2\0\1\113\2\0"+ - "\1\113\1\0\7\113\1\0\23\113\2\17\2\0\1\17"+ - "\2\0\1\17\2\0\1\17\1\0\4\17\1\114\2\17"+ - "\1\0\23\17\2\31\6\0\1\31\1\0\1\31\1\0"+ - "\26\31\4\0\3\31\6\0\1\31\1\0\1\31\1\0"+ - "\13\31\1\115\12\31\4\0\1\31\2\0\2\116\1\0"+ - "\1\116\31\0\1\117\7\0\2\40\4\0\3\40\1\0"+ - "\1\40\1\0\26\40\4\0\1\40\2\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\33\42\1\43\1\120"+ - "\2\121\1\43\1\121\3\43\1\121\1\43\1\121\33\43"+ - "\2\42\2\0\1\42\1\0\3\42\1\0\1\42\1\0"+ - "\6\42\1\122\26\42\2\0\1\42\1\0\3\42\1\0"+ - "\1\42\1\0\14\42\1\123\16\42\2\46\2\124\1\46"+ - "\1\124\3\46\1\124\1\46\1\124\32\46\1\125\2\47"+ - "\2\0\1\47\1\0\3\47\1\0\1\47\1\0\33\47"+ - "\2\50\6\0\1\50\1\0\1\50\1\0\26\50\4\0"+ - "\1\50\2\42\2\0\1\42\1\0\3\42\1\0\1\42"+ - "\1\0\17\42\1\126\15\42\2\0\1\42\1\0\3\42"+ - "\1\0\1\42\1\0\6\42\1\127\26\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\14\42\1\130\16\42"+ - "\12\54\2\0\35\54\2\55\1\54\1\55\4\54\2\0"+ - "\33\54\12\0\1\131\34\0\2\60\2\0\1\42\1\0"+ - "\2\42\1\60\1\0\1\60\1\0\26\60\4\42\1\60"+ - "\2\61\2\0\1\42\1\0\2\42\1\61\1\0\1\61"+ - "\1\0\26\61\4\42\1\61\2\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\26\62\3\0\2\62\1\63"+ - "\1\132\2\133\1\63\1\133\3\63\1\133\1\63\1\133"+ - "\26\63\3\133\2\63\3\0\1\65\50\0\1\66\41\0"+ - "\2\62\2\0\1\62\1\0\3\62\1\0\1\62\1\0"+ - "\3\62\1\134\22\62\3\0\4\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\2\62\1\135\5\62\1\136"+ - "\15\62\3\0\4\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\17\62\1\137\6\62\3\0\4\62\2\0"+ - "\1\62\1\0\3\62\1\0\1\62\1\0\17\62\1\140"+ - "\6\62\3\0\4\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\5\62\1\141\12\62\1\142\1\143\4\62"+ - "\3\0\2\62\2\76\2\144\1\76\1\144\3\76\1\144"+ - "\1\76\1\144\26\76\3\144\1\76\1\132\2\77\2\0"+ - "\1\77\1\0\3\77\1\0\1\77\1\0\33\77\1\100"+ - "\1\145\2\146\1\100\1\146\3\100\1\146\1\100\1\146"+ - "\33\100\2\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\5\77\1\147\12\77\1\150\1\151\11\77\2\102"+ - "\2\152\1\102\1\152\3\102\1\152\1\102\1\152\32\102"+ - "\1\153\2\103\2\0\1\103\1\0\3\103\1\0\1\103"+ - "\1\0\26\103\3\0\2\103\12\0\1\154\34\0\2\17"+ - "\2\0\1\17\2\0\1\17\2\0\1\17\1\0\1\155"+ - "\6\17\1\0\25\17\2\0\1\17\2\0\1\17\2\0"+ - "\1\17\1\0\4\17\1\156\2\17\1\0\25\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\4\17\1\157"+ - "\2\17\1\0\23\17\2\113\2\0\1\113\2\0\1\113"+ - "\1\160\1\0\1\113\1\0\7\113\1\0\23\113\2\17"+ - "\2\0\1\17\2\0\1\17\2\0\1\17\1\0\4\17"+ - "\1\161\2\17\1\0\23\17\2\31\6\0\1\31\1\0"+ - "\1\31\1\0\16\31\1\162\7\31\4\0\1\31\27\0"+ - "\1\163\17\0\1\121\1\164\45\121\2\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\12\42\1\165\22\42"+ - "\2\0\1\42\1\0\3\42\1\0\1\42\1\0\15\42"+ - "\1\166\15\42\46\124\1\167\2\42\2\0\1\42\1\0"+ - "\3\42\1\0\1\42\1\0\11\42\1\170\23\42\2\0"+ - "\1\42\1\0\3\42\1\0\1\42\1\0\12\42\1\171"+ - "\22\42\2\0\1\42\1\0\3\42\1\0\1\42\1\0"+ - "\15\42\1\172\15\42\13\0\1\173\33\0\1\133\1\174"+ - "\45\133\2\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\4\62\1\175\21\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\4\62\1\176\21\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\4\62\1\177\21\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\20\62\1\200\5\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\11\62\1\201\14\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\2\62\1\202\23\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\1\203\25\62\3\0\4\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\5\62\1\204\20\62\3\0"+ - "\2\62\46\144\1\174\1\146\1\205\45\146\2\77\2\0"+ - "\1\77\1\0\3\77\1\0\1\77\1\0\2\77\1\206"+ - "\32\77\2\0\1\77\1\0\3\77\1\0\1\77\1\0"+ - "\1\207\34\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\5\77\1\210\25\77\46\152\1\211\2\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\2\17\1\212"+ - "\4\17\1\0\25\17\2\0\1\17\2\0\1\17\2\0"+ - "\1\17\1\0\5\17\1\213\1\17\1\0\25\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\7\17\1\0"+ - "\1\17\1\214\23\17\2\0\1\17\2\0\1\17\2\0"+ - "\1\17\1\0\1\17\1\215\5\17\1\0\23\17\2\31"+ - "\6\0\1\31\1\0\1\31\1\0\17\31\1\216\6\31"+ - "\4\0\1\31\32\0\1\217\14\0\2\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\4\42\1\220\30\42"+ - "\2\0\1\42\1\0\3\42\1\0\1\42\1\0\1\42"+ - "\1\221\33\42\2\0\1\42\1\0\3\42\1\0\1\42"+ - "\1\0\4\42\1\222\30\42\2\0\1\42\1\0\3\42"+ - "\1\0\1\42\1\0\4\42\1\223\30\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\1\42\1\224\31\42"+ - "\2\62\2\0\1\62\1\0\3\62\1\0\1\62\1\0"+ - "\5\62\1\225\20\62\3\0\4\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\10\62\1\226\15\62\3\0"+ - "\4\62\2\0\1\62\1\0\3\62\1\0\1\62\1\0"+ - "\11\62\1\227\14\62\3\0\4\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\1\230\25\62\3\0\4\62"+ - "\2\0\1\62\1\0\3\62\1\0\1\62\1\0\4\62"+ - "\1\231\21\62\3\0\4\62\2\0\1\62\1\0\3\62"+ - "\1\0\1\62\1\0\13\62\1\232\12\62\3\0\4\62"+ - "\2\0\1\62\1\0\3\62\1\0\1\62\1\0\24\62"+ - "\1\233\1\62\3\0\4\62\2\0\1\62\1\0\3\62"+ - "\1\0\1\62\1\0\25\62\1\234\3\0\2\62\2\77"+ - "\2\0\1\77\1\0\3\77\1\0\1\77\1\0\13\77"+ - "\1\235\21\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\24\77\1\236\10\77\2\0\1\77\1\0\3\77"+ - "\1\0\1\77\1\0\25\77\1\237\5\77\2\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\1\240\6\17"+ - "\1\0\25\17\2\0\1\17\2\0\1\17\2\0\1\17"+ - "\1\0\4\17\1\241\2\17\1\0\25\17\2\0\1\17"+ - "\2\0\1\17\2\0\1\17\1\0\4\17\1\242\2\17"+ - "\1\0\25\17\2\0\1\17\2\0\1\17\2\0\1\17"+ - "\1\0\5\17\1\243\1\17\1\0\23\17\2\31\6\0"+ - "\1\31\1\0\1\31\1\0\11\31\1\244\14\31\4\0"+ - "\1\31\33\0\1\245\13\0\2\42\2\0\1\42\1\0"+ - "\3\42\1\0\1\42\1\0\1\246\34\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\5\42\1\247\27\42"+ - "\2\0\1\42\1\0\3\42\1\0\1\42\1\0\11\42"+ - "\1\250\23\42\2\0\1\42\1\0\3\42\1\0\1\42"+ - "\1\0\1\251\34\42\2\0\1\42\1\0\3\42\1\0"+ - "\1\42\1\0\5\42\1\252\25\42\2\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\4\62\1\253\21\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\22\62\1\254\3\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\4\62\1\255\21\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\21\62\1\256\4\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\11\62\1\257\14\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\1\62\1\260\24\62\3\0\4\62\2\0\1\62"+ - "\1\0\3\62\1\0\1\62\1\0\14\62\1\261\11\62"+ - "\3\0\4\62\2\0\1\62\1\0\3\62\1\0\1\62"+ - "\1\0\1\262\25\62\3\0\2\62\2\77\2\0\1\77"+ - "\1\0\3\77\1\0\1\77\1\0\1\77\1\263\33\77"+ - "\2\0\1\77\1\0\3\77\1\0\1\77\1\0\14\77"+ - "\1\264\20\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\1\265\32\77\2\17\2\0\1\17\2\0\1\17"+ - "\2\0\1\17\1\0\3\17\1\266\3\17\1\0\25\17"+ - "\2\0\1\17\2\0\1\17\2\0\1\17\1\0\6\17"+ - "\1\267\1\0\25\17\2\0\1\17\2\0\1\17\2\0"+ - "\1\17\1\0\5\17\1\270\1\17\1\0\25\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\7\17\1\0"+ - "\2\17\1\271\20\17\2\31\6\0\1\31\1\0\1\31"+ - "\1\0\4\31\1\272\21\31\4\0\1\31\25\0\1\273"+ - "\21\0\2\42\2\0\1\42\1\0\3\42\1\0\1\42"+ - "\1\0\2\42\1\274\32\42\2\0\1\42\1\0\3\42"+ - "\1\0\1\42\1\0\16\42\1\274\16\42\2\0\1\42"+ - "\1\0\3\42\1\0\1\42\1\0\2\42\1\275\32\42"+ - "\2\0\1\42\1\0\3\42\1\0\1\42\1\0\16\42"+ - "\1\276\14\42\2\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\5\62\1\277\1\300\17\62\3\0\4\62"+ - "\2\0\1\62\1\0\3\62\1\0\1\62\1\0\1\301"+ - "\25\62\3\0\4\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\5\62\1\302\20\62\3\0\4\62\2\0"+ - "\1\62\1\0\3\62\1\0\1\62\1\0\12\62\1\303"+ - "\13\62\3\0\4\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\5\62\1\234\20\62\3\0\4\62\2\0"+ - "\1\62\1\0\3\62\1\0\1\62\1\0\5\62\1\304"+ - "\20\62\3\0\4\62\2\0\1\62\1\0\3\62\1\0"+ - "\1\62\1\0\17\62\1\132\6\62\3\0\2\62\2\77"+ - "\2\0\1\77\1\0\3\77\1\0\1\77\1\0\5\77"+ - "\1\305\27\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\5\77\1\306\27\77\2\0\1\77\1\0\3\77"+ - "\1\0\1\77\1\0\17\77\1\307\13\77\2\17\2\0"+ - "\1\17\2\0\1\17\2\0\1\17\1\0\4\17\1\310"+ - "\2\17\1\0\25\17\2\0\1\17\2\0\1\17\2\0"+ - "\1\17\1\0\7\17\1\0\1\311\24\17\2\0\1\17"+ - "\2\0\1\17\2\0\1\17\1\0\4\17\1\312\2\17"+ - "\1\0\23\17\2\31\6\0\1\31\1\0\1\31\1\0"+ - "\11\31\1\313\14\31\4\0\1\31\20\0\1\314\26\0"+ - "\2\62\2\0\1\62\1\0\3\62\1\0\1\62\1\0"+ - "\1\315\25\62\3\0\4\62\2\0\1\62\1\0\3\62"+ - "\1\0\1\62\1\0\3\62\1\316\22\62\3\0\4\62"+ - "\2\0\1\62\1\0\3\62\1\0\1\62\1\0\10\62"+ - "\1\317\15\62\3\0\4\62\2\0\1\62\1\0\3\62"+ - "\1\0\1\62\1\0\20\62\1\234\5\62\3\0\2\62"+ - "\2\77\2\0\1\77\1\0\3\77\1\0\1\77\1\0"+ - "\1\320\34\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\20\77\1\321\12\77\2\17\2\0\1\17\2\0"+ - "\1\17\2\0\1\17\1\0\3\17\1\322\3\17\1\0"+ - "\23\17\25\0\1\323\21\0\2\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\12\62\1\324\13\62\3\0"+ - "\4\62\2\0\1\62\1\0\3\62\1\0\1\62\1\0"+ - "\12\62\1\325\13\62\3\0\4\62\2\0\1\62\1\0"+ - "\3\62\1\0\1\62\1\0\3\62\1\326\22\62\3\0"+ - "\2\62\2\77\2\0\1\77\1\0\3\77\1\0\1\77"+ - "\1\0\17\77\1\327\15\77\2\0\1\77\1\0\3\77"+ - "\1\0\1\77\1\0\1\330\32\77\2\0\2\323\1\0"+ - "\1\323\35\0\1\331\3\0\2\77\2\0\1\77\1\0"+ - "\3\77\1\0\1\77\1\0\17\77\1\332\13\77"; - - /** - * The transition table of the DFA - */ - final private static int yytrans [] = yy_unpack(); - - - /* error codes */ - final private static int YY_UNKNOWN_ERROR = 0; - final static int YY_ILLEGAL_STATE = 1; - final private static int YY_NO_MATCH = 2; - final private static int YY_PUSHBACK_2BIG = 3; - - /* error messages for the codes above */ - final private static String YY_ERROR_MSG[] = { - "Unkown internal scanner error", - "Internal error: unknown state", - "Error: could not match input", - "Error: pushback value was too large" - }; - - /** - * YY_ATTRIBUTE[aState] contains the attributes of state <code>aState</code> - */ - private final static byte YY_ATTRIBUTE[] = { - 0, 8, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, - 1, 9, 9, 9, 1, 1, 1, 1, 1, 9, 9, 1, 1, 9, 9, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 1, - 1, 1, 1, 1, 9, 1, 1, 1, 1, 1, 1, 9, 9, 1, 1, 1, - 1, 1, 1, 9, 9, 9, 0, 1, 1, 1, 0, 1, 1, 0, 0, 1, - 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 1, 9, 1, 1, 1, 9, - 1, 1, 0, 9, 1, 1, 9, 1, 1, 1, 9, 9, 1, 1, 1, 1, - 1, 1, 1, 1, 9, 1, 1, 1, 9, 1, 1, 1, 1, 1, 0, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, - 1, 1, 0, 1, 1, 1, 1, 1, 9, 1 - }; - - /** the input device */ - private java.io.Reader yy_reader; - - /** the current state of the DFA */ - private int yy_state; - - /** the current lexical state */ - private int yy_lexical_state = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char yy_buffer[] = new char[YY_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int yy_markedPos; - - /** the textposition at the last state to be included in yytext */ - private int yy_pushbackPos; - - /** the current text position in the buffer */ - private int yy_currentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int yy_startRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int yy_endRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - int yycolumn; - - /** yy_atEOF == true <=> the scanner is at the EOF */ - private boolean yy_atEOF; - - /* user code: */ - int node_count = 0; - String currentString; - - private Token createToken(String type) { - return new Token(type, yytext(), yyline, yychar + startOffset, yylength()); - } - - private int startOffset = 0; - public void setStartOffset(int offset) { - this.startOffset = offset; - } - - public void setLine(int line) { - this.yyline = line; - } - - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ - public DTDTokenizer(java.io.Reader in) { - this.yy_reader = in; - } - - /** - * Creates a new scanner. - * There is also java.io.Reader version of this constructor. - * - * @param in the java.io.Inputstream to read input from. - */ - public DTDTokenizer(java.io.InputStream in) { - this(new java.io.InputStreamReader(in)); - } - - /** - * Unpacks the split, compressed DFA transition table. - * - * @return the unpacked transition table - */ - private static int [] yy_unpack() { - int [] trans = new int[6630]; - int offset = 0; - offset = yy_unpack(yy_packed0, offset, trans); - return trans; - } - - /** - * Unpacks the compressed DFA transition table. - * - * @param packed the packed transition table - * @return the index of the last entry - */ - private static int yy_unpack(String packed, int offset, int [] trans) { - int i = 0; /* index in packed string */ - int j = offset; /* index in unpacked array */ - int l = packed.length(); - while (i < l) { - int count = packed.charAt(i++); - int value = packed.charAt(i++); - value--; - do trans[j++] = value; while (--count > 0); - } - return j; - } - - /** - * Unpacks the compressed character translation table. - * - * @param packed the packed character translation table - * @return the unpacked character translation table - */ - private static char [] yy_unpack_cmap(String packed) { - char [] map = new char[0x10000]; - int i = 0; /* index in packed string */ - int j = 0; /* index in unpacked array */ - while (i < 130) { - int count = packed.charAt(i++); - char value = packed.charAt(i++); - do map[j++] = value; while (--count > 0); - } - return map; - } - - - /** - * Refills the input buffer. - * - * @return <code>false</code>, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean yy_refill() throws java.io.IOException { - - /* first: make room (if you can) */ - if (yy_startRead > 0) { - System.arraycopy(yy_buffer, yy_startRead, - yy_buffer, 0, - yy_endRead-yy_startRead); - - /* translate stored positions */ - yy_endRead-= yy_startRead; - yy_currentPos-= yy_startRead; - yy_markedPos-= yy_startRead; - yy_pushbackPos-= yy_startRead; - yy_startRead = 0; - } - - /* is the buffer big enough? */ - if (yy_currentPos >= yy_buffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[yy_currentPos*2]; - System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); - yy_buffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = yy_reader.read(yy_buffer, yy_endRead, - yy_buffer.length-yy_endRead); - - if (numRead < 0) { - return true; - } - else { - yy_endRead+= numRead; - return false; - } - } - - - /** - * Closes the input stream. - */ - final public void yyclose() throws java.io.IOException { - yy_atEOF = true; /* indicate end of file */ - yy_endRead = yy_startRead; /* invalidate buffer */ - - if (yy_reader != null) - yy_reader.close(); - } - - - /** - * Closes the current stream, and resets the - * scanner to read from a new input stream. - * - * All internal variables are reset, the old input stream - * <b>cannot</b> be reused (internal buffer is discarded and lost). - * Lexical state is set to <tt>YY_INITIAL</tt>. - * - * @param reader the new input stream - */ - final public void yyreset(java.io.Reader reader) throws java.io.IOException { - yyclose(); - yy_reader = reader; - yy_atEOF = false; - yy_endRead = yy_startRead = 0; - yy_currentPos = yy_markedPos = yy_pushbackPos = 0; - yyline = yychar = yycolumn = 0; - yy_lexical_state = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - final public int yystate() { - return yy_lexical_state; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - final public void yybegin(int newState) { - yy_lexical_state = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - final public String yytext() { - return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); - } - - - /** - * Returns the character at position <tt>pos</tt> from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - final public char yycharat(int pos) { - return yy_buffer[yy_startRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - final public int yylength() { - return yy_markedPos-yy_startRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ - private void yy_ScanError(int errorCode) { - String message; - try { - message = YY_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; - } - - throw new Error(message); - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ - private void yypushback(int number) { - if ( number > yylength() ) - yy_ScanError(YY_PUSHBACK_2BIG); - - yy_markedPos -= number; - } - - - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ - public Yytoken yylex() throws java.io.IOException { - int yy_input; - int yy_action; - - // cached fields: - int yy_currentPos_l; - int yy_markedPos_l; - int yy_endRead_l = yy_endRead; - char [] yy_buffer_l = yy_buffer; - char [] yycmap_l = yycmap; - - int [] yytrans_l = yytrans; - int [] yy_rowMap_l = yy_rowMap; - byte [] yy_attr_l = YY_ATTRIBUTE; - - while (true) { - yy_markedPos_l = yy_markedPos; - - yychar+= yy_markedPos_l-yy_startRead; - - yy_action = -1; - - yy_currentPos_l = yy_currentPos = - yy_startRead = yy_markedPos_l; - - yy_state = yy_lexical_state; - - - yy_forAction: { - while (true) { - - if (yy_currentPos_l < yy_endRead_l) - yy_input = yy_buffer_l[yy_currentPos_l++]; - else if (yy_atEOF) { - yy_input = YYEOF; - break yy_forAction; - } - else { - // store back cached positions - yy_currentPos = yy_currentPos_l; - yy_markedPos = yy_markedPos_l; - boolean eof = yy_refill(); - // get translated positions and possibly new buffer - yy_currentPos_l = yy_currentPos; - yy_markedPos_l = yy_markedPos; - yy_buffer_l = yy_buffer; - yy_endRead_l = yy_endRead; - if (eof) { - yy_input = YYEOF; - break yy_forAction; - } - else { - yy_input = yy_buffer_l[yy_currentPos_l++]; - } - } - int yy_next = yytrans_l[ yy_rowMap_l[yy_state] + yycmap_l[yy_input] ]; - if (yy_next == -1) break yy_forAction; - yy_state = yy_next; - - int yy_attributes = yy_attr_l[yy_state]; - if ( (yy_attributes & 1) == 1 ) { - yy_action = yy_state; - yy_markedPos_l = yy_currentPos_l; - if ( (yy_attributes & 8) == 8 ) break yy_forAction; - } - - } - } - - // store back cached position - yy_markedPos = yy_markedPos_l; - - switch (yy_action) { - - case 26: - { yypushback(yylength()); yybegin(YYINITIAL); } - case 219: break; - case 89: - case 123: - { yypushback(yylength()); yybegin(ATTRIBUTE_DEFAULT); } - case 220: break; - case 12: - case 62: - case 63: - case 64: - case 65: - case 102: - case 103: - case 104: - case 133: - case 134: - case 135: - case 156: - case 157: - case 158: - case 178: - case 179: - case 180: - case 196: - case 197: - case 207: - case 208: - case 215: - { yypushback(yylength()); yybegin(ATTLIST_CONTENT); } - case 221: break; - case 51: - case 52: - { yypushback(yylength()); yybegin(ATTLIST_CONTENT); } - case 222: break; - case 205: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.NMTOKEN_KEYWORD); } - case 223: break; - case 194: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.IDREFS_KEYWORD); } - case 224: break; - case 191: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ENTITY_KEYWORD); } - case 225: break; - case 107: - { yybegin(COMMENT_CONTENT); return createToken(DTDRegionTypes.COMMENT_START); } - case 226: break; - case 48: - { yybegin(ATTRIBUTE_CONTENT); return createToken(DTDRegionTypes.ATTRIBUTE_NAME); } - case 227: break; - case 39: - { yybegin(EXTERNALID_CONTENT); return createToken(DTDRegionTypes.NAME); } - case 228: break; - case 106: - case 136: - { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.SINGLEQUOTED_LITERAL); } - case 229: break; - case 100: - case 132: - { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.DOUBLEQUOTED_LITERAL); } - case 230: break; - case 202: - case 216: - { return createToken(DTDRegionTypes.CONTENT_PCDATA); } - case 231: break; - case 189: - { return createToken(DTDRegionTypes.PUBLIC_KEYWORD); } - case 232: break; - case 188: - { return createToken(DTDRegionTypes.SYSTEM_KEYWORD); } - case 233: break; - case 14: - case 20: - case 21: - case 23: - case 71: - case 72: - case 73: - case 75: - case 108: - case 109: - case 110: - case 112: - case 137: - case 138: - case 139: - case 140: - case 159: - case 160: - case 161: - case 162: - case 181: - case 183: - case 184: - case 200: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 234: break; - case 4: - case 33: - case 34: - case 35: - case 36: - case 37: - case 81: - case 82: - case 116: - case 117: - case 143: - case 144: - case 165: - case 166: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 235: break; - case 7: - case 40: - case 41: - case 42: - case 85: - case 86: - case 87: - case 119: - case 120: - case 121: - case 145: - case 146: - case 147: - case 168: - case 169: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 236: break; - case 9: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 237: break; - case 10: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 238: break; - case 43: - case 45: - case 46: - { return createToken(DTDRegionTypes.COMMENT_CONTENT); } - case 239: break; - case 60: - { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - case 240: break; - case 198: - { return createToken(DTDRegionTypes.FIXED_KEYWORD); } - case 241: break; - case 214: - { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.IMPLIED_KEYWORD); } - case 242: break; - case 212: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.NMTOKENS_KEYWORD); } - case 243: break; - case 211: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ENTITIES_KEYWORD); } - case 244: break; - case 209: - { yybegin(NOTATION_NAME); return createToken(DTDRegionTypes.NOTATION_TAG); } - case 245: break; - case 201: - { yybegin(ATTLIST_NAME); return createToken(DTDRegionTypes.ATTLIST_TAG); } - case 246: break; - case 199: - { yybegin(ELEMENT_NAME); return createToken(DTDRegionTypes.ELEMENT_TAG); } - case 247: break; - case 182: - { yybegin(ENTITY_NAME); return createToken(DTDRegionTypes.ENTITY_TAG); } - case 248: break; - case 167: - { yybegin(NDATA_CONTENT); return createToken(DTDRegionTypes.NDATA_KEYWORD); } - case 249: break; - case 111: - { return createToken(DTDRegionTypes.ENTITY_PARM); } - case 250: break; - case 94: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ID_KEYWORD); } - case 251: break; - case 25: - { return createToken(DTDRegionTypes.OCCUR_TYPE); } - case 252: break; - case 16: - { return createToken(DTDRegionTypes.EXCLAMATION); } - case 253: break; - case 15: - { return createToken(DTDRegionTypes.WHITESPACE); } - case 254: break; - case 11: - case 49: - case 50: - case 54: - case 55: - case 56: - case 57: - case 58: - case 61: - case 91: - case 92: - case 93: - case 95: - case 96: - case 97: - case 98: - case 124: - case 125: - case 126: - case 127: - case 128: - case 129: - case 130: - case 131: - case 148: - case 149: - case 150: - case 151: - case 152: - case 153: - case 154: - case 155: - case 170: - case 171: - case 172: - case 175: - case 176: - case 177: - case 190: - case 192: - case 193: - case 195: - case 204: - case 206: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.PARM_ENTITY_TYPE); } - case 255: break; - case 28: - { return createToken(DTDRegionTypes.LEFT_PAREN); } - case 256: break; - case 29: - { return createToken(DTDRegionTypes.RIGHT_PAREN); } - case 257: break; - case 44: - { return createToken(DTDRegionTypes.WHITESPACE); } - case 258: break; - case 53: - { return createToken(DTDRegionTypes.WHITESPACE); } - case 259: break; - case 59: - { yypushback(yylength()); yybegin(ATTRIBUTE_ENUMERATION); } - case 260: break; - case 67: - { return createToken(DTDRegionTypes.LEFT_PAREN); } - case 261: break; - case 68: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.RIGHT_PAREN); } - case 262: break; - case 69: - { return createToken(DTDRegionTypes.ENUM_CHOICE); } - case 263: break; - case 31: - { yybegin(ENTITY_CONTENT); return createToken(DTDRegionTypes.NAME); } - case 264: break; - case 47: - { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.NAME); } - case 265: break; - case 187: - { yypushback(yylength()); yybegin(EXTERNALID_CONTENT); } - case 266: break; - case 213: - { yybegin(ATTRIBUTE_ENUMERATION); return createToken(DTDRegionTypes.NOTATION_KEYWORD); } - case 267: break; - case 174: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.CDATA_KEYWORD); } - case 268: break; - case 173: - { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.IDREF_KEYWORD); } - case 269: break; - case 217: - { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.REQUIRED_KEYWORD); } - case 270: break; - case 122: - { yybegin(YYINITIAL); return createToken(DTDRegionTypes.COMMENT_END); } - case 271: break; - case 84: - case 118: - { return createToken(DTDRegionTypes.SINGLEQUOTED_LITERAL); } - case 272: break; - case 79: - case 115: - { return createToken(DTDRegionTypes.DOUBLEQUOTED_LITERAL); } - case 273: break; - case 24: - case 27: - case 76: - case 113: - case 141: - case 163: - case 185: - { return createToken(DTDRegionTypes.NAME); } - case 274: break; - case 5: - case 38: - { yybegin(YYINITIAL); return createToken(DTDRegionTypes.NDATA_VALUE); } - case 275: break; - case 13: - case 66: - { return createToken(DTDRegionTypes.NAME); } - case 276: break; - case 18: - { return createToken(DTDRegionTypes.START_TAG); } - case 277: break; - case 17: - { return createToken(DTDRegionTypes.SEMICOLON); } - case 278: break; - case 30: - { return createToken(DTDRegionTypes.CONNECTOR); } - case 279: break; - case 22: - { return createToken(DTDRegionTypes.PERCENT); } - case 280: break; - case 19: - { return createToken(DTDRegionTypes.END_TAG); } - case 281: break; - case 32: - { return createToken(DTDRegionTypes.PERCENT); } - case 282: break; - default: - if (yy_input == YYEOF && yy_startRead == yy_currentPos) { - yy_atEOF = true; - return null; - } - else { - yy_ScanError(YY_NO_MATCH); - } - } - } - } - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Token.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Token.java deleted file mode 100644 index f8dbaba403..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Token.java +++ /dev/null @@ -1,61 +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.dtd.core.internal.tokenizer; - -public class Token extends Yytoken { - public static final int COMMENT_START = 9; - public static final int CONNECTOR = 6; - public static final int CONTENT_ANY = 43; - public static final int CONTENT_EMPTY = 42; - public static final int CONTENT_PCDATA = 44; - public static final int ELEMENT_CONTENT = 41; - - public static final int ELEMENT_TAG = 40; - public static final int END_TAG = 2; - public static final int ENTITY_CONTENT = 32; - public static final int ENTITY_PARM = 31; - - public static final int ENTITY_TAG = 30; - public static final int EXCLAMATION = 8; - public static final int LEFT_PAREN = 3; - public static final int NAME = 0; - public static final int NOTATION_CONTENT = 21; - - - public static final int NOTATION_TAG = 20; - - // public static final int CONNECT_CHOICE = 5; - // public static final int CONNECT_SEQUENCE = 6; - // public static final int OCCUR_OPTIONAL = 7; - // public static final int OCCUR_ONE_OR_MORE = 8; - // public static final int OCCUR_ZERO_OR_MORE = 9; - public static final int OCCUR_TYPE = 7; - public static final int RIGHT_PAREN = 4; - public static final int START_TAG = 1; - public static final int WHITESPACE = 5; - - - public Token(String type) { - super(type); - } - - public Token(String type, String text, int line, int charBegin, int length) { - super(type, text, line, charBegin, length); - } - - public Token createCopy() { - Token copy = new Token(getType(), getText(), getStartLine(), getStartOffset(), getLength()); - return copy; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Yytoken.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Yytoken.java deleted file mode 100644 index 120da07532..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/Yytoken.java +++ /dev/null @@ -1,89 +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.dtd.core.internal.tokenizer; - -class Yytoken { - public int m_charBegin; - public int m_length; - public int m_line; - public String m_text; - public String m_type; - - Yytoken(String type) { - m_type = type; - } - - Yytoken(String type, String text, int line, int charBegin, int length) { - m_type = type; - m_text = new String(text); - m_line = line; - m_charBegin = charBegin; - m_length = length; - } - - public void delete(int start, int length) { - int stringStart = start - m_charBegin; - String oldString = m_text; - m_text = oldString.substring(0, stringStart); - m_text += oldString.substring(stringStart + length); - - m_length = m_text.length(); - System.out.println("new string = " + m_text); //$NON-NLS-1$ - - } - - public boolean equals(Yytoken other) { - return m_type == other.getType() && m_text.equals(other.getText()) && m_line == other.getStartLine() && m_charBegin == other.getStartOffset() && m_length == other.getLength(); - } - - public int getEndOffset() { - return m_charBegin + m_length; - } - - public int getLength() { - return m_length; - } - - public int getStartLine() { - return m_line; - } - - public int getStartOffset() { - return m_charBegin; - } - - public String getText() { - return m_text; - } - - public String getType() { - return m_type; - } - - public void setStartOffset(int startOffset) { - m_charBegin = startOffset; - } - - public String toString() { - return "Text : " + m_text + "\ntype : " + m_type + "\nline : " + m_line + "\ncBeg. : " + m_charBegin + "\ncEnd. : " + getEndOffset() + "\ncLength. : " + m_length; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ - } - - public void updateOffset(int delta) { - m_charBegin += delta; - } - - public void updateText(String newText) { - m_text = newText; - m_length = newText.length(); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtd.flex b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtd.flex deleted file mode 100644 index e3a14aa15f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtd.flex +++ /dev/null @@ -1,327 +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.dtd.core.internal.tokenizer; - -import org.eclipse.wst.dtd.core.internal.parser.DTDRegionTypes; - -/** - * Generate with "dtdskeleton". - * - * It removes some unused fields and avoids some compiler warnings - */ - -%% - -%{ - int node_count = 0; - String currentString; - - private Token createToken(String type) { - return new Token(type, yytext(), yyline, yychar + startOffset, yylength()); - } - - private int startOffset = 0; - public void setStartOffset(int offset) { - this.startOffset = offset; - } - - public void setLine(int line) { - this.yyline = line; - } -%} - -%class DTDTokenizer -%public -%unicode -%char - -%state NODE -%state ELEMENT_NAME -%state ELEMENT_CONTENT -%state ELEMENT_MIXED_OR_CHILD -%state ELEMENT_MIXED -%state ELEMENT_CHILD -%state ENTITY_NAME -%state ENTITY_CONTENT -%state NDATA_CONTENT - -%state NOTATION_NAME -%state EXTERNALID_CONTENT - -%state COMMENT_CONTENT -%state ATTLIST_NAME -%state ATTLIST_CONTENT -%state ATTRIBUTE_CONTENT -%state ATTRIBUTE_DEFAULT -%state ATTRIBUTE_ENUMERATION - - -ALPHA=[A-Za-z] -DIGIT=[0-9] -NONNEWLINE_WHITE_SPACE_CHAR=[\ \t\b\012] -STRING_TEXT=(\\\"|[^\n\r\"]|\\{WHITE_SPACE_CHAR}+\\)* -COMMENT_TEXT=([^*/\n]|[^*\n]"/"[^*\n]|[^/\n]"*"[^/\n]|"*"[^/\n]|"/"[^*\n])* -Ident = {ALPHA}({ALPHA}|{DIGIT}|_)* -InputCharacter = [^\r\n] - -LineTerminator = \r|\n|\r\n - -/* 3 - White Space */ -S = (\x20 | \x09 | \x0D | \x0A)+ -NonLineTerminatorWhitespace = (\x20 | \x09)+ - -WhiteSpace = {LineTerminator} | [ \t\f] - -/* 84 */ -/*Letter = {BaseChar} | {Ideographic} - -/* 85 */ -BaseChar = [\u0041-\u005A] | [\u0061-\u007A] | [\u00C0-\u00D6] | [\u00D8-\u00F6] | [\u00F8-\u00FF] | [\u0100-\u0131] | [\u0134-\u013E] | [\u0141-\u0148] | [\u014A-\u017E] | [\u0180-\u01C3] | [\u01CD-\u01F0] | [\u01F4-\u01F5] | [\u01FA-\u0217] | [\u0250-\u02A8] | [\u02BB-\u02C1] | \u0386 | [\u0388-\u038A] | \u038C | [\u038E-\u03A1] | [\u03A3-\u03CE] | [\u03D0-\u03D6] | \u03DA | \u03DC | \u03DE | \u03E0 | [\u03E2-\u03F3] | [\u0401-\u040C] | [\u040E-\u044F] | [\u0451-\u045C] | [\u045E-\u0481] | [\u0490-\u04C4] | [\u04C7-\u04C8] | [\u04CB-\u04CC] | [\u04D0-\u04EB] | [\u04EE-\u04F5] | [\u04F8-\u04F9] | [\u0531-\u0556] | \u0559 | [\u0561-\u0586] | [\u05D0-\u05EA] | [\u05F0-\u05F2] | [\u0621-\u063A] | [\u0641-\u064A] | [\u0671-\u06B7] | [\u06BA-\u06BE] | [\u06C0-\u06CE] | [\u06D0-\u06D3] | \u06D5 | [\u06E5-\u06E6] | [\u0905-\u0939] | \u093D | [\u0958-\u0961] | [\u0985-\u098C] | [\u098F-\u0990] | [\u0993-\u09A8] | [\u09AA-\u09B0] | \u09B2 | [\u09B6-\u09B9] | [\u09DC-\u09DD] | [\u09DF-\u09E1] | [\u09F0-\u09F1] | [\u0A05-\u0A0A] | [\u0A0F-\u0A10] | [\u0A13-\u0A28] | [\u0A2A-\u0A30] | [\u0A32-\u0A33] | [\u0A35-\u0A36] | [\u0A38-\u0A39] | [\u0A59-\u0A5C] | \u0A5E | [\u0A72-\u0A74] | [\u0A85-\u0A8B] | \u0A8D | [\u0A8F-\u0A91] | [\u0A93-\u0AA8] | [\u0AAA-\u0AB0] | [\u0AB2-\u0AB3] | [\u0AB5-\u0AB9] | \u0ABD | \u0AE0 | [\u0B05-\u0B0C] | [\u0B0F-\u0B10] | [\u0B13-\u0B28] | [\u0B2A-\u0B30] | [\u0B32-\u0B33] | [\u0B36-\u0B39] | \u0B3D | [\u0B5C-\u0B5D] | [\u0B5F-\u0B61] | [\u0B85-\u0B8A] | [\u0B8E-\u0B90] | [\u0B92-\u0B95] | [\u0B99-\u0B9A] | \u0B9C | [\u0B9E-\u0B9F] | [\u0BA3-\u0BA4] | [\u0BA8-\u0BAA] | [\u0BAE-\u0BB5] | [\u0BB7-\u0BB9] | [\u0C05-\u0C0C] | [\u0C0E-\u0C10] | [\u0C12-\u0C28] | [\u0C2A-\u0C33] | [\u0C35-\u0C39] | [\u0C60-\u0C61] | [\u0C85-\u0C8C] | [\u0C8E-\u0C90] | [\u0C92-\u0CA8] | [\u0CAA-\u0CB3] | [\u0CB5-\u0CB9] | \u0CDE | [\u0CE0-\u0CE1] | [\u0D05-\u0D0C] | [\u0D0E-\u0D10] | [\u0D12-\u0D28] | [\u0D2A-\u0D39] | [\u0D60-\u0D61] | [\u0E01-\u0E2E] | \u0E30 | [\u0E32-\u0E33] | [\u0E40-\u0E45] | [\u0E81-\u0E82] | \u0E84 | [\u0E87-\u0E88] | \u0E8A | \u0E8D | [\u0E94-\u0E97] | [\u0E99-\u0E9F] | [\u0EA1-\u0EA3] | \u0EA5 | \u0EA7 | [\u0EAA-\u0EAB] | [\u0EAD-\u0EAE] | \u0EB0 | [\u0EB2-\u0EB3] | \u0EBD | [\u0EC0-\u0EC4] | [\u0F40-\u0F47] | [\u0F49-\u0F69] | [\u10A0-\u10C5] | [\u10D0-\u10F6] | \u1100 | [\u1102-\u1103] | [\u1105-\u1107] | \u1109 | [\u110B-\u110C] | [\u110E-\u1112] | \u113C | \u113E | \u1140 | \u114C | \u114E | \u1150 | [\u1154-\u1155] | \u1159 | [\u115F-\u1161] | \u1163 | \u1165 | \u1167 | \u1169 | [\u116D-\u116E] | [\u1172-\u1173] | \u1175 | \u119E | \u11A8 | \u11AB | [\u11AE-\u11AF] | [\u11B7-\u11B8] | \u11BA | [\u11BC-\u11C2] | \u11EB | \u11F0 | \u11F9 | [\u1E00-\u1E9B] | [\u1EA0-\u1EF9] | [\u1F00-\u1F15] | [\u1F18-\u1F1D] | [\u1F20-\u1F45] | [\u1F48-\u1F4D] | [\u1F50-\u1F57] | \u1F59 | \u1F5B | \u1F5D | [\u1F5F-\u1F7D] | [\u1F80-\u1FB4] | [\u1FB6-\u1FBC] | \u1FBE | [\u1FC2-\u1FC4] | [\u1FC6-\u1FCC] | [\u1FD0-\u1FD3] | [\u1FD6-\u1FDB] | [\u1FE0-\u1FEC] | [\u1FF2-\u1FF4] | [\u1FF6-\u1FFC] | \u2126 | [\u212A-\u212B] | \u212E | [\u2180-\u2182] | [\u3041-\u3094] | [\u30A1-\u30FA] | [\u3105-\u312C] | [\uAC00-\uD7A3] - -/* 86 */ -Ideographic = [\u4E00-\u9FA5] | \u3007 | [\u3021-\u3029] - -/* 4 */ /* is '.' to be escaped?? */ -NameChar = {Letter} | {Digit} | . | - | _ | : | {CombiningChar} | {Extender} - -/* 5 */ -Name = ({Letter} | _ | :) {NameChar}* - -/* 87 */ -CombiningChar = [\u0300-\u0345] | [\u0360-\u0361] | [\u0483-\u0486] | [\u0591-\u05A1] | [\u05A3-\u05B9] | [\u05BB-\u05BD] | \u05BF | [\u05C1-\u05C2] | \u05C4 | [\u064B-\u0652] | \u0670 | [\u06D6-\u06DC] | [\u06DD-\u06DF] | [\u06E0-\u06E4] | [\u06E7-\u06E8] | [\u06EA-\u06ED] | [\u0901-\u0903] | \u093C | [\u093E-\u094C] | \u094D | [\u0951-\u0954] | [\u0962-\u0963] | [\u0981-\u0983] | \u09BC | \u09BE | \u09BF | [\u09C0-\u09C4] | [\u09C7-\u09C8] | [\u09CB-\u09CD] | \u09D7 | [\u09E2-\u09E3] | \u0A02 | \u0A3C | \u0A3E | \u0A3F | [\u0A40-\u0A42] | [\u0A47-\u0A48] | [\u0A4B-\u0A4D] | [\u0A70-\u0A71] | [\u0A81-\u0A83] | \u0ABC | [\u0ABE-\u0AC5] | [\u0AC7-\u0AC9] | [\u0ACB-\u0ACD] | [\u0B01-\u0B03] | \u0B3C | [\u0B3E-\u0B43] | [\u0B47-\u0B48] | [\u0B4B-\u0B4D] | [\u0B56-\u0B57] | [\u0B82-\u0B83] | [\u0BBE-\u0BC2] | [\u0BC6-\u0BC8] | [\u0BCA-\u0BCD] | \u0BD7 | [\u0C01-\u0C03] | [\u0C3E-\u0C44] | [\u0C46-\u0C48] | [\u0C4A-\u0C4D] | [\u0C55-\u0C56] | [\u0C82-\u0C83] | [\u0CBE-\u0CC4] | [\u0CC6-\u0CC8] | [\u0CCA-\u0CCD] | [\u0CD5-\u0CD6] | [\u0D02-\u0D03] | [\u0D3E-\u0D43] | [\u0D46-\u0D48] | [\u0D4A-\u0D4D] | \u0D57 | \u0E31 | [\u0E34-\u0E3A] | [\u0E47-\u0E4E] | \u0EB1 | [\u0EB4-\u0EB9] | [\u0EBB-\u0EBC] | [\u0EC8-\u0ECD] | [\u0F18-\u0F19] | \u0F35 | \u0F37 | \u0F39 | \u0F3E | \u0F3F | [\u0F71-\u0F84] | [\u0F86-\u0F8B] | [\u0F90-\u0F95] | \u0F97 | [\u0F99-\u0FAD] | [\u0FB1-\u0FB7] | \u0FB9 | [\u20D0-\u20DC] | \u20E1 | [\u302A-\u302F] | \u3099 | \u309A - -/* 88 */ -Digit = [\u0030-\u0039] | [\u0660-\u0669] | [\u06F0-\u06F9] | [\u0966-\u096F] | [\u09E6-\u09EF] | [\u0A66-\u0A6F] | [\u0AE6-\u0AEF] | [\u0B66-\u0B6F] | [\u0BE7-\u0BEF] | [\u0C66-\u0C6F] | [\u0CE6-\u0CEF] | [\u0D66-\u0D6F] | [\u0E50-\u0E59] | [\u0ED0-\u0ED9] | [\u0F20-\u0F29] - -/* 89 */ -Extender = \u00B7 | \u02D0 | \u02D1 | \u0387 | \u0640 | \u0E46 | \u0EC6 | \u3005 | [\u3031-\u3035] | [\u309D-\u309E] | [\u30FC-\u30FE] -*/ - -Letter = [a-zA-Z] -NameChar = {Letter} | [0-9] -//Name = ({Letter} | _ | :) {NameChar}* -//Name = [^\x20\x09\x0D\x0A]+ -Name = [^\x20\x09\x0D\x0A\|,\!\?\+\*\(\)<>]+ -ElementRefName = [^\x20\x09\x0D\x0A\|,\?\+\*\(\)<>]+ -EntityName = [^\x20\x09\x0D\x0A\|,\?\*\(\)<>]+ -ParmEntityName = [^\x20\x09\x0D\x0A\!%;<>]+ - -CommentStart = \!-- -CommentContent = [^->]+ -CommentEnd = --> -ElementStart = ELEMENT -ElementContent = [^<>]* - -EntityStart = ENTITY -Entity_Parm = %{S} -EntityContent = {S}[^<>]* - -NotationStart = NOTATION -NotationContent = {S}[^<>]* -AttList = ATTLIST -ExternalParmEntityRef = %{ParmEntityName}; -EndTag = > -StartTag = < -System = SYSTEM -Public = PUBLIC -NData = NDATA - -// these are attribute type keywords -// we reuse NOTATION from NotationStart -// we reuse ENTITY from EntityStart -CData = CDATA -ID = ID -IDRef = IDREF -IDRefs = IDREFS -Entities = ENTITIES -NMToken = NMTOKEN -NMTokens = NMTOKENS - -// these are attribute defaults keywords -Required = #REQUIRED -Implied = #IMPLIED -Fixed = #FIXED - - -Empty = EMPTY -Any = ANY -PcData = #PCDATA -LeftParen = \( -RightParen = \) - -Percent = % -Semicolon = ; -Plus = \+ -Choice = \| -Sequence = , -Connector = {Choice}|{Sequence} -OccurOptional = \? -OccurOneOrMore = \+ -OccurZeroOrMore = \* -OccurType = {OccurOptional}|{OccurOneOrMore}|{OccurZeroOrMore} -Exclamation = \! -SingleQuotedLiteral = '[^']*' -DoubleQuotedLiteral = \"[^\"]*\" -NonTagContent = [^\x20\x09\x0D\x0A<>]* -NonEnumContent = [^\x20\x09\x0D\x0A<>\(\)\|]* - -%% - -<YYINITIAL> { - {StartTag} { return createToken(DTDRegionTypes.START_TAG); } - {EndTag} { return createToken(DTDRegionTypes.END_TAG); } - {Exclamation} { return createToken(DTDRegionTypes.EXCLAMATION); } - {Percent} { return createToken(DTDRegionTypes.PERCENT); } - {Semicolon} { return createToken(DTDRegionTypes.SEMICOLON); } - - {ElementStart} { yybegin(ELEMENT_NAME); return createToken(DTDRegionTypes.ELEMENT_TAG); } - {CommentStart} { yybegin(COMMENT_CONTENT); return createToken(DTDRegionTypes.COMMENT_START); } - {EntityStart} { yybegin(ENTITY_NAME); return createToken(DTDRegionTypes.ENTITY_TAG); } - {NotationStart} { yybegin(NOTATION_NAME); return createToken(DTDRegionTypes.NOTATION_TAG); } - {AttList} { yybegin(ATTLIST_NAME); return createToken(DTDRegionTypes.ATTLIST_TAG); } - - {ExternalParmEntityRef} { return createToken(DTDRegionTypes.ENTITY_PARM); } -// just a parmentityname by itself is no good. we use this -// to capture garbage content at the top level - {ParmEntityName} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - - {S} { return createToken(DTDRegionTypes.WHITESPACE); } -} - -<ELEMENT_NAME> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {PcData}|\({S}*{PcData}{S}*\) { return createToken(DTDRegionTypes.CONTENT_PCDATA); } - {Name} { return createToken(DTDRegionTypes.NAME); } - - {LeftParen} { return createToken(DTDRegionTypes.LEFT_PAREN); } - {Connector} { return createToken(DTDRegionTypes.CONNECTOR); } - {OccurType} { return createToken(DTDRegionTypes.OCCUR_TYPE); } - {RightParen} { return createToken(DTDRegionTypes.RIGHT_PAREN); } - - {StartTag} { yypushback(yylength()); yybegin(YYINITIAL); } - {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -// ******** <!ATTLIST...> -<ATTLIST_NAME> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {Name} { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.NAME); } - {NonTagContent} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<ATTLIST_CONTENT> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {Name} { yybegin(ATTRIBUTE_CONTENT); return createToken(DTDRegionTypes.ATTRIBUTE_NAME); } - {NonTagContent} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<ATTRIBUTE_CONTENT> { - {LineTerminator} { yypushback(yylength()); yybegin(ATTLIST_CONTENT); } - {NonLineTerminatorWhitespace} - { return createToken(DTDRegionTypes.WHITESPACE); } - {CData} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.CDATA_KEYWORD); } - - {ID} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ID_KEYWORD); } - {IDRef} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.IDREF_KEYWORD); } - {IDRefs} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.IDREFS_KEYWORD); } - {EntityStart} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ENTITY_KEYWORD); } - {Entities} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.ENTITIES_KEYWORD); } - {NMToken} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.NMTOKEN_KEYWORD); } - {NMTokens} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.NMTOKENS_KEYWORD); } - {NotationStart} { yybegin(ATTRIBUTE_ENUMERATION); return createToken(DTDRegionTypes.NOTATION_KEYWORD); } - - {Required} | {Implied} | {Fixed} | {SingleQuotedLiteral} | { DoubleQuotedLiteral} - { yypushback(yylength()); yybegin(ATTRIBUTE_DEFAULT); } - - {LeftParen} { yypushback(yylength()); yybegin(ATTRIBUTE_ENUMERATION); } - {NonEnumContent} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.PARM_ENTITY_TYPE); } - {NonEnumContent}|{RightParen}|{Choice} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<ATTRIBUTE_DEFAULT> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {Required} { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.REQUIRED_KEYWORD); } - {Implied} { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.IMPLIED_KEYWORD); } - {Fixed} { return createToken(DTDRegionTypes.FIXED_KEYWORD); } - {SingleQuotedLiteral} { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.SINGLEQUOTED_LITERAL); } - {DoubleQuotedLiteral} { yybegin(ATTLIST_CONTENT); return createToken(DTDRegionTypes.DOUBLEQUOTED_LITERAL); } - {NonTagContent} { yypushback(yylength()); yybegin(ATTLIST_CONTENT); } //return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<ATTRIBUTE_ENUMERATION> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {LeftParen} { return createToken(DTDRegionTypes.LEFT_PAREN); } - {Choice} { return createToken(DTDRegionTypes.ENUM_CHOICE); } - {RightParen} { yybegin(ATTRIBUTE_DEFAULT); return createToken(DTDRegionTypes.RIGHT_PAREN); } - {NonEnumContent} { return createToken(DTDRegionTypes.NAME); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - - -// ******** <!ENTITY...> -<ENTITY_NAME> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {Percent} { return createToken(DTDRegionTypes.PERCENT); } - {EntityName} { yybegin(ENTITY_CONTENT); return createToken(DTDRegionTypes.NAME); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<ENTITY_CONTENT> { -// {EntityContent} { yybegin(YYINITIAL); return createToken(DTDRegionTypes.ENTITY_CONTENT); } - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {System} | {Public} { yypushback(yylength()); yybegin(EXTERNALID_CONTENT); } - {SingleQuotedLiteral} { return createToken(DTDRegionTypes.SINGLEQUOTED_LITERAL); } - {DoubleQuotedLiteral} { return createToken(DTDRegionTypes.DOUBLEQUOTED_LITERAL); } - {NonTagContent} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - - -// ******** <!NOTATION...> -<NOTATION_NAME> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {Name} { yybegin(EXTERNALID_CONTENT); return createToken(DTDRegionTypes.NAME); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<EXTERNALID_CONTENT> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {System} { return createToken(DTDRegionTypes.SYSTEM_KEYWORD); } - {Public} { return createToken(DTDRegionTypes.PUBLIC_KEYWORD); } - {SingleQuotedLiteral} { return createToken(DTDRegionTypes.SINGLEQUOTED_LITERAL); } - {DoubleQuotedLiteral} { return createToken(DTDRegionTypes.DOUBLEQUOTED_LITERAL); } - {NData} { yybegin(NDATA_CONTENT); return createToken(DTDRegionTypes.NDATA_KEYWORD); } - {NonTagContent} { return createToken(DTDRegionTypes.UNKNOWN_CONTENT); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - -<NDATA_CONTENT> { - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {NonTagContent} { yybegin(YYINITIAL); return createToken(DTDRegionTypes.NDATA_VALUE); } - {StartTag} | {EndTag} { yypushback(yylength()); yybegin(YYINITIAL); } -} - - -// ******** <!-- ...> -<COMMENT_CONTENT> { - {CommentEnd} { yybegin(YYINITIAL); return createToken(DTDRegionTypes.COMMENT_END); } - {S} { return createToken(DTDRegionTypes.WHITESPACE); } - {CommentContent} | "-" | ">" { return createToken(DTDRegionTypes.COMMENT_CONTENT); } -} - - diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtdskeleton b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtdskeleton deleted file mode 100644 index 3dbe086560..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/tokenizer/dtdskeleton +++ /dev/null @@ -1,317 +0,0 @@ - - /** This character denotes the end of file */ - final public static int YYEOF = -1; - - /** initial size of the lookahead buffer */ ---- final private static int YY_BUFFERSIZE = ...; - - /** lexical states */ ---- lexical states, charmap - - /* error codes */ - final private static int YY_UNKNOWN_ERROR = 0; - final static int YY_ILLEGAL_STATE = 1; - final private static int YY_NO_MATCH = 2; - final private static int YY_PUSHBACK_2BIG = 3; - - /* error messages for the codes above */ - final private static String YY_ERROR_MSG[] = { - "Unkown internal scanner error", - "Internal error: unknown state", - "Error: could not match input", - "Error: pushback value was too large" - }; - ---- isFinal list - /** the input device */ - private java.io.Reader yy_reader; - - /** the current state of the DFA */ - private int yy_state; - - /** the current lexical state */ - private int yy_lexical_state = YYINITIAL; - - /** this buffer contains the current text to be matched and is - the source of the yytext() string */ - private char yy_buffer[] = new char[YY_BUFFERSIZE]; - - /** the textposition at the last accepting state */ - private int yy_markedPos; - - /** the textposition at the last state to be included in yytext */ - private int yy_pushbackPos; - - /** the current text position in the buffer */ - private int yy_currentPos; - - /** startRead marks the beginning of the yytext() string in the buffer */ - private int yy_startRead; - - /** endRead marks the last character in the buffer, that has been read - from input */ - private int yy_endRead; - - /** number of newlines encountered up to the start of the matched text */ - private int yyline; - - /** the number of characters up to the start of the matched text */ - private int yychar; - - /** - * the number of characters from the last newline up to the start of the - * matched text - */ - int yycolumn; - - /** yy_atEOF == true <=> the scanner is at the EOF */ - private boolean yy_atEOF; - ---- user class code - - /** - * Creates a new scanner - * There is also a java.io.InputStream version of this constructor. - * - * @param in the java.io.Reader to read input from. - */ ---- constructor declaration - - - /** - * Refills the input buffer. - * - * @return <code>false</code>, iff there was new input. - * - * @exception java.io.IOException if any I/O-Error occurs - */ - private boolean yy_refill() throws java.io.IOException { - - /* first: make room (if you can) */ - if (yy_startRead > 0) { - System.arraycopy(yy_buffer, yy_startRead, - yy_buffer, 0, - yy_endRead-yy_startRead); - - /* translate stored positions */ - yy_endRead-= yy_startRead; - yy_currentPos-= yy_startRead; - yy_markedPos-= yy_startRead; - yy_pushbackPos-= yy_startRead; - yy_startRead = 0; - } - - /* is the buffer big enough? */ - if (yy_currentPos >= yy_buffer.length) { - /* if not: blow it up */ - char newBuffer[] = new char[yy_currentPos*2]; - System.arraycopy(yy_buffer, 0, newBuffer, 0, yy_buffer.length); - yy_buffer = newBuffer; - } - - /* finally: fill the buffer with new input */ - int numRead = yy_reader.read(yy_buffer, yy_endRead, - yy_buffer.length-yy_endRead); - - if (numRead < 0) { - return true; - } - else { - yy_endRead+= numRead; - return false; - } - } - - - /** - * Closes the input stream. - */ - final public void yyclose() throws java.io.IOException { - yy_atEOF = true; /* indicate end of file */ - yy_endRead = yy_startRead; /* invalidate buffer */ - - if (yy_reader != null) - yy_reader.close(); - } - - - /** - * Closes the current stream, and resets the - * scanner to read from a new input stream. - * - * All internal variables are reset, the old input stream - * <b>cannot</b> be reused (internal buffer is discarded and lost). - * Lexical state is set to <tt>YY_INITIAL</tt>. - * - * @param reader the new input stream - */ - final public void yyreset(java.io.Reader reader) throws java.io.IOException { - yyclose(); - yy_reader = reader; - yy_atEOF = false; - yy_endRead = yy_startRead = 0; - yy_currentPos = yy_markedPos = yy_pushbackPos = 0; - yyline = yychar = yycolumn = 0; - yy_lexical_state = YYINITIAL; - } - - - /** - * Returns the current lexical state. - */ - final public int yystate() { - return yy_lexical_state; - } - - - /** - * Enters a new lexical state - * - * @param newState the new lexical state - */ - final public void yybegin(int newState) { - yy_lexical_state = newState; - } - - - /** - * Returns the text matched by the current regular expression. - */ - final public String yytext() { - return new String( yy_buffer, yy_startRead, yy_markedPos-yy_startRead ); - } - - - /** - * Returns the character at position <tt>pos</tt> from the - * matched text. - * - * It is equivalent to yytext().charAt(pos), but faster - * - * @param pos the position of the character to fetch. - * A value from 0 to yylength()-1. - * - * @return the character at position pos - */ - final public char yycharat(int pos) { - return yy_buffer[yy_startRead+pos]; - } - - - /** - * Returns the length of the matched text region. - */ - final public int yylength() { - return yy_markedPos-yy_startRead; - } - - - /** - * Reports an error that occured while scanning. - * - * In a wellformed scanner (no or only correct usage of - * yypushback(int) and a match-all fallback rule) this method - * will only be called with things that "Can't Possibly Happen". - * If this method is called, something is seriously wrong - * (e.g. a JFlex bug producing a faulty scanner etc.). - * - * Usual syntax/scanner level error handling should be done - * in error fallback rules. - * - * @param errorCode the code of the errormessage to display - */ ---- yy_ScanError declaration - String message; - try { - message = YY_ERROR_MSG[errorCode]; - } - catch (ArrayIndexOutOfBoundsException e) { - message = YY_ERROR_MSG[YY_UNKNOWN_ERROR]; - } - ---- throws clause - } - - - /** - * Pushes the specified amount of characters back into the input stream. - * - * They will be read again by then next call of the scanning method - * - * @param number the number of characters to be read again. - * This number must not be greater than yylength()! - */ ---- yypushback decl (contains yy_ScanError exception) - if ( number > yylength() ) - yy_ScanError(YY_PUSHBACK_2BIG); - - yy_markedPos -= number; - } - - ---- yy_doEof - /** - * Resumes scanning until the next regular expression is matched, - * the end of input is encountered or an I/O-Error occurs. - * - * @return the next token - * @exception java.io.IOException if any I/O-Error occurs - */ ---- yylex declaration - int yy_input; - int yy_action; - - // cached fields: - int yy_currentPos_l; - int yy_markedPos_l; - int yy_endRead_l = yy_endRead; - char [] yy_buffer_l = yy_buffer; - char [] yycmap_l = yycmap; - ---- local declarations - - while (true) { - yy_markedPos_l = yy_markedPos; - ---- start admin (line, char, col count) - yy_action = -1; - - yy_currentPos_l = yy_currentPos = - yy_startRead = yy_markedPos_l; - ---- start admin (lexstate etc) - - yy_forAction: { - while (true) { - ---- next input, line, col, char count, next transition, isFinal action - yy_action = yy_state; - yy_markedPos_l = yy_currentPos_l; ---- line count update - } - - } - } - - // store back cached position - yy_markedPos = yy_markedPos_l; ---- char count update - - switch (yy_action) { - ---- actions - default: - if (yy_input == YYEOF && yy_startRead == yy_currentPos) { - yy_atEOF = true; ---- eofvalue - } - else { ---- no match - } - } - } - } - ---- main - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDBatchNodeDelete.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDBatchNodeDelete.java deleted file mode 100644 index e56e98c968..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDBatchNodeDelete.java +++ /dev/null @@ -1,57 +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.dtd.core.internal.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; - - -public class DTDBatchNodeDelete { - protected DTDFile dtdFile; - - protected List nodes = new ArrayList(); - - public DTDBatchNodeDelete(DTDFile dtdFile) { - this.dtdFile = dtdFile; - } - - public void addNode(DTDNode node) { - // first check if the node is contained by anyone - for (int i = 0; i < nodes.size(); i++) { - DTDNode currentNode = (DTDNode) nodes.get(i); - - if (currentNode.containsRange(node.getStartOffset(), node.getEndOffset())) { - // then no need to add the node to the list to be deleted - return; - } - - if (node.getStartOffset() < currentNode.getStartOffset() && node.getEndOffset() <= currentNode.getStartOffset()) { - nodes.add(i, node); - return; - } - } - // if we get here, then add it to the end - nodes.add(node); - } - - public void deleteNodes(Object requestor) { - for (int i = nodes.size() - 1; i >= 0; i--) { - DTDNode node = (DTDNode) nodes.get(i); - dtdFile.deleteNode(requestor, node); - } - nodes.clear(); - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDExternalReferenceRemover.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDExternalReferenceRemover.java deleted file mode 100644 index 7c1aba34d2..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDExternalReferenceRemover.java +++ /dev/null @@ -1,134 +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.dtd.core.internal.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.AttributeList; -import org.eclipse.wst.dtd.core.internal.CMBasicNode; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Element; -import org.eclipse.wst.dtd.core.internal.Entity; - - -/* - * This class is responsible for updating the model when items are deleted or - * so that items referenced by it are cleaned up note that top level nodes are - * queued up for deletion so that iteration over the list of nodes from the - * dtdfile is not messed up. Note that when an external parmeter entity - * changes, the client of the model (e.g. editor) must be a DTDFileListener - * implementing the listener's interface to keep the model's referential - * integrity (See DTDModelImpl for example). - */ - -public class DTDExternalReferenceRemover extends DTDVisitor { - - protected DTDBatchNodeDelete batchDelete; - protected List externalElementsAndParmEntities = new ArrayList(); - - protected boolean isParmEntity = false; - - protected boolean isUpdating = false; - protected DTDNode nodeToDelete; - protected String oldRefName = ""; //$NON-NLS-1$ - protected Object requestor; - - public DTDExternalReferenceRemover() { - - } - - public synchronized void externalReferenceAboutToChange(Object requestor, Entity entity) { - if (isUpdating) { - return; - } - if (!entity.isParameterEntity() || !entity.isExternalEntity()) { - // if it is not an external parameter entity, ignore as well - return; - } - - isUpdating = true; - this.requestor = requestor; - - DTDFile dtdFile = entity.getDTDFile(); - if (batchDelete == null) { - batchDelete = new DTDBatchNodeDelete(dtdFile); - } - - // See the comment at the head of this file regarding - // external parameter entities. - // externalElementsAndParmEntities = - // dtdFile.getDTDModel().getExternalModels().getElementContentNames(entity.getPublicID(), - // dtdFile.getDTDModel().resolveID(entity.getPublicID(), - // entity.getSystemID())); - - visit(dtdFile); - - batchDelete.deleteNodes(requestor); - - isUpdating = false; - } - - public boolean isMatchingName(String name) { - return externalElementsAndParmEntities.contains(name); - } - - public void visitAttribute(Attribute attr) { - super.visitAttribute(attr); - String attrName = attr.getName(); - String attrType = attr.getType(); - - if (isParameterEntityRef(attrName)) { - if (isMatchingName(attrName)) { - attr.setName(requestor, "TempName"); //$NON-NLS-1$ - } - } - if (isParameterEntityRef(attrType)) { - if (isMatchingName(attrType)) { - attr.setType(requestor, Attribute.CDATA); - } - } - } - - public void visitAttributeList(AttributeList attList) { - super.visitAttributeList(attList); - String attListName = attList.getName(); - if (isParameterEntityRef(attListName)) { - if (isMatchingName(attListName)) { - attList.setName(requestor, "TempName"); //$NON-NLS-1$ - } - } - } - - public void visitElement(Element element) { - String elementName = element.getName(); - if (isParameterEntityRef(elementName)) { - if (isMatchingName(elementName)) { - element.setName(requestor, "TempName"); //$NON-NLS-1$ - } - } - super.visitElement(element); - } - - public void visitReference(CMBasicNode node) { - super.visitReference(node); - String refName = node.getName(); - if (isMatchingName(refName)) { - batchDelete.addNode(node); - } - } - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDModelUpdater.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDModelUpdater.java deleted file mode 100644 index 21bf47691b..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDModelUpdater.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.dtd.core.internal.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.AttributeList; -import org.eclipse.wst.dtd.core.internal.CMBasicNode; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Element; -import org.eclipse.wst.dtd.core.internal.Entity; -import org.eclipse.wst.dtd.core.internal.ParameterEntityReference; - - -// this class is responsible for updating the model when items -// are deleted or a external parm entity changes so that -// items referenced by it are cleaned up -// note that top level nodes are queued up for deletion so that -// iteration over the list of nodes from the dtdfile is not messed up -public class DTDModelUpdater extends DTDVisitor { - - protected boolean isParmEntity = false; - - protected boolean isUpdating = false; - - protected List nodesToDelete = new ArrayList(); - protected DTDNode nodeToDelete; - protected String oldRefName = ""; //$NON-NLS-1$ - protected Object requestor; - - public DTDModelUpdater() { - - } - - public synchronized void objectAboutToBeDeleted(Object requestor, DTDNode node) { - if (isUpdating) { - return; - } - if (!(node instanceof Entity || node instanceof Element)) { - // just ignore if it is not one of these - return; - } - if (node instanceof Entity && !((Entity) node).isParameterEntity()) { - // if it is not a parameter entity, ignore as well - return; - } - - - isUpdating = true; - this.requestor = requestor; - this.nodeToDelete = node; - oldRefName = node.getName(); - isParmEntity = false; - nodesToDelete.clear(); - - if (node instanceof Entity) { - isParmEntity = true; - oldRefName = "%" + oldRefName + ";"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - DTDFile dtdFile = node.getDTDFile(); - visit(dtdFile); - - for (int i = 0; i < nodesToDelete.size(); i++) { - dtdFile.deleteNode(requestor, (DTDNode) nodesToDelete.get(i)); - } - - isUpdating = false; - } - - public void visitAttribute(Attribute attr) { - super.visitAttribute(attr); - if (isParmEntity) { - if (attr.getName().equals(oldRefName)) { - attr.setName(requestor, "TempName"); //$NON-NLS-1$ - } - if (attr.getType().equals(oldRefName)) { - attr.setType(requestor, Attribute.CDATA); - } - } - // check the attr name and the attr type to see if it - // needs updating - } - - public void visitAttributeList(AttributeList attList) { - super.visitAttributeList(attList); - if (attList.getName().equals(oldRefName)) { - if (isParmEntity) { - attList.setName(requestor, "TempName"); //$NON-NLS-1$ - } - else { - // save up for later deletion - nodesToDelete.add(attList); - } - } - } - - public void visitElement(Element element) { - if (isParmEntity) { - if (element.getName().equals(oldRefName)) { - element.setName(requestor, "TempName"); //$NON-NLS-1$ - } - } - super.visitElement(element); - } - - public void visitExternalParameterEntityReference(ParameterEntityReference parmEntityRef) { - super.visitExternalParameterEntityReference(parmEntityRef); - if (isParmEntity && parmEntityRef.getName().equals(oldRefName)) { - nodesToDelete.add(parmEntityRef); - } - } - - public void visitReference(CMBasicNode node) { - super.visitReference(node); - - if (node.getName().equals(oldRefName)) { - DTDNode parent = (DTDNode) node.getParentNode(); - parent.delete(requestor, node); - } - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDNotationReferenceRemover.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDNotationReferenceRemover.java deleted file mode 100644 index 35cbf8469f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDNotationReferenceRemover.java +++ /dev/null @@ -1,93 +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.dtd.core.internal.util; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.AttributeEnumList; -import org.eclipse.wst.dtd.core.internal.AttributeList; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Entity; -import org.eclipse.wst.dtd.core.internal.Notation; - - -public class DTDNotationReferenceRemover { - protected Notation notation; - protected String notationName; - - protected Object requestor; - - public DTDNotationReferenceRemover() { - - } - - public void notationAboutToBeDeleted(Object requestor, Notation notation) { - this.requestor = requestor; - this.notation = notation; - notationName = notation.getName(); - - visit(notation.getDTDFile()); - } - - public void visit(DTDFile file) { - List nodes = file.getNodes(); - for (int i = 0; i < nodes.size(); i++) { - DTDNode currentNode = (DTDNode) nodes.get(i); - if (currentNode instanceof Entity) { - visitEntity((Entity) currentNode); - } - else if (currentNode instanceof AttributeList) { - visitAttributeList((AttributeList) currentNode); - } - } - } - - public void visitAttribute(Attribute attr) { - if (attr.getType().equals(Attribute.ENUMERATED_NOTATION)) { - AttributeEnumList enumList = attr.getEnumList(); - List notationNames = enumList.getItems(); - Iterator iter = notationNames.iterator(); - boolean updateRequired = false; - while (iter.hasNext()) { - String notation = (String) iter.next(); - if (notation.equals(notationName)) { - updateRequired = true; - iter.remove(); - } - } - if (updateRequired) { - String[] newItems = new String[notationNames.size()]; - notationNames.toArray(newItems); - enumList.setItems(requestor, newItems); - } - } - } - - public void visitAttributeList(AttributeList attList) { - Attribute attr = (Attribute) attList.getFirstChild(); - while (attr != null) { - visitAttribute(attr); - attr = (Attribute) attr.getNextSibling(); - } - } - - public void visitEntity(Entity entity) { - if (entity.getNotationName().equals(notationName)) { - entity.setNotationName(requestor, ""); //$NON-NLS-1$ - } - } - -}// DTDNotationRemover diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDReferenceUpdater.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDReferenceUpdater.java deleted file mode 100644 index 26931d88db..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDReferenceUpdater.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.dtd.core.internal.util; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.AttributeEnumList; -import org.eclipse.wst.dtd.core.internal.AttributeList; -import org.eclipse.wst.dtd.core.internal.CMBasicNode; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Element; -import org.eclipse.wst.dtd.core.internal.Entity; -import org.eclipse.wst.dtd.core.internal.Notation; -import org.eclipse.wst.dtd.core.internal.ParameterEntityReference; - - -// this class is responsible for updating any dtd node in -// response to a change in the node that they reference -public class DTDReferenceUpdater extends DTDVisitor { - protected boolean isNotation = false; - - protected boolean isParmEntity = false; - - protected boolean isUpdating = false; - protected String newName = ""; //$NON-NLS-1$ - protected String oldRefName = "", newRefName = ""; //$NON-NLS-1$ //$NON-NLS-2$ - protected DTDNode referencedNode = null; - - // the references List is a cache of the DTDNodes that are changed - // as a result of a call to nameAboutToChange(). The idea is that - // if a subsequent call comes in that changes the name of the same - // object for which this cache exists for, then we optimize the - // path by just walking the cache - private List references = new ArrayList(); - protected Object requestor; - - public DTDReferenceUpdater() { - - } - - public void clearCache() { - referencedNode = null; - references.clear(); - } - - public synchronized void nameAboutToChange(Object requestor, DTDNode referencedNode, String newName) { - if (isUpdating) { - return; - } - if (!(referencedNode instanceof Entity || referencedNode instanceof Element || referencedNode instanceof Notation)) { - // just ignore if it is not one of these - return; - } - if (referencedNode instanceof Entity && !((Entity) referencedNode).isParameterEntity()) { - // if it is not a parameter entity, ignore as well - return; - } - - isUpdating = true; - this.requestor = requestor; - oldRefName = referencedNode.getName(); - this.newName = newRefName = newName; - isParmEntity = false; - isNotation = referencedNode instanceof Notation; - - if (referencedNode instanceof Entity) { - isParmEntity = true; - oldRefName = "%" + oldRefName + ";"; //$NON-NLS-1$ //$NON-NLS-2$ - newRefName = "%" + newRefName + ";"; //$NON-NLS-1$ //$NON-NLS-2$ - } - - if (this.referencedNode != null) { - // check if the previous referenced node that was changed - // is the same as the one that is coming in. if so, just - // change the previous regions - if (this.referencedNode == referencedNode) { - quickUpdate(); - isUpdating = false; - return; - } - } - - // clear the cache if we get here - this.referencedNode = referencedNode; - references.clear(); - DTDFile dtdFile = referencedNode.getDTDFile(); - visit(dtdFile); - isUpdating = false; - } - - protected void quickUpdate() { - for (int i = 0; i < references.size(); i++) { - DTDNode node = (DTDNode) references.get(i); - if (node instanceof Element) { - visitElement((Element) node); - } - else if (node instanceof AttributeList) { - visitAttributeList((AttributeList) node); - } - else if (node instanceof Attribute) { - visitAttribute((Attribute) node); - } - else if (node instanceof CMBasicNode) { - visitReference((CMBasicNode) node); - } - else if (node instanceof ParameterEntityReference) { - visitExternalParameterEntityReference((ParameterEntityReference) node); - } - } - } - - public void visitAttribute(Attribute attr) { - super.visitAttribute(attr); - if (isParmEntity) { - // check the attr name and the attr type to see if it - // needs updating - if (attr.getName().equals(oldRefName)) { - attr.setName(requestor, newRefName); - references.add(attr); - } - if (attr.getType().equals(oldRefName)) { - attr.setType(requestor, newRefName); - references.add(attr); - } - } - else if (isNotation && attr.getType().equals(Attribute.ENUMERATED_NOTATION)) { - AttributeEnumList enumList = attr.getEnumList(); - List items = enumList.getItems(); - boolean updateNeeded = false; - for (int i = 0; i < items.size(); i++) { - String notationName = (String) items.get(i); - if (notationName.equals(oldRefName)) { - updateNeeded = true; - items.set(i, newName); - } - } - if (updateNeeded) { - String[] newItems = new String[items.size()]; - - enumList.setItems((String[]) items.toArray(newItems)); - } - } - - } - - public void visitAttributeList(AttributeList attList) { - if (!isNotation && attList.getName().equals(oldRefName)) { - attList.setName(requestor, newRefName); - references.add(attList); - } - super.visitAttributeList(attList); - } - - public void visitElement(Element element) { - if (isParmEntity) { - if (element.getName().equals(oldRefName)) { - element.setName(requestor, newRefName); - references.add(element); - } - } - super.visitElement(element); - } - - public void visitExternalParameterEntityReference(ParameterEntityReference parmEntityRef) { - super.visitExternalParameterEntityReference(parmEntityRef); - if (parmEntityRef.getName().equals(oldRefName)) { - parmEntityRef.setReferencedEntity(requestor, newName); - references.add(parmEntityRef); - } - } - - public void visitReference(CMBasicNode node) { - super.visitReference(node); - if (isParameterEntityRef(oldRefName) && !isParmEntity) { - return; - } - - if (node.getName().equals(oldRefName)) { - node.setName(requestor, newRefName); - references.add(node); - } - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDUniqueNameHelper.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDUniqueNameHelper.java deleted file mode 100644 index 9c339d8b50..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDUniqueNameHelper.java +++ /dev/null @@ -1,95 +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.dtd.core.internal.util; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.CMBasicNode; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.Element; -import org.eclipse.wst.dtd.core.internal.Entity; -import org.eclipse.wst.dtd.core.internal.Notation; - - -public class DTDUniqueNameHelper { - - static public String getName(Object obj) { - if (obj instanceof Element) { - return ((Element) obj).getName(); - } - else if (obj instanceof Entity) { - return ((Entity) obj).getName(); - } - else if (obj instanceof Notation) { - return ((Notation) obj).getName(); - } - else if (obj instanceof Attribute) { - return ((Attribute) obj).getName(); - } - else if (obj instanceof CMBasicNode) // Model Group Content - { - return ((CMBasicNode) obj).getName(); - } - return ""; //$NON-NLS-1$ - } - - static public String getUniqueAttributeName(Element element) { - List attrs = element.getElementAttributes(); - return getUniqueName(attrs, "NewAttribute"); //$NON-NLS-1$ - } - - static public String getUniqueElementName(DTDFile dtdFile) { - List elements = dtdFile.getElementsAndParameterEntityReferences().getNodes(); - return getUniqueName(elements, "NewElement"); //$NON-NLS-1$ - } - - static public String getUniqueEntityName(DTDFile dtdFile) { - List entities = dtdFile.getEntities().getNodes(); - return getUniqueName(entities, "NewEntity"); //$NON-NLS-1$ - } - - static public String getUniqueName(List objs, String token) { - int counter = 1; - - boolean uniqueName = false; - while (!uniqueName) { - String newName = token + new Integer(counter++); - uniqueName = true; - Iterator iter = objs.iterator(); - while (iter.hasNext()) { - Object obj = iter.next(); - String objName = getName(obj); - if (objName.equals(newName)) { - uniqueName = false; - break; - } - } - if (uniqueName) { - return newName; - } - } - // we shouldn't get here - return "No Name found"; //$NON-NLS-1$ - } - - static public String getUniqueNotationName(DTDFile dtdFile) { - List notations = dtdFile.getNotations().getNodes(); - return getUniqueName(notations, "NewNotation"); //$NON-NLS-1$ - } - - public DTDUniqueNameHelper() { - } - -} // DTDUniqueNameHelper diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDVisitor.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDVisitor.java deleted file mode 100644 index d3e6d01c28..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/DTDVisitor.java +++ /dev/null @@ -1,108 +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.dtd.core.internal.util; - -import java.util.List; - -import org.eclipse.wst.dtd.core.internal.Attribute; -import org.eclipse.wst.dtd.core.internal.AttributeList; -import org.eclipse.wst.dtd.core.internal.CMBasicNode; -import org.eclipse.wst.dtd.core.internal.CMGroupNode; -import org.eclipse.wst.dtd.core.internal.CMNode; -import org.eclipse.wst.dtd.core.internal.DTDFile; -import org.eclipse.wst.dtd.core.internal.DTDNode; -import org.eclipse.wst.dtd.core.internal.Element; -import org.eclipse.wst.dtd.core.internal.ParameterEntityReference; - - -public class DTDVisitor { - - public DTDVisitor() { - - } - - // utility method - public boolean isParameterEntityRef(String reference) { - if (reference.length() > 0) { - return reference.charAt(0) == '%' && reference.charAt(reference.length() - 1) == ';'; - } - return false; - } - - public void visit(DTDFile file) { - List nodes = file.getNodes(); - for (int i = 0; i < nodes.size(); i++) { - DTDNode currentNode = (DTDNode) nodes.get(i); - if (currentNode instanceof Element) { - visitElement((Element) currentNode); - } - else if (currentNode instanceof AttributeList) { - visitAttributeList((AttributeList) currentNode); - } - else if (currentNode instanceof ParameterEntityReference) { - visitExternalParameterEntityReference((ParameterEntityReference) currentNode); - } - } - } - - public void visitAttribute(Attribute attr) { - } - - public void visitAttributeList(AttributeList attList) { - // note that we don't visit attributes here because we - // want the element to visit them with it's consolidated list - // that it creates by gathering all attribute lists together - } - - public void visitAttributes(List attributes) { - int size = attributes.size(); - for (int i = 0; i < size; i++) { - Attribute attr = (Attribute) attributes.get(i); - visitAttribute(attr); - } - } - - public void visitContentNode(CMNode content) { - if (content instanceof CMBasicNode) { - CMBasicNode basicNode = (CMBasicNode) content; - if (basicNode.isReference()) { - visitReference(basicNode); - } - } - else if (content instanceof CMGroupNode) { - visitGroupNode((CMGroupNode) content); - } - } - - public void visitElement(Element element) { - CMNode content = element.getContentModel(); - visitContentNode(content); - visitAttributes(element.getElementAttributes()); - } - - public void visitExternalParameterEntityReference(ParameterEntityReference parmEntityRef) { - } - - public void visitGroupNode(CMGroupNode group) { - List children = group.getChildrenList(); - int size = children.size(); - for (int i = 0; i < size; i++) { - visitContentNode((CMNode) children.get(i)); - } - } - - public void visitReference(CMBasicNode node) { - } - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/LabelValuePair.java b/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/LabelValuePair.java deleted file mode 100644 index f51d8728ca..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/src/org/eclipse/wst/dtd/core/internal/util/LabelValuePair.java +++ /dev/null @@ -1,30 +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.dtd.core.internal.util; - -import org.eclipse.jface.util.Assert; - -public class LabelValuePair { - - public String fLabel; - public Object fValue; - - /** - * Creates a new name/value item - */ - public LabelValuePair(String label, Object value) { - Assert.isTrue(label != null); - fLabel = label; - fValue = value; - } -} |