diff options
Diffstat (limited to 'bundles/org.eclipse.wst.dtd.core/saxparser')
23 files changed, 0 insertions, 4628 deletions
diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/AttNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/AttNode.java deleted file mode 100644 index a86ddfbf18..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/AttNode.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; -import java.util.Vector; - -public final class AttNode { - // - // attType - // - public static final int CDATA = 0, ID = 1, IDREF = 2, IDREFS = 3, ENTITY = 4, ENTITIES = 5, NMTOKEN = 6, NMTOKENS = 7, NOTATION = 8, ENUMERATION = 9, PEREFERENCE = 10; - - // - // Keep this array in-sync with the ATTTYPE definitions - // - private static final String[] fgAttTypeString = {"CDATA", // 0 //$NON-NLS-1$ - "ID", // 1 //$NON-NLS-1$ - "IDREF", // 2 //$NON-NLS-1$ - "IDREFS", // 3 //$NON-NLS-1$ - "ENTITY", // 4 //$NON-NLS-1$ - "ENTITIES", // 5 //$NON-NLS-1$ - "NMTOKEN", // 6 //$NON-NLS-1$ - "NMTOKENS", // 7 //$NON-NLS-1$ - "NOTATION", // 8 //$NON-NLS-1$ - "ENUMERATION", // 9 (replaced with "NMTOKEN" by SAX //$NON-NLS-1$ - // AttributeList handler) - "%ENTITYREFERENCE;"}; //$NON-NLS-1$ - - // - // attDefaultType - // - public static final int NOFIXED = 1, // AttValue - REQUIRED = 2, // #REQUIRED - IMPLIED = 3, // #IMPLIED - FIXED = 4; // #FIXED AttValue - - public String name = null; - public String type = null; - public String defaultType = null; - public String defaultValue = null; - public Vector enumList = null; // list of Notations or Enum values - - public int getDeclaredType() { - int t = -1; - if (type == null) - return t; - - if (type.startsWith("%") && type.endsWith(";")) //$NON-NLS-1$ //$NON-NLS-2$ - return PEREFERENCE; - - for (int i = 0; i < fgAttTypeString.length; i++) { - if (type.equals(fgAttTypeString[i])) { - t = i; - break; - } - } - return t; - } - - public Enumeration elements() { - if (enumList == null) - enumList = new Vector(); - return enumList.elements(); - } - - public int getDefaultType() { - if (defaultType == null) - return -1; - - if (defaultType.startsWith("%") && defaultType.endsWith(";")) //$NON-NLS-1$ //$NON-NLS-2$ - return PEREFERENCE; - else if (defaultType.equals("#REQUIRED")) //$NON-NLS-1$ - return REQUIRED; - else if (defaultType.equals("#IMPLIED")) //$NON-NLS-1$ - return IMPLIED; - else if (defaultType.equals("#FIXED")) //$NON-NLS-1$ - return FIXED; - else - return NOFIXED; - } - - public String toString() { - return "Att Name: " + name + " Type: " + type + " defaultType: " + defaultType + " defaultValue: " + defaultValue; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/Attlist.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/Attlist.java deleted file mode 100644 index e42e42121e..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/Attlist.java +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; -import java.util.Vector; - -public class Attlist extends BaseNode { - Vector attDefs = new Vector(); - - /** - * Constructor. - * - * @param name - * This attribute list's name; this value is also known as the - * Element type. - */ - public Attlist(String name, String ownerDTD) { - this(name, ownerDTD, null, null); - } - - public Attlist(String name, String ownerDTD, String comment, ErrorMessage errorMessage) { - super(name, ownerDTD, comment, errorMessage); - } - - - /** - * Adds the specified attribute definition to the end of this attribute - * list . - * - * @param attDef - * Attribute definition to add to this atribute list. - * @return =true if the attribute definition does not already exist in - * this attribute list; otherwise, =false. - * @see #elementAt - * @see #getAttDef - * @see #contains - * @see #size - */ - public boolean addElement(AttNode attDef) { - if (contains(attDef.name)) - return false; - this.attDefs.addElement(attDef); - return true; - } - - /** - * Returns the attribute definition at the specified <var>index</var> in - * this attribute list - * - * @param index - * Index into this list of attribute definitions. - * @return Attribute definition at the specified index, or <var>null</var> - * if an invalid index. - * @see #addElement - * @see #getAttDef - * @see #contains - * @see #size - */ - public AttNode elementAt(int index) { - return (AttNode) this.attDefs.elementAt(index); - } - - /** - * Returns the attribute definition that matches the specified attribute - * definition name in this attribute list. - * - * @param attDefName - * Attribute definition name to match in this attribute list. - * @return The matching attribute definition, or <var>null</var> if the - * attribute is not currently defined. - * @see #addElement - * @see #elementAt - * @see #contains - * @see #size - * @see #elements - */ - public AttNode getAttDef(String attDefName) { - for (int i = 0; i < size(); i++) { - AttNode ad = elementAt(i); - if (attDefName.equals(ad.name)) - return ad; - } - return null; - } - - /** - * Returns whether the specified attribute definition name is currently - * defined in this attribute list. - * - * @param attDefName - * Attribute definition name to match in this attribute list. - * @return =true if <var>attDefName</var> is defined; otherwise, =false. - * @see #addElement - * @see #elementAt - * @see #getAttDef - * @see #size - * @see #elements - */ - public boolean contains(String attDefName) { - return null != getAttDef(attDefName); - } - - /** - * Returns the number of attribute definitions in this attribute list. - * - * @return Number of attribute list definitions, or <var>null</var> if no - * definitions defined. - * @see #addElement - * @see #elementAt - * @see #getAttDef - * @see #contains - */ - public int size() { - return this.attDefs.size(); - } - - /** - * Returns an enumeration of all attribute definitions in this attribute - * list. - * - * @return An enumeration of all attribute definitions, or <var>null</var> - * if none specified. - * @see #addElement - * @see #elementAt - * @see #getAttDef - * @see #contains - * @see #size - */ - public Enumeration elements() { - return this.attDefs.elements(); - } - - void setAttDefs(Vector attrs) { - attDefs = attrs; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/BaseNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/BaseNode.java deleted file mode 100644 index e944b30797..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/BaseNode.java +++ /dev/null @@ -1,66 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - - -public abstract class BaseNode { - protected String name = null; - protected ErrorMessage errorMessage = null; - // protected String errorMessage = null; - protected String comment = null; - protected String ownerDTD = null; - - /** Default constructor. */ - public BaseNode(String name, String ownerDTD) { - this(name, ownerDTD, null, null); - } - - public BaseNode(String name, String ownerDTD, String comment, ErrorMessage errorMessage) { - this.name = name; - this.ownerDTD = ownerDTD; - this.comment = comment; - this.errorMessage = errorMessage; - } - - public String getNodeName() { - return name; - } - - public void setNodeName(String name) { - this.name = name; - } - - public String getOwnerDTD() { - return ownerDTD; - } - - public void setOwnerDTD(String owner) { - ownerDTD = owner; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public ErrorMessage getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(ErrorMessage message) { - errorMessage = message; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMBasicNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMBasicNode.java deleted file mode 100644 index d470ffbcab..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMBasicNode.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class CMBasicNode extends CMNode { - private int type = CMNodeType.EMPTY; // possible types : - - // CMNodeType.EMPTY - // CMNodeType.ANY - // CMNodeType.PCDATA - - /** Default constructor. */ - public CMBasicNode(String refName) { - super(refName); - } - - public CMBasicNode(String refName, int type) { - super(refName); - this.type = type; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String toString() { - return " BasicNodeName: " + getName() + " Type: " + getType() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMGroupNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMGroupNode.java deleted file mode 100644 index 823b2cf044..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMGroupNode.java +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; -import java.util.Vector; - -public class CMGroupNode extends CMRepeatableNode { - private int type = CMNodeType.GROUP; - private int groupKind = CMNodeType.GROUP_SEQUENCE; - private Vector children = new Vector(); - - public CMGroupNode() { - super("GROUP"); //$NON-NLS-1$ - } - - public int getType() { - return type; - } - - // implement super class - public void setType(int type) { - // can't change - only one type allows - } - - public int getGroupKind() { - return groupKind; - } - - public void setGroupKind(int kind) { - groupKind = kind; - } - - public Vector getChildren() { - return children; - } - - public void addChild(CMNode child) { - children.addElement(child); - } - - public String toString() { - String result = "Group ( - kind: " + getGroupKind() + " OccType: " + getOccurrence() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - Enumeration en = children.elements(); - while (en.hasMoreElements()) { - result += " " + en.nextElement(); //$NON-NLS-1$ - } - - result += "Group )"; //$NON-NLS-1$ - return result; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNode.java deleted file mode 100644 index 1682a27baf..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNode.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public abstract class CMNode { - private String refName; - - /** Default constructor. */ - public CMNode(String refName) { - this.refName = refName; - } - - public String getName() { - return refName; - } - - public abstract int getType(); - - public abstract void setType(int type); - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNodeType.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNodeType.java deleted file mode 100644 index 4e85db9a16..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMNodeType.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public interface CMNodeType { - static public int EMPTY = 1; - static public int ANY = 2; - static public int PCDATA = 3; - static public int ELEMENT_REFERENCE = 4; - static public int ENTITY_REFERENCE = 5; - static public int GROUP = 6; - - static public int ONE = 7; - static public int OPTIONAL = 8; - static public int ONE_OR_MORE = 9; - static public int ZERO_OR_MORE = 10; - - static public int GROUP_CHOICE = 11; - static public int GROUP_SEQUENCE = 12; - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMReferenceNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMReferenceNode.java deleted file mode 100644 index ab59b4cd84..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMReferenceNode.java +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class CMReferenceNode extends CMRepeatableNode { - private int type = CMNodeType.ELEMENT_REFERENCE; - - public CMReferenceNode(String refName) { - this(refName, CMNodeType.ELEMENT_REFERENCE); - } - - public CMReferenceNode(String refName, int type) { - super(refName); - this.type = type; - } - - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String toString() { - return " RefName: " + getName() + " Type: " + getType() + " OccType: " + getOccurrence() + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMRepeatableNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMRepeatableNode.java deleted file mode 100644 index cf6e112e78..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/CMRepeatableNode.java +++ /dev/null @@ -1,34 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public abstract class CMRepeatableNode extends CMNode { - private int occType = CMNodeType.ONE; - - public CMRepeatableNode(String refName) { - super(refName); - } - - public CMRepeatableNode(String refName, int occType) { - super(refName); - this.occType = occType; - } - - public int getOccurrence() { - return occType; - } - - public void setOccurrence(int occType) { - this.occType = occType; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTD.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTD.java deleted file mode 100644 index d86f9b1647..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTD.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; -import java.util.Vector; - -public class DTD { - // - // Constants - // - - Vector externalElements = new Vector(); - String name = null; - - boolean isExceptionDuringParse = false; - - // - // Constructors - // - - /** - * Constructor. - */ - - /** - * Constructor. - * - * @param name - * The file name of this DTD. - * @see #getName - * @see #setName - */ - public DTD(String name) { - this.name = name; - } - - /** - * Returns this DTD's file name. - * - * @return This DTD's file name, or <var>null</var> if no name. - */ - public String getName() { - return this.name; - } - - /** - * Sets this DTD's file name. - * - * @param name - * This DTD's name. - * @see #getName - */ - public void setName(String name) { - this.name = name; - } - - /** - * Returns an Enumeration instance of all external subset children of this - * DTD. - * - * @return An enumeration of all external subset children of this DTD. - */ - public Enumeration externalElements() { - return externalElements.elements(); - } - - public void addDecl(BaseNode decl) { - externalElements.addElement(decl); - } - - public void setIsExceptionDuringParse(boolean on) { - isExceptionDuringParse = on; - } - - public boolean getIsExceptionDuringParse() { - return isExceptionDuringParse; - } - -} // class DTD diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java deleted file mode 100644 index d9bc4390de..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDParser.java +++ /dev/null @@ -1,764 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.io.StringReader; -import java.io.UnsupportedEncodingException; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.List; -import java.util.Stack; -import java.util.Vector; - -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; - -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver; -import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xml.core.internal.validation.core.LazyURLInputStream; -import org.xml.sax.ContentHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.Locator; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; -import org.xml.sax.XMLReader; -import org.xml.sax.ext.DeclHandler; -import org.xml.sax.ext.LexicalHandler; -import org.xml.sax.helpers.DefaultHandler; - -public class DTDParser extends DefaultHandler implements ContentHandler, DTDHandler, ErrorHandler, DeclHandler, LexicalHandler { - private String contentString = ""; //$NON-NLS-1$ - private String declString = ""; //$NON-NLS-1$ - - /* Canonical output. */ - protected boolean canonical; - - protected XMLReader reader; - int entityDepth; - - // dmw 11/15 private field never read locally - // private Vector declElements; - private String comment = null; - private ErrorMessage errorMessage = null; - private List errorMessages = new ArrayList(); - private DeclNode previousDeclNode = null; - private DeclNode currentDeclNode = null; - private BaseNode lastBaseNode = null; - - private boolean entityEnd = false; - private int lineNumber; - - private DTD currentDTD = null; - private Vector dtdList = new Vector(); - - private Stack dtdStack = new Stack(); - private Stack peRefStack = new Stack(); - private Stack parsingPERefStack = new Stack(); - - private EntityPool entityPool = new EntityPool(); - private String expandedEntityValue = null; - private Hashtable elementPool = new Hashtable(); - - boolean parsingExternalPEReference = false; - protected boolean expandEntityReferences = true; - - private Locator locator = null; - - private Locator getLocator() { - return locator; - } - - public void setDocumentLocator(Locator locator) { - this.locator = locator; - } - - public DTDParser(boolean canonical) throws UnsupportedEncodingException { - this(null, canonical); - } - - protected DTDParser(String encoding, boolean canonical) throws UnsupportedEncodingException { - - if (encoding == null) - encoding = "UTF-8"; //$NON-NLS-1$ - - this.canonical = canonical; - try { - SAXParser sparser = SAXParserFactory.newInstance().newSAXParser(); - reader = sparser.getXMLReader(); - reader.setProperty("http://xml.org/sax/properties/declaration-handler", this); //$NON-NLS-1$ - reader.setProperty("http://xml.org/sax/properties/lexical-handler", this); //$NON-NLS-1$ - reader.setContentHandler(this); - reader.setDTDHandler(this); - reader.setErrorHandler(this); - reader.setEntityResolver(this); - } - catch (Exception e) { - e.printStackTrace(); - } - - } - - /* Prints the output from the SAX callbacks. */ - public void parse(String logicalURI) { - try { - // CS ensure that the physical URI is considered where streams are required - // and the logicalURI is used as the DTD's baseLocation - String physicalURI = URIResolverPlugin.createResolver().resolvePhysicalLocation("", "", logicalURI); - boolean isReadable = URIHelper.isReadableURI(physicalURI, true); - if (!isReadable) { - throw new Exception("DTD parse error. Can not read the specified URI : " + logicalURI); //$NON-NLS-1$ - } - String document = "<!DOCTYPE root SYSTEM \"" + logicalURI + "\"><root/>"; //$NON-NLS-1$ //$NON-NLS-2$ - entityDepth = 0; - currentDTD = new DTD(logicalURI); - InputSource inputSource = new InputSource(new StringReader(document)); - inputSource.setSystemId(logicalURI + ".xml"); //$NON-NLS-1$ - reader.parse(inputSource); - } - catch (SAXParseException se) { - if (currentDTD != null) - currentDTD.setIsExceptionDuringParse(true); - } - catch (Exception e) { - if (currentDTD != null) - currentDTD.setIsExceptionDuringParse(true); - } - - } - - /* - * @deprecated Entity references are always expanded. - */ - public void setExpandEntityReferences(boolean expandEntityReferences) { - this.expandEntityReferences = true; - } - - /* - * @deprecated Entity references are always expanded. - */ - public boolean getExpandEntityReferences() { - return expandEntityReferences; - } - - public Vector getDTDList() { - return dtdList; - } - - public Hashtable getElementPool() { - return elementPool; - } - - public EntityPool getEntityPool() { - return entityPool; - } - - public List getErrorMessages() { - return errorMessages; - } - - // - // DocumentHandler methods - // - - public void startDocument() { - } - - public void endDocument() { - } - - public void processingInstruction(String target, String data) { - } - - // - // DTDHandler methods - // - - public void unparsedEntityDecl(String name, String publicId, String systemId, String notationName) throws SAXException { - } - - public void notationDecl(String name, String publicId, String systemId) throws SAXException { - startDeclaration(DeclNode.NOTATION); - declString = "<!NOTATION"; //$NON-NLS-1$ - if (entityDepth == 1 || parsingExternalPEReference) { - String xs = " "; //$NON-NLS-1$ - xs += name; - if (publicId == null) - xs += " SYSTEM " + "\"" + systemId + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - else - xs += " PUBLIC " + "\"" + publicId + "\" " + "\"" + systemId + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ - contentString += xs; - parseCurrentDeclaration(); - } - } - - // - // DeclHandler methods - // - - public void elementDecl(String name, String model) throws SAXException { - startDeclaration(DeclNode.ELEMENT); - declString = "<!ELEMENT"; //$NON-NLS-1$ - - // KB: With early versions of Xerces 2.x, startEntity("[dtd]") used to - // be called before this method - // so entityDepth was 1. Using JAXP changed that and startEntity() is - // not called back anymore. - // Because of this, we need to handle the case where entityDepth == 0 - // as well. - if (entityDepth == 0 || entityDepth == 1 || parsingExternalPEReference) - parseCurrentDeclarationHelper(name + " " + model); //$NON-NLS-1$ - } - - protected String attributeString = ""; //$NON-NLS-1$ - - public void attributeDecl(String eName, String aName, String type, String valueDefault, String value) throws SAXException { - startDeclaration(DeclNode.ATTLIST); - declString = "<!ATTLIST"; //$NON-NLS-1$ - - attributeString += " " + aName; //$NON-NLS-1$ - if (type != null) - attributeString += " " + type; //$NON-NLS-1$ - if (valueDefault != null) - attributeString += " " + valueDefault; //$NON-NLS-1$ - if (value != null) - attributeString += " '" + value + "'"; //$NON-NLS-1$ //$NON-NLS-2$ - - attributeString = eName + " " + attributeString + ">"; //$NON-NLS-1$ //$NON-NLS-2$ - parseCurrentDeclarationHelper(attributeString); - attributeString = ""; //$NON-NLS-1$ - } - - public void internalEntityDecl(String name, String value) throws SAXException { - startDeclaration(DeclNode.INTERNAL_ENTITY); - declString = "<!ENTITY"; //$NON-NLS-1$ - - if (entityDepth == 1 || parsingExternalPEReference) { - // build up a string: e.g. " % STRDOM "(#PCDATA)">" - String xs = " "; //$NON-NLS-1$ - if (name.startsWith("%")) { //$NON-NLS-1$ - xs += "% "; //$NON-NLS-1$ - xs += name.substring(1); - } - else - xs += name; - - xs += " \"" + value + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ - - contentString += xs; - // save expanded entity value - expandedEntityValue = value; - parseCurrentDeclaration(); - - } - } - - public void externalEntityDecl(String name, String publicId, String systemId) throws SAXException { - startDeclaration(DeclNode.EXTERNAL_ENTITY); - declString = "<!ENTITY"; //$NON-NLS-1$ - - if (entityDepth == 1 || parsingExternalPEReference) { - // build up a string: - // ex1) " % FIELD SYSTEM "oagis_fields.dtd">" - // ex2) " % FIELD PUBLIC "FOO">" - String xs = " "; //$NON-NLS-1$ - if (name.startsWith("%")) { //$NON-NLS-1$ - xs += "% "; //$NON-NLS-1$ - xs += name.substring(1); - } - else - xs += name; - - if (systemId != null) - xs += " SYSTEM \"" + systemId + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ - else if (publicId != null) - xs += " PUBLIC \"" + publicId + "\">"; //$NON-NLS-1$ //$NON-NLS-2$ - - contentString += xs; - parseCurrentDeclaration(); - } - } - - // - // LexicalHandler methods - // - - public void startCDATA() throws SAXException { - } - - public void endCDATA() throws SAXException { - } - - public void startDTD(String name, String publicId, String systemId) throws SAXException { - dtdList.removeAllElements(); - dtdList.addElement(currentDTD); - } - - /** - * Report the end of DTD declarations. - * - * @exception SAXException - * The application may raise an exception. - * @see #startDTD - */ - public void endDTD() throws SAXException { - startDeclaration(DeclNode.END_DTD); - } - - /** - * Report the beginning of an entity. - * - * The start and end of the document entity are not reported. The start - * and end of the external DTD subset are reported using the pseudo-name - * "[dtd]". All other events must be properly nested within start/end - * entity events. - * - * @param name - * The name of the entity. If it is a parameter entity, the - * name will begin with '%'. - * @exception SAXException - * The application may raise an exception. - * @see #endEntity - */ - - public void startEntity(String name) throws SAXException { - if (name.equals("[dtd]")) { //$NON-NLS-1$ - startDeclaration(DeclNode.START_ENTITY_DTD); - } - else if (currentDeclNode == null) { - // PE reference in markupdecl section - if (name.startsWith("%")) { //$NON-NLS-1$ - String peName = name.substring(1); - EntityDecl en = entityPool.referPara(peName); - - peRefStack.push(name); - parsingPERefStack.push(new Boolean(parsingExternalPEReference)); - - String systemId = en.getSystemId(); - String publicId = en.getPublicId(); - if (systemId == null) { - parsingExternalPEReference = false; - } - else { - URIResolver idResolver = URIResolverPlugin.createResolver(); - String uri = idResolver.resolve(currentDTD.getName(), publicId, systemId); - if (!isDTDLoaded(uri)) { - // not loaded - // out.println(" DTD not loaded .. create new DTD: " - // ); - dtdStack.push(currentDTD); - DTD newDTD = new DTD(uri); - dtdList.addElement(newDTD); - currentDTD = newDTD; - parsingExternalPEReference = true; - } - else { - // out.println(" DTD already loaded .. " ); - parsingExternalPEReference = false; - } - } - } - } - else if (entityDepth == 1 || parsingExternalPEReference) { - String xs = (String) reader.getProperty("http://xml.org/sax/properties/xml-string"); //$NON-NLS-1$ - contentString += xs; - } - entityDepth++; - } - - /** - * Report the end of an entity. - * - * @param name - * The name of the entity that is ending. - * @exception SAXException - * The application may raise an exception. - * @see #startEntity - */ - public void endEntity(String name) throws SAXException { - if (name.equals("[dtd]")) { //$NON-NLS-1$ - startDeclaration(DeclNode.END_ENTITY_DTD); - } - else if (!peRefStack.empty()) { - parseExternalPEReference(name); - } - else if (entityDepth == 1 || parsingExternalPEReference) { - if (!contentString.endsWith(name + ";")) { //$NON-NLS-1$ - String xs = (String) reader.getProperty("http://xml.org/sax/properties/xml-string"); //$NON-NLS-1$ - contentString += xs; - } - } - entityDepth--; - entityEnd = true; - } - - protected boolean parseExternalPEReference(String name) { - if (!peRefStack.empty()) { - if (((String) peRefStack.peek()).equals(name)) { - peRefStack.pop(); - if (parsingExternalPEReference) { - currentDTD = (DTD) dtdStack.pop(); - addPEReferenceNode(name); - } - parsingExternalPEReference = ((Boolean) parsingPERefStack.pop()).booleanValue(); - return true; - } - } - return false; - } - - /** - * Report an XML comment anywhere in the document. - * - * This callback will be used for comments inside or outside the document - * element, including comments in the external DTD subset (if read). - * - * @param ch - * An array holding the characters in the comment. - * @param start - * The starting position in the array. - * @param length - * The number of characters to use from the array. - * @exception SAXException - * The application may raise an exception. - */ - public void comment(char ch[], int start, int length) throws SAXException { - startDeclaration(DeclNode.COMMENT); - - if (comment == null) - comment = new String(ch, start, length); - else - comment += "\n" + new String(ch); // append all comments. //$NON-NLS-1$ - // The comment will get reset after - // it has been attached to the following - // declaration. - } - - // - // ErrorHandler methods - // - - /* Warning. */ - public void warning(SAXParseException ex) { - String error = "[Source Line] " + declString + contentString + "\n"; //$NON-NLS-1$//$NON-NLS-2$ - error += "[Warning ] " + getLocationString(ex) + ": " + ex.getMessage(); //$NON-NLS-1$//$NON-NLS-2$ - setErrorInformation(ex, "warning"); //$NON-NLS-1$ - - parseCurrentDeclaration(); - } - - /* Error. */ - public void error(SAXParseException ex) { - String error = "[Source Line] " + declString + contentString + "\n"; //$NON-NLS-1$//$NON-NLS-2$ - error += "[Error ] " + getLocationString(ex) + ": " + ex.getMessage(); //$NON-NLS-1$//$NON-NLS-2$ - setErrorInformation(ex, "error"); //$NON-NLS-1$ - - parseCurrentDeclaration(); - } - - /* Fatal error. */ - public void fatalError(SAXParseException ex) throws SAXException { - String error = "[Source Line] " + declString + contentString + "\n"; //$NON-NLS-1$//$NON-NLS-2$ - error += "[Fatal Error] " + getLocationString(ex) + ": " + ex.getMessage(); //$NON-NLS-1$//$NON-NLS-2$ - setErrorInformation(ex, "fatal"); //$NON-NLS-1$ - - parseCurrentDeclaration(); - } - - /* Returns a string of the location. */ - private String getLocationString(SAXParseException ex) { - StringBuffer str = new StringBuffer(); - - String systemId = ex.getSystemId(); - if (systemId != null) { - int index = systemId.lastIndexOf('/'); - if (index != -1) - systemId = systemId.substring(index + 1); - str.append(systemId); - } - str.append(':'); - str.append(ex.getLineNumber()); - str.append(':'); - str.append(ex.getColumnNumber()); - - return str.toString(); - - } - - private void startDeclaration(int type) { - if (type == DeclNode.END_DTD || type == DeclNode.END_ENTITY_DTD || type == DeclNode.COMMENT || type == DeclNode.ERROR) { - previousDeclNode = currentDeclNode; - currentDeclNode = null; - } - else { - currentDeclNode = new DeclNode(type); - contentString = ""; //$NON-NLS-1$ - declString = ""; //$NON-NLS-1$ - expandedEntityValue = null; - } - } - - private void parseCurrentDeclaration() { - parseCurrentDeclarationHelper(contentString); - contentString = ""; //$NON-NLS-1$ - } - - private void parseCurrentDeclarationHelper(String declarationString) { - DTDScanner scanner; - String name; - - if (currentDeclNode == null && previousDeclNode != null && entityEnd) { - currentDeclNode = previousDeclNode; - } - - // save the previous declNode - if (currentDeclNode != null) { - BaseNode baseNode = null; - // strip out the ending markup symbol ">" - if (declarationString.endsWith(">")) //$NON-NLS-1$ - declarationString = declarationString.substring(0, declarationString.length() - 1); - - int sIndex; - String cString; - int type = currentDeclNode.getType(); - switch (type) { - case DeclNode.ELEMENT : { - name = TString.word(declarationString, 1); - - // strip out the name - sIndex = declarationString.indexOf(name) + name.length(); - cString = declarationString.substring(sIndex); - - baseNode = new ElementDecl(name, currentDTD.getName()); - scanner = new DTDScanner(currentDTD.getName(), cString); - CMNode contentModel = scanner.scanContentModel(); - if (contentModel == null && errorMessage == null) { - createErrorMessage("Expecting '(' in content model", "error"); //$NON-NLS-1$ //$NON-NLS-2$ - } - - ((ElementDecl) baseNode).setContentModelNode(contentModel); - elementPool.put(name, baseNode); - break; - } - case DeclNode.INTERNAL_ENTITY : - case DeclNode.EXTERNAL_ENTITY : { - if (!parseExternalPEReference(declarationString)) { - scanner = new DTDScanner(currentDTD.getName(), declarationString); - baseNode = scanner.scanEntityDecl(); - // System.out.println("----baseNode (" + - // declarationString + ")" + baseNode); - if (type == DeclNode.INTERNAL_ENTITY && expandedEntityValue != null) { - ((EntityDecl) baseNode).expandedValue = expandedEntityValue; - } - if (baseNode != null) { - entityPool.add((EntityDecl) baseNode); - } - } - - break; - } - case DeclNode.NOTATION : { - scanner = new DTDScanner(currentDTD.getName(), declarationString); - baseNode = scanner.scanNotationDecl(); - break; - } - case DeclNode.ATTLIST : { - name = TString.word(declarationString, 1); - - // strip out the name - sIndex = declarationString.indexOf(name) + name.length(); - cString = declarationString.substring(sIndex); - - baseNode = new Attlist(name, currentDTD.getName()); - scanner = new DTDScanner(currentDTD.getName(), cString.trim()); - Vector attrs = scanner.scanAttlistDecl(entityPool); - String errorString = scanner.getErrorString(); - - if (attrs.size() > 0) { - ((Attlist) baseNode).setAttDefs(attrs); - } - if (errorString != null) { - createErrorMessage(errorString, "error"); //$NON-NLS-1$ - } - break; - } - default : { - currentDeclNode = null; - } - } - - if (baseNode != null) { - if (comment != null) { - baseNode.setComment(comment); - comment = null; - } - - if (errorMessage != null) { - baseNode.setErrorMessage(errorMessage); - errorMessage = null; - } - - if (currentDeclNode != null) { - currentDTD.addDecl(baseNode); - } - lastBaseNode = baseNode; - } - - currentDeclNode = null; - } - else { - if (lastBaseNode != null && errorMessage != null && lastBaseNode.getErrorMessage() == null) { - lastBaseNode.setErrorMessage(errorMessage); - errorMessage = null; - } - } - } - - private void addPEReferenceNode(String name) { - if (name.startsWith("%")) { //$NON-NLS-1$ - name = name.substring(1); // strip out the % from entity name - } - EntityDecl e = new EntityDecl(name, currentDTD.getName(), null, true); - e.setEntityReferenced(true); - e.setErrorMessage(errorMessage); - errorMessage = null; - currentDTD.addDecl(e); - } - - private boolean isDTDLoaded(String uri) { - boolean loaded = false; - String list = ""; //$NON-NLS-1$ - if (dtdList != null) { - Enumeration en = dtdList.elements(); - while (en.hasMoreElements()) { - DTD dtd = (DTD) en.nextElement(); - list += dtd.getName(); - list += ","; //$NON-NLS-1$ - if (dtd.getName().equals(uri)) { - loaded = true; - break; - } - } - } - return loaded; - } - - public InputSource resolveEntity(String publicId, String systemId) throws SAXException { - InputSource result = null; - URIResolver idResolver = URIResolverPlugin.createResolver(); - String logicalURI = idResolver.resolve(currentDTD.getName(), publicId, systemId); - // bug 113537, ensure physical resolution gets done here - // right before we attempt to open a stream - String physicalURI = idResolver.resolvePhysicalLocation(currentDTD.getName(), publicId, logicalURI); - result = new InputSource(logicalURI); - result.setByteStream(new LazyURLInputStream(physicalURI)); - return result; - } - - // - // Main - // - - /** Main program entry point. */ - public static void main(String argv[]) { - - // is there anything to do? - if (argv.length == 0) { - printUsage(); - System.exit(1); - } - - // vars - boolean canonical = false; - boolean expandEntityReferences = false; - DTDParser parser; - - // check parameters - for (int i = 0; i < argv.length; i++) { - String arg = argv[i]; - - // options - if (arg.startsWith("-")) { //$NON-NLS-1$ - - if (arg.equals("-c")) { //$NON-NLS-1$ - canonical = true; - continue; - } - - if (arg.equals("-x")) { //$NON-NLS-1$ - expandEntityReferences = true; - continue; - } - - if (arg.equals("-h")) { //$NON-NLS-1$ - printUsage(); - System.exit(1); - } - } - try { - parser = new DTDParser(canonical); - parser.setExpandEntityReferences(expandEntityReferences); - parser.parse(arg); - } - catch (Exception e) { - e.printStackTrace(); - } - } - - } // main(String[]) - - /** Prints the usage. */ - private static void printUsage() { - - System.err.println("usage: java sax.DTDParser (options) uri ..."); //$NON-NLS-1$ - System.err.println(); - System.err.println("options:"); //$NON-NLS-1$ - System.err.println(" -c Canonical XML output."); //$NON-NLS-1$ - System.err.println(" -x Expand entity references."); //$NON-NLS-1$ - System.err.println(" -h This help screen."); //$NON-NLS-1$ - - } // printUsage() - - private void setErrorInformation(SAXParseException ex, String severity) { - errorMessage = new ErrorMessage(); - - if (ex.getLineNumber() == -1) { - errorMessage.setErrorLine(lineNumber); - } - else { - errorMessage.setErrorLine(ex.getLineNumber()); - } - - - errorMessage.setErrorMessage(ex.getMessage()); - errorMessage.setErrorColumn(ex.getColumnNumber()); - errorMessage.setSeverity(severity); - errorMessages.add(errorMessage); - } - - private void createErrorMessage(String message, String severity) { - errorMessage = new ErrorMessage(); - - Locator locator = getLocator(); - - errorMessage.setErrorLine(locator.getLineNumber()); - errorMessage.setErrorColumn(locator.getColumnNumber()); - - errorMessage.setErrorMessage(message); - errorMessage.setSeverity(severity); - - errorMessages.add(errorMessage); - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDSaxArtifactVisitor.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDSaxArtifactVisitor.java deleted file mode 100644 index ed96bb1400..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDSaxArtifactVisitor.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; - - - -public class DTDSaxArtifactVisitor { - public void visitDTD(DTD dtd) { - Enumeration en = dtd.externalElements(); - - while (en.hasMoreElements()) { - Object e = en.nextElement(); - if (e instanceof EntityDecl) { - visitEntityDecl((EntityDecl) e); - } - else if (e instanceof ElementDecl) { - visitElementDecl((ElementDecl) e); - } - else if (e instanceof NotationDecl) { - visitNotationDecl((NotationDecl) e); - } - } - } - - public void visitNotationDecl(NotationDecl notation) { - } - - public void visitElementDecl(ElementDecl element) { - } - - public void visitEntityDecl(EntityDecl entity) { - if (entity.isEntityReferenced()) { - visitParameterEntityReferenceDecl(entity); - } - else { - if (entity.isExternal()) { - visitExternalEntityDecl(entity); - } - else { - visitInternalEntityDecl(entity); - } - } - } - - public void visitParameterEntityReferenceDecl(EntityDecl entity) { - } - - public void visitExternalEntityDecl(EntityDecl entity) { - } - - public void visitInternalEntityDecl(EntityDecl entity) { - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDScanner.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDScanner.java deleted file mode 100644 index 7027058659..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DTDScanner.java +++ /dev/null @@ -1,1126 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Vector; - -/** - * Scanning / parsing the content string from the Decl statement - * - * @version - */ -public class DTDScanner { - // element content model strings - private static final char[] empty_string = {'E', 'M', 'P', 'T', 'Y'}; - private static final char[] any_string = {'A', 'N', 'Y'}; - private static final char[] pcdata_string = {'#', 'P', 'C', 'D', 'A', 'T', 'A'}; - - // attribute type and default type strings - private static final char[] cdata_string = {'C', 'D', 'A', 'T', 'A'}; - private static final char[] id_string = {'I', 'D'}; - private static final char[] ref_string = {'R', 'E', 'F'}; - private static final char[] entit_string = {'E', 'N', 'T', 'I', 'T'}; - private static final char[] ies_string = {'I', 'E', 'S'}; - private static final char[] nmtoken_string = {'N', 'M', 'T', 'O', 'K', 'E', 'N'}; - private static final char[] notation_string = {'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N'}; - private static final char[] required_string = {'#', 'R', 'E', 'Q', 'U', 'I', 'R', 'E', 'D'}; - private static final char[] implied_string = {'#', 'I', 'M', 'P', 'L', 'I', 'E', 'D'}; - private static final char[] fixed_string = {'#', 'F', 'I', 'X', 'E', 'D'}; - - private static final char[] system_string = {'S', 'Y', 'S', 'T', 'E', 'M'}; - private static final char[] public_string = {'P', 'U', 'B', 'L', 'I', 'C'}; - private static final char[] ndata_string = {'N', 'D', 'A', 'T', 'A'}; - - private int[] fOpStack = null; - private CMGroupNode[] fGrpStack = null; - - private EntityPool entityPool; - - /* Attribute Def scanner state */ - static final int Att_Scanner_State_Name = 1, Att_Scanner_State_Type = 2, Att_Scanner_State_DefaultType = 3, Att_Scanner_State_DefaultValue = 4; - - private StringParser contentString; - private String cData; - private int prevNodeOffset = 0; - private int nodeOffset = 1; - private String ownerDTD; - - private String errorString; - - public DTDScanner(String ownerDTD, String cm) { - // System.out.println("Cm: " + cm); - contentString = new StringParser(cm); - cData = cm; - this.ownerDTD = ownerDTD; - } - - // - // [46] contentspec ::= 'EMPTY' | 'ANY' | Mixed | children - // - // Specific to VisualDTD : also allows %PEReference; - // - public CMNode scanContentModel() { - CMNode cmNode = null; - contentString.skipPastSpaces(); - if (contentString.skippedString(empty_string)) { - cmNode = new CMBasicNode("EMPTY", CMNodeType.EMPTY); //$NON-NLS-1$ - } - else if (contentString.skippedString(any_string)) { - cmNode = new CMBasicNode("ANY", CMNodeType.ANY); //$NON-NLS-1$ - } - else if (contentString.lookingAtChar('%', true)) { - cmNode = new CMReferenceNode(contentString.getData(), CMNodeType.ENTITY_REFERENCE); - } - else if (!contentString.lookingAtChar('(', true)) { - // This means that the contentmodel string is bad... - // System.out.println("!!! exception - no ("); - return cmNode; - } - else { - // System.out.println("Remaining String = " + - // contentString.getRemainingString()); - - contentString.skipPastSpaces(); - boolean skippedPCDATA = contentString.skippedString(pcdata_string); - if (skippedPCDATA) { - cmNode = scanMixed(); - } - else { - cmNode = scanChildren(); - } - - } - return cmNode; - } - - // - // [51] Mixed ::= '(' S? '#PCDATA' (S? '|' S? Name)* S? ')*' | '(' S? - // '#PCDATA' S? ')' - // - // Called after scanning past '(' S? '#PCDATA' - // - private CMNode scanMixed() { - // System.out.println("ScanMixed..."); - CMGroupNode cmNode = new CMGroupNode(); - cmNode.setGroupKind(CMNodeType.GROUP_CHOICE); - cmNode.addChild(new CMBasicNode("#PCDATA", CMNodeType.PCDATA)); //$NON-NLS-1$ - - // int prevNodeIndex = -1; - boolean starRequired = false; - - - while (true) { - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - prevNodeOffset = contentString.getCurrentOffset(); - - if (!contentString.lookingAtChar('|', true)) { - if (!contentString.lookingAtChar(')', true)) { - break; - } - if (contentString.lookingAtChar('*', true)) { - cmNode.setOccurrence(CMNodeType.ZERO_OR_MORE); - } - else if (starRequired) { - // System.out.println(" * is required ... "); - } - break; - } - - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - - nodeOffset = contentString.getCurrentOffset(); - if (nodeOffset != -1) { - // skip pass "|" - prevNodeOffset = nodeOffset; - } - - starRequired = true; - contentString.skipPastNameAndPEReference(')'); - nodeOffset = contentString.getCurrentOffset(); - - if (nodeOffset == -1) - break; - - // add leave node - int len = nodeOffset - prevNodeOffset; - String refName = contentString.getString(prevNodeOffset, len); - prevNodeOffset = nodeOffset; - if (refName.startsWith("%")) //$NON-NLS-1$ - cmNode.addChild(new CMReferenceNode(refName, CMNodeType.ENTITY_REFERENCE)); - else - cmNode.addChild(new CMReferenceNode(refName, CMNodeType.ELEMENT_REFERENCE)); - - } // end while - - - if (cmNode.getChildren().size() == 1) { - // simplify the contentModel if the CMGroupNode only has one child - // node. - return (CMBasicNode) cmNode.getChildren().elementAt(0); - } - - return cmNode; - } - - // - // [47] children ::= (choice | seq) ('?' | '*' | '+')? - // [49] choice ::= '(' S? cp ( S? '|' S? cp )* S? ')' - // [50] seq ::= '(' S? cp ( S? ',' S? cp )* S? ')' - // [48] cp ::= (Name | choice | seq) ('?' | '*' | '+')? - // - // Called after scanning past '(' - - private CMNode scanChildren() { - - // System.out.println("scanChildren..."); - - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - - prevNodeOffset = contentString.getCurrentOffset(); - nodeOffset = contentString.getCurrentOffset(); - int depth = 1; - initializeContentModelStack(depth); - int len; - - String nodeName; - CMGroupNode cmNode = new CMGroupNode(); - fGrpStack[depth] = cmNode; - - while (true) { - - // System.out.println(" Begin outter while loop ..." ); - if (contentString.lookingAtChar('(', true)) { - if (contentString.lookingAtSpace(true)) { - // skip past any white spaces after the '(' - contentString.skipPastSpaces(); - } - - depth++; - initializeContentModelStack(depth); - fGrpStack[depth] = new CMGroupNode(); - fGrpStack[depth - 1].addChild(fGrpStack[depth]); - continue; - } - - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipPastNameAndPEReference(')'); - nodeOffset = contentString.getCurrentOffset(); - - /* - * System.out.println(" prevNodeOFfset " + prevNodeOffset); - * System.out.println(" currentNodeOFfset " + nodeOffset); - */ - - len = nodeOffset - prevNodeOffset; - - if (nodeOffset == -1 || len < 1) { - break; - } - - nodeName = contentString.getString(prevNodeOffset, len); - - CMRepeatableNode rn; - if (nodeName.startsWith("%")) { //$NON-NLS-1$ - rn = new CMReferenceNode(nodeName, CMNodeType.ENTITY_REFERENCE); - } - else { - rn = new CMReferenceNode(nodeName, CMNodeType.ELEMENT_REFERENCE); - } - - fGrpStack[depth].addChild(rn); - - prevNodeOffset = nodeOffset; - - if (contentString.lookingAtChar('?', true)) { - rn.setOccurrence(CMNodeType.OPTIONAL); - } - else if (contentString.lookingAtChar('*', true)) { - rn.setOccurrence(CMNodeType.ZERO_OR_MORE); - } - else if (contentString.lookingAtChar('+', true)) { - rn.setOccurrence(CMNodeType.ONE_OR_MORE); - } - - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - - prevNodeOffset = contentString.getCurrentOffset(); - - while (true) { - // System.out.println(" Begin inner while loop ... depth " + - // depth ); - if (fOpStack[depth] != CMNodeType.GROUP_SEQUENCE && contentString.lookingAtChar('|', true)) { - fOpStack[depth] = CMNodeType.GROUP_CHOICE; - fGrpStack[depth].setGroupKind(CMNodeType.GROUP_CHOICE); - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - break; - } - else if (fOpStack[depth] != CMNodeType.GROUP_CHOICE && contentString.lookingAtChar(',', true)) { - fOpStack[depth] = CMNodeType.GROUP_SEQUENCE; - fGrpStack[depth].setGroupKind(CMNodeType.GROUP_SEQUENCE); - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - break; - } - else { - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - if (!contentString.lookingAtChar(')', true)) { - // System.out.println(" error ) not found"); - } - // end of the curent group node - if (contentString.lookingAtChar('?', true)) { - fGrpStack[depth].setOccurrence(CMNodeType.OPTIONAL); - } - else if (contentString.lookingAtChar('*', true)) { - fGrpStack[depth].setOccurrence(CMNodeType.ZERO_OR_MORE); - } - else if (contentString.lookingAtChar('+', true)) { - fGrpStack[depth].setOccurrence(CMNodeType.ONE_OR_MORE); - } - depth--; - if (depth == 0) { - break; - } - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - - // System.out.println(" End end inner while loop ... depth - // " + depth ); - - } - } // inner while - - if (depth == 0) { - break; - } - } // outer while - - if (cmNode.getChildren().size() == 1) { - // simplify the contentModel if the CMGroupNode only has one child - // node and that node is an element ref. - CMRepeatableNode rn = (CMRepeatableNode) cmNode.getChildren().elementAt(0); - if (rn instanceof CMReferenceNode) { - CMReferenceNode ref = (CMReferenceNode) rn; - if (ref.getType() == CMNodeType.ELEMENT_REFERENCE) { - if (ref.getOccurrence() == CMNodeType.ONE) { - ref.setOccurrence(cmNode.getOccurrence()); - return ref; - } - else if (cmNode.getOccurrence() == CMNodeType.ONE) { - return ref; - } - } // end of if () - } - } - - return cmNode; - } - - // - // [52] AttlistDecl ::= '<!ATTLIST' S Name AttDef* S? '>' - // [53] AttDef ::= S Name S AttType S DefaultDecl - // [60] DefaultDecl ::= '#REQUIRED' | '#IMPLIED' | (('#FIXED' S)? - // AttValue) - // - - public Vector scanAttlistDecl(EntityPool entityPool) { - Vector attList = new Vector(); - this.entityPool = entityPool; - - int scannerState = Att_Scanner_State_Name; - - AttNode attNode; - - while (true) { - attNode = new AttNode(); - - // System.out.println(" scanner state: " + scannerState); - - // scanning att name - if (scannerState == Att_Scanner_State_Name) { - // System.out.println("scan att Name..."); - scannerState = checkForAttributeWithPEReference(attNode, scannerState); - if (scannerState == -1) { - return attList; - } - } - - // scanning att type - if (scannerState == Att_Scanner_State_Type) { - // System.out.println("scan att type..."); - - if (contentString.skippedString(cdata_string)) { - attNode.type = new String(cdata_string); - scannerState = Att_Scanner_State_DefaultType; - } - else if (contentString.skippedString(id_string)) { - if (!contentString.skippedString(ref_string)) { - attNode.type = new String(id_string); - } - else if (!contentString.lookingAtChar('S', true)) { - attNode.type = "IDREF"; //$NON-NLS-1$ - } - else { - attNode.type = "IDREFS"; //$NON-NLS-1$ - } - scannerState = Att_Scanner_State_DefaultType; - } - else if (contentString.skippedString(entit_string)) { - if (contentString.lookingAtChar('Y', true)) { - attNode.type = "ENTITY"; //$NON-NLS-1$ - } - else if (contentString.skippedString(ies_string)) { - attNode.type = "ENTITIES"; //$NON-NLS-1$ - } - scannerState = Att_Scanner_State_DefaultType; - } - else if (contentString.skippedString(nmtoken_string)) { - if (contentString.lookingAtChar('S', true)) { - attNode.type = "NMTOKENS"; //$NON-NLS-1$ - } - else { - attNode.type = "NMTOKEN"; //$NON-NLS-1$ - } - scannerState = Att_Scanner_State_DefaultType; - } - else if (contentString.skippedString(notation_string)) { - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - } - if (!contentString.lookingAtChar('(', true)) { - System.out.println(" missing ( in notation "); //$NON-NLS-1$ - } - attNode.type = "NOTATION"; //$NON-NLS-1$ - attNode.enumList = scanEnumeration(contentString, true); - scannerState = Att_Scanner_State_DefaultType; - } - else if (contentString.lookingAtChar('(', true)) { - attNode.type = "ENUMERATION"; //$NON-NLS-1$ - attNode.enumList = scanEnumeration(contentString, false); - scannerState = Att_Scanner_State_DefaultType; - } - else { - scannerState = checkForAttributeWithPEReference(attNode, scannerState); - if (scannerState == Att_Scanner_State_Type) { - setErrorString("Failed to find type for attribute '" + attNode.name + "'. Please refer to the original DTD file."); //$NON-NLS-1$ //$NON-NLS-2$ - // we failed to find a type for this attribute - return attList; - } - } - } - - if (scannerState == Att_Scanner_State_DefaultType) { - contentString.skipPastSpaces(); - // System.out.println("scan default type..."); - if (contentString.skippedString(required_string)) { - attNode.defaultType = new String(required_string); - } - else if (contentString.skippedString(implied_string)) { - attNode.defaultType = new String(implied_string); - } - else { - if (contentString.skippedString(fixed_string)) { - contentString.skipPastSpaces(); - attNode.defaultType = new String(fixed_string); - } - else - // "default" - attNode.defaultType = "NOFIXED"; //$NON-NLS-1$ - - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - attNode.defaultValue = scanDefaultAttValue(contentString); - } - scannerState = Att_Scanner_State_Name; // next - } - - - attList.addElement(attNode); - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - nodeOffset = contentString.getCurrentOffset(); - - if (nodeOffset >= cData.length()) - return attList; - - prevNodeOffset = contentString.getCurrentOffset(); - - }// end while loop - } - - // - // content model stack - // - private void initializeContentModelStack(int depth) { - if (fOpStack == null) { - fOpStack = new int[8]; - fGrpStack = new CMGroupNode[8]; - } - else if (depth == fOpStack.length) { - int[] newStack = new int[depth * 2]; - System.arraycopy(fOpStack, 0, newStack, 0, depth); - fOpStack = newStack; - - CMGroupNode[] newGrpStack = new CMGroupNode[depth * 2]; - System.arraycopy(fGrpStack, 0, newGrpStack, 0, depth); - fGrpStack = newGrpStack; - } - fOpStack[depth] = -1; - fGrpStack[depth] = null; - } - - // - private int checkForAttributeWithPEReference(AttNode attNode, int scannerState) { - int state = -1; - int len; - String rawText; - EntityDecl pEntity; - - // System.out.println(" checkforATTPERReference- start scannerState: " - // + scannerState); - if (scannerState == Att_Scanner_State_Name) { - contentString.skipPastNameAndPEReference(' '); - nodeOffset = contentString.getCurrentOffset(); - len = nodeOffset - prevNodeOffset; - - rawText = contentString.getString(prevNodeOffset, len); - attNode.name = rawText; - - // System.out.println("State_name : " + rawText); - - if (rawText.startsWith("%") && rawText.endsWith(";")) { //$NON-NLS-1$ //$NON-NLS-2$ - String pe = rawText.substring(1, rawText.length() - 1); - - pEntity = entityPool.referPara(pe); - if (pEntity != null) { - // System.out.println(" name :" + rawText +" expandTo:" + - // pEntity.expandedValue); - state = whatIsTheNextAttributeScanningState(pEntity.expandedValue, scannerState); - // System.out.println("checkForAttrwithPER - nextstate: " - // + state); - } - else - state = Att_Scanner_State_Type; - } - else - state = Att_Scanner_State_Type; - - } - else if (scannerState == Att_Scanner_State_Type) { - if (contentString.lookingAtChar('%', true)) { - rawText = getPEName(); - attNode.type = "%" + rawText; //$NON-NLS-1$ - String peName = rawText.substring(0, rawText.length() - 1); - // System.out.println("State_type : pe- " + peName); - pEntity = entityPool.referPara(peName); - if (pEntity != null) { - state = whatIsTheNextAttributeScanningState(pEntity.expandedValue, scannerState); - } - else - state = Att_Scanner_State_DefaultType; - } - else - state = Att_Scanner_State_Type; - } - else if (scannerState == Att_Scanner_State_DefaultType) { - if (contentString.lookingAtChar('%', true)) { - rawText = getPEName(); - attNode.defaultType = rawText; - // System.out.println("State_defaultType : " + rawText); - pEntity = entityPool.referPara(rawText.substring(1, rawText.length() - 1)); - if (pEntity != null) { - state = whatIsTheNextAttributeScanningState(pEntity.expandedValue, scannerState); - } - else - state = Att_Scanner_State_DefaultValue; - } - else - state = Att_Scanner_State_DefaultType; - } - else if (scannerState == Att_Scanner_State_DefaultValue) { - if (contentString.lookingAtChar('%', true)) { - rawText = getPEName(); - attNode.defaultValue = rawText; - // System.out.println("State_defaultValue : " + rawText); - - pEntity = entityPool.referPara(rawText.substring(1, rawText.length() - 1)); - if (pEntity != null) { - state = whatIsTheNextAttributeScanningState(pEntity.expandedValue, scannerState); - } - else - state = Att_Scanner_State_DefaultValue; - } - else - state = Att_Scanner_State_DefaultValue; - } - - if (contentString.lookingAtSpace(true)) - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - return state; - } - - private String getPEName() { - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipToChar(';', true); - nodeOffset = contentString.getCurrentOffset(); - int len = nodeOffset - prevNodeOffset; - return contentString.getString(prevNodeOffset, len); - } - - private int whatIsTheNextAttributeScanningState(String attrContentString, int currentState) { - StringParser sp = new StringParser(attrContentString.trim()); - - - int nextState = currentState; - int nOffset = 0; - - /* - * System.out.println("WhatistheNext AttContentStringt : " + - * attrContentString); System.out.println("WhatistheNext - * AttContentStringL : " + attrContentString.length()); - * System.out.println("WhatistheNext currentstate : " + currentState); - */ - - while (true) { - // System.out.println("WhatistheNext inside whil nextstate : " + - // nextState); - if (nextState == Att_Scanner_State_Name) { // the current - // scanning state is - // Attr Name, is the - // next part Attr Type - // ? - if (isAttrName(sp)) { - nextState = Att_Scanner_State_Type; - } - } - else if (nextState == Att_Scanner_State_Type) { // the current - // scanning state - // is Attr Type, - // is the next - // part Default - // Attr Type ? - - if (isAttrType(sp)) { - nextState = Att_Scanner_State_DefaultType; - } - else - System.out.println("WhatistheNext Attr Part - is not an Attr Type"); //$NON-NLS-1$ - - } - - if (nextState == Att_Scanner_State_DefaultType) { - - int dType = isAttrDefaultType(sp); - // System.out.println("WhatistheNext inside dType : " + - // dType); - if (dType == 1) // #REQUIRED or #IMPLIED - { - nextState = Att_Scanner_State_Name; - } - else { - if (dType == 2) // #FIXED - { - // need to look at this again - nextState = Att_Scanner_State_DefaultType; - } - - if (scanDefaultAttValue(sp) != null) { - nextState = Att_Scanner_State_Name; - - } - } - } - - sp.skipPastSpaces(); - - if (nOffset == sp.getCurrentOffset()) - break; - - nOffset = sp.getCurrentOffset(); - - if (nOffset >= attrContentString.length() || nOffset == -1) - break; - - } // end while - - return nextState; - } - - - private boolean isAttrName(StringParser sp) { - // System.out.println("isAttrName - sp:" + sp.fData); - // System.out.println("isAttrName - currentOffset:" + - // sp.getCurrentOffset()); - boolean isAttrName = false; - int prev = sp.getCurrentOffset(); - sp.skipPastName(' '); - if ((sp.getCurrentOffset() - prev) > 0) - isAttrName = true; - return isAttrName; - - } - - private boolean isAttrType(StringParser sp) { - // System.out.println("isAttrType - sp:" + sp.fData); - // System.out.println("isAttrType - currentOffset:" + - // sp.getCurrentOffset()); - boolean isAttrType = false; - if (sp.skippedString(cdata_string)) { - isAttrType = true; - } - else if (sp.skippedString(id_string)) { - if (!sp.skippedString(ref_string)) { - isAttrType = true; // ID - } - else if (!sp.lookingAtChar('S', true)) { - isAttrType = true; // IDREFS - } - else { - isAttrType = true; // IDREF - } - } - else if (sp.skippedString(entit_string)) { - if (sp.lookingAtChar('Y', true)) { - isAttrType = true; // ENTITY - } - else if (sp.skippedString(ies_string)) { - isAttrType = true; // ENTITITES - } - } - else if (sp.skippedString(nmtoken_string)) { - if (sp.lookingAtChar('S', true)) { - isAttrType = true; // NMTOKENS - } - else { - isAttrType = true; // NMTOKEN - } - } - else if (sp.skippedString(notation_string)) { - if (!sp.lookingAtChar('(', true)) { - // System.out.println(" missing ( in notation "); - } - Vector enumList = scanEnumeration(sp, true); - if (enumList == null || enumList.size() == 0) - isAttrType = false; - else - isAttrType = true; - } - else if (sp.lookingAtChar('(', true)) { - // "ENUMERATION"; - Vector enumList = scanEnumeration(sp, false); - if (enumList == null || enumList.size() == 0) - isAttrType = false; - else - isAttrType = true; - } - - return isAttrType; - - } - - /* - * return 0 - not default type 1 - #REQUIRED or #IMPLIED 2 - #FIXED - */ - - private int isAttrDefaultType(StringParser sp) { - // System.out.println("isAttrDefaultType - sp:" + sp.fData); - int result = 0; - if (sp.skippedString(required_string)) { - result = 1; - } - else if (sp.skippedString(implied_string)) { - result = 1; - } - else if (sp.skippedString(fixed_string)) { - result = 2; - } - return result; - } - - // - // [58] NotationType ::= 'NOTATION' S '(' S? Name (S? '|' S? Name)* S? ')' - // [59] Enumeration ::= '(' S? Nmtoken (S? '|' S? Nmtoken)* S? ')' - // - // Called after scanning '(' - // - private Vector scanEnumeration(StringParser sp, boolean isNotationType) { - // System.out.println(" scanEnum ..."); - Vector enumList = null; - int len; - - if (sp.lookingAtSpace(true)) - sp.skipPastSpaces(); - - int prevNodeOffset = sp.getCurrentOffset(); - int nodeOffset; - - String nodeName; - - while (true) { - - if (isNotationType) - sp.skipPastNameAndPEReference(')'); - else - sp.skipPastNmtokenAndPEReference(')'); - - nodeOffset = sp.getCurrentOffset(); - - if (nodeOffset == -1) { - return enumList; - } - - len = nodeOffset - prevNodeOffset; - nodeName = sp.getString(prevNodeOffset, len); - - if (enumList == null) - enumList = new Vector(); - - enumList.addElement(nodeName); - - if (sp.lookingAtSpace(true)) - sp.skipPastSpaces(); - - if (!sp.lookingAtChar('|', true)) { - if (!sp.lookingAtChar(')', true)) { - System.out.println("scanning enum values - error missing ')'"); //$NON-NLS-1$ - break; - } - break; - } - - if (sp.lookingAtSpace(true)) - sp.skipPastSpaces(); - - prevNodeOffset = sp.getCurrentOffset(); - } - return enumList; - } - - // - // [10] AttValue ::= '"' ([^<&"] | Reference)* '"' - // | "'" ([^<&'] | Reference)* "'" - // - /** - * Scan the default value in an attribute declaration - * - * @param elementType - * handle to the element that owns the attribute - * @param attrName - * handle in the string pool for the attribute name - * @return handle in the string pool for the default attribute value - * @exception java.lang.Exception - */ - public String scanDefaultAttValue(StringParser sp) { - String value = null; - // System.out.println("scan default ATT Value... sp:" + sp.fData); - - sp.skipPastSpaces(); - - boolean single; - if (!(single = sp.lookingAtChar('\'', true)) && !sp.lookingAtChar('\"', true)) { - return value; - } - - char qchar = single ? '\'' : '\"'; - int sOffset = sp.getCurrentOffset(); - sp.skipToChar(qchar, true); - int len = sp.getCurrentOffset() - sOffset - 1; - if (len == 0) - value = ""; //$NON-NLS-1$ - else - value = sp.getString(sOffset, len); - - return value; - } - - // - // [70] EntityDecl ::= GEDecl | PEDecl - // [71] GEDecl ::= '<!ENTITY' S Name S EntityDef S? '>' - // [72] PEDecl ::= '<!ENTITY' S '%' S Name S PEDef S? '>' - // [73] EntityDef ::= EntityValue | (ExternalID NDataDecl?) - // [74] PEDef ::= EntityValue | ExternalID - // [75] ExternalID ::= 'SYSTEM' S SystemLiteral - // | 'PUBLIC' S PubidLiteral S SystemLiteral - // [76] NDataDecl ::= S 'NDATA' S Name - // [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' - // | "'" ([^%&'] | PEReference | Reference)* "'" - // - // Called after scanning 'ENTITY' - // - public EntityDecl scanEntityDecl() { - prevNodeOffset = 1; - nodeOffset = 1; - int len; - boolean isPEDecl = false; - EntityDecl entityDecl = null; - - String name = null; - String ndata = null; - - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - if (!contentString.lookingAtChar('%', true)) { - isPEDecl = false; // <!ENTITY x "x"> - } - else if (contentString.lookingAtSpace(true)) { - isPEDecl = true; // <!ENTITY % x "x"> - } - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipPastName(' '); - nodeOffset = contentString.getCurrentOffset(); - len = nodeOffset - prevNodeOffset; - if (len > 0) { - name = contentString.getString(prevNodeOffset, len); - prevNodeOffset = nodeOffset; - } - } - - if (name == null) - return null; - - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - - boolean single; - if ((single = contentString.lookingAtChar('\'', true)) || contentString.lookingAtChar('\"', true)) { - String value = scanEntityValue(single); - entityDecl = new EntityDecl(name, ownerDTD, value, isPEDecl); - } - else { - // external entity - ExternalID xID = scanExternalID(); - if (xID != null) { - if (!isPEDecl) // general entity - { - boolean unparsed = false; - contentString.skipPastSpaces(); - unparsed = contentString.skippedString(ndata_string); - if (unparsed) { - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipPastName(' '); - nodeOffset = contentString.getCurrentOffset(); - len = nodeOffset - prevNodeOffset; - ndata = contentString.getString(prevNodeOffset, len); - } - } - entityDecl = new EntityDecl(name, ownerDTD, xID, isPEDecl, ndata); - } - } - return entityDecl; - } - - - // - // [82] NotationDecl ::= '<!NOTATION' S Name S (ExternalID | PublicID) S? - // '>' - // [75] ExternalID ::= 'SYSTEM' S SystemLiteral - // | 'PUBLIC' S PubidLiteral S SystemLiteral - // [83] PublicID ::= 'PUBLIC' S PubidLiteral - // - // Called after scanning 'NOTATION' - // - public NotationDecl scanNotationDecl() { - prevNodeOffset = 1; - nodeOffset = 1; - int len; - NotationDecl notationDecl = null; - - String name = null; - - if (contentString.lookingAtSpace(true)) { - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipPastName(' '); - nodeOffset = contentString.getCurrentOffset(); - len = nodeOffset - prevNodeOffset; - if (len > 0) { - name = contentString.getString(prevNodeOffset, len); - prevNodeOffset = nodeOffset; - } - } - - if (name == null) - return null; - - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - - notationDecl = new NotationDecl(name, ownerDTD); - - ExternalID xID = scanExternalID(); - if (xID != null) { - if (xID.getSystemLiteral() != null) { - notationDecl.setSystemId(xID.getSystemLiteral()); - } - if (xID.getPubIdLiteral() != null) { - notationDecl.setPublicId(xID.getPubIdLiteral()); - } - } - - return notationDecl; - } - - - private String scanEntityValue(boolean single) { - char qchar = single ? '\'' : '\"'; - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipToChar(qchar, false); - int len = contentString.getCurrentOffset() - prevNodeOffset; - String value = contentString.getString(prevNodeOffset, len); - return value; - } - - // - // [75] ExternalID ::= 'SYSTEM' S SystemLiteral - // | 'PUBLIC' S PubidLiteral S SystemLiteral - private ExternalID scanExternalID() { - ExternalID xID = null; - char qchar = '\"'; - if (contentString.skippedString(system_string)) { - if (!contentString.lookingAtSpace(true)) { - return null; - } - contentString.skipPastSpaces(); - - if (contentString.lookingAtChar('\'', true)) - qchar = '\''; - else if (contentString.lookingAtChar('\"', true)) - qchar = '\"'; - - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipToChar(qchar, true); - int len = contentString.getCurrentOffset() - prevNodeOffset - 1; - String systemId = contentString.getString(prevNodeOffset, len); - // System.out.println("systemid..." + systemId); - xID = new ExternalID(systemId); - } - else if (contentString.skippedString(public_string)) { - if (!contentString.lookingAtSpace(true)) { - return null; - } - - contentString.skipPastSpaces(); - if (contentString.lookingAtChar('\'', true)) - qchar = '\''; - else if (contentString.lookingAtChar('\"', true)) - qchar = '\"'; - - // publicLiteral - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipToChar(qchar, true); - int len = contentString.getCurrentOffset() - prevNodeOffset - 1; - String publicId = contentString.getString(prevNodeOffset, len); - - // systemLiteral - contentString.skipPastSpaces(); - if (contentString.lookingAtChar('\'', true)) - qchar = '\''; - else if (contentString.lookingAtChar('\"', true)) - qchar = '\"'; - prevNodeOffset = contentString.getCurrentOffset(); - contentString.skipToChar(qchar, true); - len = contentString.getCurrentOffset() - prevNodeOffset - 1; - - if (len > 0) { - String systemId = contentString.getString(prevNodeOffset, len); - xID = new ExternalID(publicId, systemId); - } - else { - xID = new ExternalID(publicId, null); - } - } - return xID; - } - - // - // [83] PublicID ::= 'PUBLIC' S PubidLiteral - // - - // dmw 11/15 private method never read locally - // TODO: change to private if used, otherwise should be removed - String scanPublicID() { - String pID = null; - if (contentString.skippedString(public_string)) { - if (!contentString.lookingAtSpace(true)) { - return pID; - } - contentString.skipPastSpaces(); - prevNodeOffset = contentString.getCurrentOffset(); - - contentString.skipToChar(' ', true); - int len = contentString.getCurrentOffset() - prevNodeOffset; - pID = contentString.getString(prevNodeOffset, len); - } - - return pID; - } - - // - // Main - // - - /** Main program entry point. */ - public static void main(String argv[]) { - - // is there anything to do? - if (argv.length == 0) { - System.exit(1); - } - - // DTDScanner sc = new DTDScanner(argv[0]); - DTDScanner sc = new DTDScanner("hello.dtd", " gif SYSTEM \"GIF File\" "); //$NON-NLS-1$ //$NON-NLS-2$ - - NotationDecl n = sc.scanNotationDecl(); - System.out.println("Noation Name: " + n.getNodeName()); //$NON-NLS-1$ - System.out.println("SystemId: " + n.getSystemId()); //$NON-NLS-1$ - - - // Attributes - // Vector lists = sc.scanAttlistDecl(); - // sc.printAttList(lists); - - // System.out.println("CM: " + sc.scanContentModel()); - - } // main(String[]) - - /** - * Gets the errorString - * - * @return Returns a String - */ - public String getErrorString() { - return errorString; - } - - /** - * Sets the errorString - * - * @param errorString - * The errorString to set - */ - public void setErrorString(String errorString) { - this.errorString = errorString; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DeclNode.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DeclNode.java deleted file mode 100644 index 25720b4c6f..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/DeclNode.java +++ /dev/null @@ -1,103 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class DeclNode { - static public final int INVALID = -1; - static public final int ELEMENT = 1; - static public final int ATTLIST = 2; - static public final int ENTITY = 3; - static public final int INTERNAL_ENTITY = 4; - static public final int EXTERNAL_ENTITY = 5; - static public final int INTERNAL_GENERAL_ENTITY = 6; - static public final int INTERNAL_PARAMETER_ENTITY = 7; - static public final int EXTERNAL_GENERAL_ENTITY = 8; - static public final int EXTERNAL_PARAMETER_ENTITY = 9; - static public final int PARAMETER_ENTITY_REFERENCE = 10; - static public final int NOTATION = 11; - static public final int COMMENT = 12; - - static public final int START_DTD = 21; - static public final int END_DTD = 22; - static public final int START_ENTITY_DTD = 23; - static public final int END_ENTITY_DTD = 24; - static public final int ERROR = 25; - - public int type = INVALID; - private String declName = null; - private String contentString = null; - private String errorMessage = null; - private String comment = null; - - // - // Constants - // - - /** Default constructor. */ - public DeclNode(int type) { - this(null, type, null); - } - - public DeclNode(String name, int type, String contentString) { - this.declName = name; - this.type = type; - this.contentString = contentString; - } - - public String getDeclName() { - return declName; - } - - public void setDeclName(String name) { - declName = name; - } - - public int getType() { - return type; - } - - public void setType(int type) { - this.type = type; - } - - public String getErrorMessage() { - return errorMessage; - } - - public void setErrorMessage(String message) { - errorMessage = message; - } - - public String getContentString() { - return contentString; - } - - public void setContentString(String content) { - this.contentString = content; - } - - public String getComment() { - return comment; - } - - public void setComment(String comment) { - this.comment = comment; - } - - public String toString() - - { - return "Node Name: " + declName + " Type: " + type + " ContentString: " + contentString; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ElementDecl.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ElementDecl.java deleted file mode 100644 index 3e87167aeb..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ElementDecl.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class ElementDecl extends BaseNode { - CMNode contentModelNode = null; - - public ElementDecl(String name, String ownerDTD) { - this(name, ownerDTD, null, null); - } - - public ElementDecl(String name, String ownerDTD, String comment, ErrorMessage errorMessage) { - super(name, ownerDTD, comment, errorMessage); - } - - public CMNode getContentModelNode() { - return contentModelNode; - } - - public void setContentModelNode(CMNode cmnode) { - contentModelNode = cmnode; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityDecl.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityDecl.java deleted file mode 100644 index 673c99f163..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityDecl.java +++ /dev/null @@ -1,242 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class EntityDecl extends BaseNode { - boolean isParameter = false; - String expandedValue = null; // Always <var>null</var> for external - // Entities - String value = null; // Always <var>null</var> for external Entities - ExternalID externalID = null; // Always <var>null</var> for internal - // Entities - String ndata = null; // Always <var>null</var> for internal Entities - - boolean parsed = false; - DTDParser dtd = null; // Always null, except when it has been parsed. - - boolean entityReferenced = false; - - /** - * Constructor for internal Entities. - * - * @param name - * Name of this Entity. - * @param value - * The XML-encoded value that was directly assigned to the - * Entity. - * @param isParameter - * =true if a parameter Entity; otherwise =false. - */ - public EntityDecl(String name, String ownerDTD, String value, boolean isParameter) { - super(name, ownerDTD, null, null); - this.value = value; - this.isParameter = isParameter; - } - - /** - * Constructor for external Entities. - * - * @param name - * Name of the Entity. - * @param externalID - * The reference(s) to the external entity to retrieve. - * @param isParameter - * =true if a parameter Entity; otherwise =false. - * @param ndata - * The notation associated with the binary Entity, or <var>null</var> - * if the Entity is a text Entity. - * @see sax.ExternalID - */ - public EntityDecl(String name, String ownerDTD, ExternalID externalID, boolean isParameter, String ndata) { - super(name, ownerDTD, null, null); - this.externalID = externalID; - this.isParameter = isParameter; - this.ndata = ndata; - } - - /** - * Returns whether this Entity is a parameter Entity. - * - * @return =true if an internal parameter Entity; otherwise =false. - */ - public boolean isParameter() { - return this.isParameter; - } - - /** - * Returns the value of this Entity. - * - * @return The XML-encoded value that was directly assigned to the - * internal Entity; otherwise, <var>null</var>. - */ - public String getValue() { - return this.value; - } - - public boolean isEntityReferenced() { - return entityReferenced; - } - - public void setEntityReferenced(boolean reference) { - entityReferenced = reference; - } - - - /** - * Returns the system identifier of the Notation. A system identifier is a - * URI, which may be used to retrieve an external entity's content. - * <p> - * This method is defined by DOM. - * - * @return The system identifier, or <var>null</var> if the identifier is - * not defined. - * @see org.eclipcse.wst.dtd.parser.ExternalID#getSystemLiteral - */ - public String getSystemId() { - if (externalID == null) - return null; - else - return this.externalID.getSystemLiteral(); - } - - /** - * Sets the system identifier of the Notation. A system identifier is a - * URI, which may be used to retrieve an external entity's content. - * <p> - * This method is defined by DOM. - * - * @param systemIdentifier - * The system identifier. - * @see org.eclipcse.wst.dtd.parser.ExternalID - */ - public void setSystemId(String systemIdentifier) { - // System.out.println("setSYstemId - externalId: " + externalID); - this.externalID = new ExternalID(this.externalID.getPubIdLiteral(), systemIdentifier); - } - - /** - * Returns the public identifier of the Notation. This value is only valid - * if the identifier is defined as <var>public</var> (as opposed to - * <var>system</var>). Public identifiers may be used to try to generate - * an alternative URI in order to retrieve the an external entities - * content. If retrieval fails using the public identifier, an attempt - * must be made to retrieve content using the system identifier. - * <p> - * This method is defined by DOM. - * - * @return The public identifier, or <var>null</var> if the identifier is - * not defined. - * @see org.eclipcse.wst.dtd.parser.ExternalID - */ - public String getPublicId() { - if (externalID == null) - return null; - else - return this.externalID.getPubIdLiteral(); - } - - /** - * Sets the public identifier of the Notation. This value is only valid if - * the identifier is defined as <var>public</var> (as opposed to - * <var>system</var>). Public identifiers may be used to try to generate - * an alternative URI in order to retrieve the an external entities - * content. If retrieval fails using the public identifier, an attempt - * must be made to retrieve content using the system identifier. - * <p> - * This method is defined by DOM. - * - * @param publicIdentifier - * The public identifier. - * @see #getPublicId - * @see org.eclipcse.wst.dtd.parser.ExternalID - */ - public void setPublicId(String publicIdentifier) { - this.externalID = new ExternalID(publicIdentifier, this.externalID.getSystemLiteral()); - } - - /** - * Returns the external ID of this Entity. - * - * @return The reference(s) to the external entity to retrieve; otherwise, - * <var>null</var>. - * @see org.eclipcse.wst.dtd.parser.ExternalID - */ - public ExternalID getExternalID() { - return this.externalID; - } - - /** - * Returns whether this entity value is external. - * - * @return =true if entity is external; otherwise, =false. - * @see org.eclipcse.wst.dtd.parser.ExternalID - */ - public boolean isExternal() { - return this.externalID != null; - } - - /** - * Returns the notation associated with this Entity. - * - * @return The notation associated with the external binary Entity, - * otherwise, <var>null</var>. - */ - public String getNotation() { - return this.ndata; - } - - public void setNotation(String ndata) { - this.ndata = ndata; - } - - /** - * Returns the notation associated with this Entity. - * <p> - * This method is defined by DOM. - * - * @return The notation associated with the external binary Entity, - * otherwise, <var>null</var>. - */ - public String getNotationName() { - return this.ndata; - } - - /** - * <p> - * This method is defined by DOM. - * - * public void setNotationName(String arg) { this.ndata = arg; } - */ - - /** - * Returns whether there is a notation associated with this entity value. - * - * @return =true if the external binary entity contains a notation; - * otherwise, =false. - */ - public boolean isNotation() { - return this.ndata != null; - } - - public void setValue(String s) { - this.value = s; - } - - public void setParsed(boolean p) { - this.parsed = p; - } - - public boolean getParsed() { - return this.parsed; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityPool.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityPool.java deleted file mode 100644 index c43e41460b..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/EntityPool.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 - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.Enumeration; -import java.util.Hashtable; - -public class EntityPool { - private Hashtable m_entity = new Hashtable(); - private Hashtable m_para = new Hashtable(); // parameter references - - public EntityPool() { - } - - public boolean add(EntityDecl entity) { - String name = entity.getNodeName(); - if (entity.isParameter()) { - if (m_para.containsKey(name)) - return false; - m_para.put(name, entity); - } - else { - if (m_entity.containsKey(name)) - return false; - m_entity.put(name, entity); - } - return true; - } - - public EntityDecl refer(String name) { - return (EntityDecl) m_entity.get(name); - } - - public EntityDecl referPara(String name) { - return (EntityDecl) m_para.get(name); - } - - /** - * Return an <CODE>Enumeration</CODE> of <CODE>EntityDecl</CODE>. - * - * @see org.eclipcse.wst.dtd.parser.EntityDecl - */ - public Enumeration elements() { - return m_entity.elements(); - } - - /** - * Return an <CODE>Enumeration</CODE> of <CODE>EntityDecl</CODE> for - * parameter entities. - * - * @see org.eclipcse.wst.dtd.parser.EntityDecl - */ - public Enumeration parameterEntityElements() { - return m_para.elements(); - } - - /** - * For DTD#getEntities(); - */ - Hashtable getEntityHash() { - return this.m_entity; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ErrorMessage.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ErrorMessage.java deleted file mode 100644 index 6995e8aa37..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ErrorMessage.java +++ /dev/null @@ -1,114 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - - - -public class ErrorMessage { - private int errorLine, errorColumn, severity; - private String errorString; - - - public ErrorMessage() { - } - - public void setErrorMessage(String error) { - errorString = error; - } - - public void setSeverity(int severity) { - this.severity = severity; - } - - public void setSeverity(String severity) { - if (severity == "warning") { //$NON-NLS-1$ - this.severity = 0; - } - else if (severity == "error") { //$NON-NLS-1$ - this.severity = 1; - } - else if (severity == "fatal") { //$NON-NLS-1$ - this.severity = 2; - } - } - - public void setErrorLine(int line) { - errorLine = line; - } - - public void setErrorColumn(int column) { - errorColumn = column; - } - - public String getErrorMessage() { - return errorString; - } - - public int getSeverity() { - return severity; - } - - public int getErrorLine() { - return errorLine; - } - - public int getErrorColumn() { - return errorColumn; - } - - private int startOffset = -1; - - public void setErrorStartOffset(int start) { - startOffset = start; - } - - public int getErrorStartOffset() { - return startOffset; - } - - private int endOffset = -1; - - public void setErrorEndOffset(int end) { - endOffset = end; - } - - public int getErrorEndOffset() { - return endOffset; - } - - - Object object; - - /** - * Get the value of the closest object to the error. - * - * @return value of object. - */ - public Object getObject() { - return object; - } - - /** - * Set the value of closest object to the error. - * - * @param v - * Value to assign to object. - */ - public void setObject(Object v) { - this.object = v; - } - - - public void addNewErrorMessageLine(String newLine) { - errorString += "\n" + newLine; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ExternalID.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ExternalID.java deleted file mode 100644 index 11b0988524..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/ExternalID.java +++ /dev/null @@ -1,154 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -public class ExternalID { - private static final int T_SYSTEM = 0; - private static final int T_PUBLIC = 1; - - int type = T_PUBLIC; - String publicID = null; - String systemID = null; - - /** - * Constructor for system IDs. - * - * @param systemID - * URI, which may be used to retrieve an external entity's - * content. - */ - public ExternalID(String systemID) { - this.type = T_SYSTEM; - this.publicID = null; - this.systemID = systemID; - } - - /** - * Constructor for public and system IDs. - * - * @param publicID - * Identifier to be used to try to generate an alternative URI - * in order to retrieve the external entity's content, or - * <var>null</var> if a system identitier is to be - * constructed. - * @param systemID - * URI, which may be used to retrieve an external entity's - * content. - */ - public ExternalID(String publicID, String systemID) { - this.type = T_PUBLIC; - this.publicID = publicID; - this.systemID = systemID; - if (null == this.publicID) - this.type = T_SYSTEM; - } - - /** - * Returns if this external ID is a system ID (or public ID). - * - * @return System ID=true, Public ID=false. - * @see #isPublic - */ - public boolean isSystem() { - return this.type == T_SYSTEM; - } - - /** - * Returns if this external ID is a public ID (or system ID). - * - * @return Public ID=true, System ID=false. - * @see #isSystem - */ - public boolean isPublic() { - return this.type == T_PUBLIC; - } - - /** - * Returns the system identifier of this external ID. A system identifier - * is a URI, which may be used to retrieve an external entity's content. - * - * @return The system identifier, or <var>null</var> if the identifier is - * not defined. - * @see #getPubidLiteral - */ - public String getSystemLiteral() { - return this.systemID; - } - - /** - * Returns the public identifier of this external ID. This value is only - * valid if the identifier is defined as <var>public</var> (as opposed to - * <var>system</var>). Public identifiers may be used to try to generate - * an alternative URI in order to retrieve an external entity's content. - * If retrieval fails using the public identifier, an attempt must be made - * to retrieve content using the system identifier. - * - * @return The public identifier, or <var>null</var> if the identifier is - * not defined. - * @see #getSystemLiteral - */ - public String getPubIdLiteral() { - return this.publicID; - } - - /** - * Returns this external ID in the format it was declared: <CODE>SYSTEM - * "<VAR>systemID</VAR>"</CODE> or <CODE>PUBLIC "<VAR>publicID</VAR>" - * "<VAR>systemID</VAR>"</CODE>. - * - * @return XML string representing the content of the external ID (never - * <var>null</var>). - */ - public String toString() { - String ret; - if (isSystem()) { - ret = "SYSTEM \"" + getSystemLiteral() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ - } - else if (null != getSystemLiteral()) { - ret = "PUBLIC \"" + getPubIdLiteral() + "\" \"" + getSystemLiteral() + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - } - else { - ret = "PUBLIC \"" + getPubIdLiteral() + "\""; // for NOTATION //$NON-NLS-1$ //$NON-NLS-2$ - } - return ret; - } - - /** - * - */ - public boolean equals(Object obj) { - if (obj == null) - return false; - if (!(obj instanceof ExternalID)) - return false; - ExternalID eid = (ExternalID) obj; - if (!((eid.publicID == null && this.publicID == null) || eid.publicID != null && eid.publicID.equals(this.publicID))) - return false; - if (!((eid.systemID == null && this.systemID == null) || eid.systemID != null && eid.systemID.equals(this.systemID))) - return false; - return true; - } - - - /** - * - */ - public int hashCode() { - int retval = 0; - if (publicID != null) - retval = publicID.hashCode(); - if (systemID != null) - retval += systemID.hashCode(); - return retval; - } - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/NotationDecl.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/NotationDecl.java deleted file mode 100644 index 57d4e2f654..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/NotationDecl.java +++ /dev/null @@ -1,77 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -/** - * Notations are how the Document Type Description (DTD) records hints about - * the format of an XML "unparsed entity" -- in other words, non-XML data - * bound to this document type, which some applications may wish to consult - * when manipulating the document. A Notation represents a name-value pair, - * with its nodeName being set to the declared name of the notation. - */ -public class NotationDecl extends BaseNode { - /** Public identifier. */ - protected String publicId = null; - - /** System identifier. */ - protected String systemId = null; - - // - // Constructors - // - - /** Factory constructor. */ - public NotationDecl(String name, String ownerDTD) { - super(name, ownerDTD); - } - - // - // Notation methods - // - - /** - * The Public Identifier for this Notation. If no public identifier was - * specified, this will be null. - */ - public String getPublicId() { - return publicId; - } // getPublicId():String - - /** - * The System Identifier for this Notation. If no system identifier was - * specified, this will be null. - */ - public String getSystemId() { - return systemId; - } // getSystemId():String - - // - // Public methods - // - - /** - * NON-DOM: The Public Identifier for this Notation. If no public - * identifier was specified, this will be null. - */ - public void setPublicId(String id) { - publicId = id; - } // setPublicId(String) - - /** - * NON-DOM: The System Identifier for this Notation. If no system - * identifier was specified, this will be null. - */ - public void setSystemId(String id) { - systemId = id; - } // setSystemId(String) - -} // class NotationImpl diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/StringParser.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/StringParser.java deleted file mode 100644 index 6a51cdc72c..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/StringParser.java +++ /dev/null @@ -1,449 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -/** - * Reader for processing/parsing xml string - * - * @version - */ -public class StringParser { - String fData = null; - int fEndOffset; - int fMostRecentChar; - int fCurrentOffset; - boolean fCalledCharPropInit = false; - - public StringParser(String data) { - fData = data; - fCurrentOffset = 0; - fEndOffset = fData.length(); - fMostRecentChar = fEndOffset == 0 ? -1 : fData.charAt(0); - } - - public String getString(int offset, int length) { - if (length == 0) - return ""; //$NON-NLS-1$ - return fData.substring(offset, offset + length); - } - - public String getData() { - return fData; - } - - public String getRemainingString() { - return fData.substring(getCurrentOffset()); - } - - public int getCurrentOffset() { - return fCurrentOffset; - } - - // - // - public int loadNextChar() { - if (++fCurrentOffset >= fEndOffset) { - fMostRecentChar = -1; - } - else { - fMostRecentChar = fData.charAt(fCurrentOffset); - } - return fMostRecentChar; - } - - // - // - public boolean lookingAtChar(char chr, boolean skipPastChar) { - int ch = fMostRecentChar; - if (ch != chr) { - return false; - } - if (skipPastChar) { - if (++fCurrentOffset >= fEndOffset) { - fMostRecentChar = -1; - } - else { - fMostRecentChar = fData.charAt(fCurrentOffset); - } - } - return true; - } - - // - // - // - public boolean lookingAtValidChar(boolean skipPastChar) { - int ch = fMostRecentChar; - if (ch < 0xD800) { - if (ch < 0x20 && ch != 0x09 && ch != 0x0A && ch != 0x0D) { - return false; - } - if (skipPastChar) { - if (++fCurrentOffset >= fEndOffset) { - fMostRecentChar = -1; - } - else { - fMostRecentChar = fData.charAt(fCurrentOffset); - } - } - return true; - } - if (ch > 0xFFFD) { - return false; - } - if (ch < 0xDC00) { - if (fCurrentOffset + 1 >= fEndOffset) { - return false; - } - ch = fData.charAt(fCurrentOffset + 1); - if (ch < 0xDC00 || ch >= 0xE000) { - return false; - } - else if (!skipPastChar) { - return true; - } - else { - fCurrentOffset++; - } - } - else if (ch < 0xE000) { - return false; - } - if (skipPastChar) { - if (++fCurrentOffset >= fEndOffset) { - fMostRecentChar = -1; - } - else { - fMostRecentChar = fData.charAt(fCurrentOffset); - } - } - return true; - } - - // - // - // - public boolean lookingAtSpace(boolean skipPastChar) { - int ch = fMostRecentChar; - if (ch > 0x20) - return false; - if (ch == 0x20 || ch == 0x0A || ch == 0x0D || ch == 0x09) { - if (skipPastChar) { - loadNextChar(); - } - return true; - } - return false; - } - - // - // - // - public void skipToChar(char chr, boolean skipPastChar) { - // - // REVISIT - this will skip invalid characters without reporting them. - // - int ch = fMostRecentChar; - while (true) { - if (ch == chr) { - if (skipPastChar) { - loadNextChar(); - } - return; - } - if (ch == -1) { - return; - } - ch = loadNextChar(); - } - } - - // - // - // - public void skipPastSpaces() { - int ch = fMostRecentChar; - if (ch == -1) { - // changeReaders().skipPastSpaces(); - return; - } - while (true) { - if (ch > 0x20 || (ch != 0x20 && ch != 0x0A && ch != 0x09 && ch != 0x0D)) { - fMostRecentChar = ch; - return; - } - if (++fCurrentOffset >= fEndOffset) { - return; - } - ch = fData.charAt(fCurrentOffset); - } - } - - // - // - // - - public void skipPastNameAndPEReference(char fastcheck) { - int ch = fMostRecentChar; - - if (ch != '%') { - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiInitialNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_InitialNameCharFlag) == 0) - return; - } - } - while (true) { - ch = loadNextChar(); - if (fastcheck == ch) - return; - if (ch == '%' || ch == ';') { - continue; - } - - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_NameCharFlag) == 0) - return; - } - } - } - - public void skipPastName(char fastcheck) { - int ch = fMostRecentChar; - // System.out.println("skippastName ch: " +ch); - - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiInitialNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_InitialNameCharFlag) == 0) - return; - } - - while (true) { - ch = loadNextChar(); - if (fastcheck == ch) - return; - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_NameCharFlag) == 0) - return; - } - } - } - - // - // - // - - public void skipPastNmtoken(char fastcheck) { - int ch = fMostRecentChar; - while (true) { - if (fastcheck == ch) - return; - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_NameCharFlag) == 0) - return; - } - ch = loadNextChar(); - } - } - - public void skipPastNmtokenAndPEReference(char fastcheck) { - int ch = fMostRecentChar; - while (true) { - if (fastcheck == ch) - return; - if (ch == '%' || ch == ';') { - ch = loadNextChar(); - continue; - } - if (ch < 0x80) { - if (ch == -1 || XMLCharacterProperties.fgAsciiNameChar[ch] == 0) - return; - } - else { - if (!fCalledCharPropInit) { - XMLCharacterProperties.initCharFlags(); - fCalledCharPropInit = true; - } - if ((XMLCharacterProperties.fgCharFlags[ch] & XMLCharacterProperties.E_NameCharFlag) == 0) - return; - } - ch = loadNextChar(); - } - } - - // - // - // - public boolean skippedString(char[] s) { - int ch = fMostRecentChar; - if (ch != s[0]) { - return false; - } - if (fCurrentOffset + s.length > fEndOffset) - return false; - for (int i = 1; i < s.length; i++) { - if (fData.charAt(fCurrentOffset + i) != s[i]) - return false; - } - fCurrentOffset += (s.length - 1); - loadNextChar(); - return true; - } - - // - // - // - public int scanInvalidChar() throws Exception { - int ch = fMostRecentChar; - loadNextChar(); - return ch; - } - - // - // - // - /* - * public int scanCharRef(boolean hex) throws Exception { int ch = - * fMostRecentChar; if (ch == -1) // return - * changeReaders().scanCharRef(hex); return ch; int num = 0; if (hex) { if - * (ch > 'f' || XMLCharacterProperties.fgAsciiXDigitChar[ch] == 0) return - * XMLEntityHandler.CHARREF_RESULT_INVALID_CHAR; num = ch - (ch < 'A' ? - * '0' : (ch < 'a' ? 'A' : 'a') - 10); } else { if (ch < '0' || ch > '9') - * return XMLEntityHandler.CHARREF_RESULT_INVALID_CHAR; num = ch - '0'; } - * boolean toobig = false; while (true) { ch = loadNextChar(); if (ch == - * -1) return XMLEntityHandler.CHARREF_RESULT_SEMICOLON_REQUIRED; if (hex) { - * if (ch > 'f' || XMLCharacterProperties.fgAsciiXDigitChar[ch] == 0) - * break; } else { if (ch < '0' || ch > '9') break; } if (hex) { int dig = - * ch - (ch < 'A' ? '0' : (ch < 'a' ? 'A' : 'a') - 10); num = (num << 4) + - * dig; } else { int dig = ch - '0'; num = (num * 10) + dig; } if (num > - * 0x10FFFF) { toobig = true; num = 0; } } if (ch != ';') return - * XMLEntityHandler.CHARREF_RESULT_SEMICOLON_REQUIRED; loadNextChar(); if - * (toobig) return XMLEntityHandler.CHARREF_RESULT_OUT_OF_RANGE; return - * num; } - */ - // - // - // - /* - * public int scanStringLiteral() throws Exception { boolean single; if - * (!(single = lookingAtChar('\'', true)) && !lookingAtChar('\"', true)) { - * return XMLEntityHandler.STRINGLIT_RESULT_QUOTE_REQUIRED; } int offset = - * fCurrentOffset; char qchar = single ? '\'' : '\"'; while - * (!lookingAtChar(qchar, false)) { if (!lookingAtValidChar(true)) { - * return XMLEntityHandler.STRINGLIT_RESULT_INVALID_CHAR; } } // int - * stringIndex = addString(offset, fCurrentOffset - offset); int - * stringIndex = addString(offset, fCurrentOffset - offset); - * lookingAtChar(qchar, true); // move past qchar return stringIndex; } - */ - - // - // - public boolean scanAttValue(char qchar) { - boolean result = true; - while (true) { - if (lookingAtChar(qchar, false)) { - break; - } - if (lookingAtChar(' ', true)) { - continue; - } - if (!lookingAtValidChar(true)) { - result = false; - } - } - lookingAtChar(qchar, true); - return result; - } - - // - // [9] EntityValue ::= '"' ([^%&"] | PEReference | Reference)* '"' - // | "'" ([^%&'] | PEReference | Reference)* "'" - // - // The values in the following table are defined as: - // - // 0 - not special - // 1 - quote character - // 2 - reference - // 3 - peref - // 4 - invalid - // - public static final byte fgAsciiEntityValueChar[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 4, 4, 0, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 1, 0, 0, 3, 2, 1, 0, 0, 0, 0, 0, 0, 0, 0, // '\"', - // '%', - // '&', - // '\'' - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - - /* - * public int scanEntityValue(int qchar, boolean createString) throws - * Exception { int offset = fCurrentOffset; int ch = fMostRecentChar; - * while (true) { if (ch == -1) { changeReaders(); // do not call next - * reader, our caller may need to change the parameters return - * XMLEntityHandler.ENTITYVALUE_RESULT_END_OF_INPUT; } if (ch < 0x80) { - * switch (fgAsciiEntityValueChar[ch]) { case 1: // quote char if (ch == - * qchar) { if (!createString) return - * XMLEntityHandler.ENTITYVALUE_RESULT_FINISHED; int length = - * fCurrentOffset - offset; int result = length == 0 ? - * StringPool.EMPTY_STRING : addString(offset, length); loadNextChar(); - * return result; } // the other quote character is not special // fall - * through case 0: // non-special char if (++fCurrentOffset >= fEndOffset) { - * if (oweTrailingSpace) { oweTrailingSpace = false; ch = fMostRecentChar = ' '; } - * else { ch = fMostRecentChar = -1; } } else { ch = fMostRecentChar = - * fData.charAt(fCurrentOffset); } continue; case 2: // reference return - * XMLEntityHandler.ENTITYVALUE_RESULT_REFERENCE; case 3: // peref return - * XMLEntityHandler.ENTITYVALUE_RESULT_PEREF; case 4: // invalid return - * XMLEntityHandler.ENTITYVALUE_RESULT_INVALID_CHAR; } } else if (ch < - * 0xD800) { ch = loadNextChar(); } else if (ch >= 0xE000 && (ch <= 0xFFFD || - * (ch >= 0x10000 && ch <= 0x10FFFF))) { // // REVISIT - needs more code - * to check surrogates. // ch = loadNextChar(); } else { return - * XMLEntityHandler.ENTITYVALUE_RESULT_INVALID_CHAR; } } } - */ - - -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/TString.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/TString.java deleted file mode 100644 index fae6f7ab02..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/TString.java +++ /dev/null @@ -1,350 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ - -package org.eclipse.wst.dtd.core.internal.saxparser; - -import java.util.StringTokenizer; - -/** - * This class provides static methods for some of the very used IString - * operations - */ - -public class TString { - private static final String ALPHABET = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$ - private static final String ALPHANUMERIC = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; //$NON-NLS-1$ - private static final String NUMERIC = "0123456789"; //$NON-NLS-1$ - - // change all occurrences of oldPat to newPat - public static String change(String in, String oldPat, String newPat) { - if (oldPat.length() == 0) - return in; - if (oldPat.length() == 1 && newPat.length() == 1) - return in.replace(oldPat.charAt(0), newPat.charAt(0)); - - int lastIndex = 0; - int newIndex = 0; - StringBuffer newString = new StringBuffer(); - for (;;) { - newIndex = in.indexOf(oldPat, lastIndex); - if (newIndex != -1) { - newString.append(in.substring(lastIndex, newIndex) + newPat); - lastIndex = newIndex + oldPat.length(); - } - else { - newString.append(in.substring(lastIndex)); - break; - } - } - return newString.toString(); - } - - // change the occurrences of oldPat to newPat starting at startPosition - // for number of numChanges - // Note: the 1st char in the string has position of 0 - - public static String change(String in, String oldPat, String newPat, int startPos, int numChanges) { - if (oldPat.length() == 0) - return in; - if (oldPat.length() == 1 && newPat.length() == 1) - return in.replace(oldPat.charAt(0), newPat.charAt(0)); - - int inLen = in.length(); - - if (startPos >= inLen) - return in; - - int lastIndex = startPos; - int newIndex = 0; - int countChanges = 0; - - - StringBuffer newString = new StringBuffer(); - - for (;;) { - newIndex = in.indexOf(oldPat, lastIndex); - if (newIndex != -1) { - newString.append(in.substring(lastIndex, newIndex) + newPat); - lastIndex = newIndex + oldPat.length(); - countChanges++; - } - else { - newString.append(in.substring(lastIndex)); - break; - } - - if (countChanges == numChanges) { - newString.append(in.substring(lastIndex)); - break; - } - } - - return newString.toString(); - } - - public static String word(String in, int i) { - StringTokenizer st = new StringTokenizer(in); - if (i <= 0 || i > st.countTokens()) - return ""; //$NON-NLS-1$ - else { - String ret = new String(); - while (st.hasMoreTokens()) { - ret = st.nextToken(); - if (--i == 0) - return ret; - } - } - return ""; //$NON-NLS-1$ - } - - public static String words(String in, int i) { - StringTokenizer st = new StringTokenizer(in); - if (i <= 0 || i > st.countTokens()) - return ""; //$NON-NLS-1$ - else { - while (st.hasMoreTokens()) { - if (--i == 0) - break; - st.nextToken(); - } - if (st.hasMoreTokens()) - return st.nextToken(""); //$NON-NLS-1$ - else - return ""; //$NON-NLS-1$ - } - } - - public static String appendSpaces(String in, int len) { - if (len < 1) - return in; - - StringBuffer sb = new StringBuffer(in); - for (int i = 0; i < len; i++) { - sb.append(" "); //$NON-NLS-1$ - } - return sb.toString(); - } - - public static int numWords(String in) { - StringTokenizer st = new StringTokenizer(in); - return st.countTokens(); - } - - // return the first index within srcString that is not in the validString - // example: - // srcString = "abcdefg" - // validString = "bcfg" - // return = 0 (i.e. char a is not in "bcfg") - 1st index = 0 - - public static int indexOfAnyBut(String srcString, String validString) { - int result = -1; - int srcLen = srcString.length(); - - // walk backward to find if a char within srcString is in validString - for (int i = 0; i < srcLen; i++) { - // not found, stop it - if (validString.indexOf(srcString.charAt(i)) == -1) { - result = i; - break; - } - - } - - return result; - } - - // return the last index within srcString that is not in the validString - // example: - // srcString = "abcdefg" - // validString = "bcfg" - // return = 4 (i.e. char e is not in "bcfg") - 1st index = 0 - - public static int lastIndexOfAnyBut(String srcString, String validString) { - int result = -1; - int srcLen = srcString.length(); - - // walk backward to find if a char within srcString is in validString - for (int i = srcLen - 1; i >= 0; i--) { - // not found, stop it - if (validString.indexOf(srcString.charAt(i)) == -1) { - result = i; - break; - } - - } - - return result; - } - - // return number of occurrences of searchChar within srcString - // example: - // srcString = "::f::f::g" - // seachrChar = ':' - // return = 6 - - public static int occurrenceOf(String srcString, char searchChar) { - int result = 0; - // walk backward to find if a char within srcString is in validString - if (srcString.length() > 0) { - - for (int i = 0; i < srcString.length(); i++) { - // found, increment the count - if (searchChar == srcString.charAt(i)) - result++; - } - } - - return result; - } - - // strip the leading pString in the srcString - // example: - // srcString = "::f::f::g" - // pString "::" - // return = "f::f::g" - - public static String stripLeading(String srcString, String pString) { - String result; - - if (srcString.startsWith(pString)) // leading patString found - result = srcString.substring(pString.length(), srcString.length()); - else - // not found - result = srcString; - - return result; - } - - // strip the trailing pString in the srcString - // example: - // srcString = "f::f::g::" - // pString "::" - // return = "f::f::g" - - public static String stripTrailing(String srcString, String pString) { - String result; - - if (srcString.endsWith(pString)) // leading patString found - result = srcString.substring(0, srcString.lastIndexOf(pString)); - else - // not found - result = srcString; - - return result; - } - - /** - * strip the trailing blanks in the src - */ - public static String stripTrailingBlanks(String src) { - - if (src != null) { - while (src.length() > 0) { - if (src.endsWith(" ")) //$NON-NLS-1$ - src = src.substring(0, src.length() - 1); - else - break; - } - } - - return src; - } - - - - // return a string that contains number of copies of srcString - // example: - // srcString = "abc" - // numberOfCopies = 2 - // return string = "abcabc" - - public static String copy(String srcString, int numberOfCopies) { - StringBuffer result = new StringBuffer(); - - if (numberOfCopies > 0) { - for (int i = 1; i <= numberOfCopies; i++) - result.append(srcString); - } - else - result = new StringBuffer(srcString); - - return result.toString(); - } - - // - // return true if all chars in srcString are in {a...z} or {A...Z} - - public static boolean isAlphabetic(String srcString) { - return (lastIndexOfAnyBut(srcString, ALPHABET) == -1); - } - - // - // return true if all chars in srcString are in {a...z,} or {A...Z} - // {0...9} - - public static boolean isAlphanumeric(String srcString) { - return (lastIndexOfAnyBut(srcString, ALPHANUMERIC) == -1); - } - - - // - // return true if all chars are in '0' - '9' - - public static boolean isDigits(String srcString) { - return (lastIndexOfAnyBut(srcString, NUMERIC) == -1); - } - - - public static boolean isEmptyOrNull(String string) { - return string == null || string.length() == 0; - } - - - // - // return the string after the matching token is removed - public static String match(String in, String token) throws Exception { - if (in == null) - return null; - - in = in.trim(); - if (in.startsWith(token)) - return in.substring(token.length(), in.length()); - else - throw new Exception("Expected: " + token + " but got:" + word(in, 1)); //$NON-NLS-1$ //$NON-NLS-2$ - } - - public static long getLong(String str) { - try { - return Long.parseLong(str); - } - catch (Exception m) { - return 0; - } - } - - // return true if the " " appears within srcString - // example: - // srcString = "a m" - // return = true - - public static boolean containsDoubleBlanks(String srcString) { - String bb = " "; //$NON-NLS-1$ - char b = bb.charAt(0); - - if (srcString.length() > 0) { - for (int i = 0; i < (srcString.length() - 1); i++) { - if ((b == srcString.charAt(i)) & (b == srcString.charAt(i + 1))) - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/XMLCharacterProperties.java b/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/XMLCharacterProperties.java deleted file mode 100644 index c7d2f325c7..0000000000 --- a/bundles/org.eclipse.wst.dtd.core/saxparser/org/eclipse/wst/dtd/core/internal/saxparser/XMLCharacterProperties.java +++ /dev/null @@ -1,448 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2001, 2004 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.wst.dtd.core.internal.saxparser; - -/** - * A class representing properties of characters according to various W3C - * recommendations - * - * XMLCharacterProperties provides convenience methods for commonly used - * character tests. - * - * For performance reasons, the tables used by the convenience methods are - * also public, and are directly accessed by performance critical routines. - * - */ - -public final class XMLCharacterProperties { - /* - * [26] VersionNum ::= ([a-zA-Z0-9_.:] | '-')+ - * - * Note: This is the same as the ascii portion of the NameChar definition. - */ - /** - * Check to see if a string is a valid version string according to [26] in - * the XML 1.0 Recommendation - * - * @param version - * string to check - * @return true if version is a valid version string - */ - public static boolean validVersionNum(String version) { - if (version.length() == 0) - return false; - for (int i = 0; i < version.length(); i++) { - char ch = version.charAt(i); - if (ch > 'z' || fgAsciiNameChar[ch] == 0) - return false; - } - return true; - } - - /* - * [81] EncName ::= [A-Za-z] ([A-Za-z0-9._] | '-')* - */ - /** - * Check to see if a string is a valid encoding name according to [81] in - * the XML 1.0 Recommendation - * - * @param encoding - * string to check - * @return true if encoding is a valid encoding name - */ - public static boolean validEncName(String encoding) { - if (encoding.length() == 0) - return false; - char ch = encoding.charAt(0); - if (ch > 'z' || fgAsciiAlphaChar[ch] == 0) - return false; - for (int i = 1; i < encoding.length(); i++) { - ch = encoding.charAt(i); - if (ch > 'z' || fgAsciiEncNameChar[ch] == 0) - return false; - } - return true; - } - - /* - * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | - * [-'()+,./:=?;!*#@$_%] - */ - /** - * Check to see if a string is a valid public identifier according to [13] - * in the XML 1.0 Recommendation - * - * @param publicId - * string to check - * @return true if publicId is a valid public identifier - */ - public static int validPublicId(String publicId) { - if (publicId.length() == 0) - return -1; - for (int i = 0; i < publicId.length(); i++) { - char ch = publicId.charAt(i); - if (ch > 'z' || fgAsciiPubidChar[ch] == 0) - return i; - } - return -1; - } - - /* - * [5] Name ::= (Letter | '_' | ':') (NameChar)* - */ - /** - * Check to see if a string is a valid Name according to [5] in the XML - * 1.0 Recommendation - * - * @param name - * string to check - * @return true if name is a valid Name - */ - public static boolean validName(String name) { - XMLCharacterProperties.initCharFlags(); - if (name.length() == 0) - return false; - char ch = name.charAt(0); - if (ch > 'z') { - if ((fgCharFlags[ch] & E_InitialNameCharFlag) == 0) - return false; - } - else if (fgAsciiInitialNameChar[ch] == 0) - return false; - for (int i = 1; i < name.length(); i++) { - ch = name.charAt(i); - if (ch > 'z') { - if ((fgCharFlags[ch] & E_NameCharFlag) == 0) - return false; - } - else if (fgAsciiNameChar[ch] == 0) - return false; - } - return true; - } - - /* - * from the namespace rec [5] NCName ::= (Letter | '_' | ':') - * (NameNCChar)* - */ - /** - * Check to see if a string is a valid NCName according to [5] from the - * XML Namespaces 1.0 Recommendation - * - * @param name - * string to check - * @return true if name is a valid NCName - */ - public static boolean validNCName(String name) { - XMLCharacterProperties.initCharFlags(); - if (name.length() == 0) - return false; - char ch = name.charAt(0); - if (ch > 'z') { - if ((fgCharFlags[ch] & E_InitialNameCharFlag) == 0) - return false; - } - else if (fgAsciiInitialNCNameChar[ch] == 0) - return false; - for (int i = 1; i < name.length(); i++) { - ch = name.charAt(i); - if (ch > 'z') { - if ((fgCharFlags[ch] & E_NameCharFlag) == 0) - return false; - } - else if (fgAsciiNCNameChar[ch] == 0) - return false; - } - return true; - } - - - /* - * [7] Nmtoken ::= (NameChar)+ - */ - /** - * Check to see if a string is a valid Nmtoken according to [7] in the XML - * 1.0 Recommendation - * - * @param nmtoken - * string to checj - * @return true if nmtoken is a valid Nmtoken - */ - public static boolean validNmtoken(String nmtoken) { - XMLCharacterProperties.initCharFlags(); - if (nmtoken.length() == 0) - return false; - for (int i = 0; i < nmtoken.length(); i++) { - char ch = nmtoken.charAt(i); - if (ch > 'z') { - if ((fgCharFlags[ch] & E_NameCharFlag) == 0) - return false; - } - else if (fgAsciiNameChar[ch] == 0) { - return false; - } - } - return true; - } - - /* - * Here are tables used to build character properties. - */ - public static final byte fgAsciiXDigitChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // '0' - // - - // '9' - 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 'A' - 'F' - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 'a' - // - - // 'f' - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - public static final byte fgAsciiAlphaChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - // - - // 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // 'P' - 'Z' - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiEncNameChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, // '-' - // is - // 0x2D - // and - // '.' - // is - // 0x2E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // '0' - '9' - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiPubidChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 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, 0, 1, // '0' - '9', - // ':', ';', - // '=', '?' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // '@', 'A' - - // 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiInitialNameChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, // ':' - // is - // 0x3A - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiNameChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, // '-' - // is - // 0x2D - // and - // '.' - // is - // 0x2E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, // '0' - '9' - // and ':' is - // 0x3A - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiInitialNCNameChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ':' - // is - // 0x3A - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiNCNameChar[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, // '-' - // is - // 0x2D - // and - // '.' - // is - // 0x2E - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, // '0' - '9' - // and ':' is - // 0x3A - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'A' - 'O' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, // 'P' - 'Z' - // and '_' is - // 0x5F - 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 'a' - 'o' - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0 // 'p' - 'z' - }; - public static final byte fgAsciiCharData[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 4, 4, 4, 4, 4, 4, // tab - // is - // 0x09 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, // '&' - // is - // 0x26 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // '<' is 0x3C - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, // ']' - // is - // 0x5D - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - public static final byte fgAsciiWSCharData[] = {4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 4, 4, 5, 4, 4, // tab - // is - // 0x09, - // LF - // is - // 0x0A, - // CR - // is - // 0x0D - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, // ' ' - // is - // 0x20, - // '&' - // is - // 0x26 - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, // '<' is 0x3C - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, // ']' - // is - // 0x5D - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; - public static final byte E_CharDataFlag = 1 << 0; - public static final byte E_InitialNameCharFlag = 1 << 1; - public static final byte E_NameCharFlag = 1 << 2; - public static byte[] fgCharFlags = null; - - public static synchronized void initCharFlags() { - if (fgCharFlags == null) { - fgCharFlags = new byte[0x10000]; - setFlagForRange(fgCharDataRanges, E_CharDataFlag); - setFlagForRange(fgInitialNameCharRanges, (byte) (E_InitialNameCharFlag | E_NameCharFlag)); - setFlagForRange(fgNameCharRanges, E_NameCharFlag); - } - } - - private static void setFlagForRange(char[] ranges, byte flag) { - int i; - int ch; - for (i = 0; (ch = ranges[i]) != 0; i += 2) { - int endch = ranges[i + 1]; - while (ch <= endch) - fgCharFlags[ch++] |= flag; - } - for (i++; (ch = ranges[i]) != 0; i++) - fgCharFlags[ch] |= flag; - } - - /* - * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] // any Unicode character, - * excluding the | [#xE000-#xFFFD] | [#x10000-#x10FFFF] // surrogate - * blocks, FFFE, and FFFF. [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) - * - * We will use Char - ( [^<&] | ']' | #xA | #xD ) and handle the special - * cases inline. - */ - private static final char fgCharDataRanges[] = {0x0020, 0x0025, // '&' is - // 0x0026 - 0x0027, 0x003B, // '<' is 0x003C - 0x003D, 0x005C, // ']' is 0x005D - 0x005E, 0xD7FF, 0xE000, 0xFFFD, 0x0000, 0x0009, // tab - 0x0000}; - /* - * [5] Name ::= (Letter | '_' | ':') (NameChar)* [4] NameChar ::= Letter | - * Digit | '.' | '-' | '_' | ':' | CombiningChar | Extender [84] Letter - * ::= BaseChar | Ideographic [85] BaseChar ::= <see standard> [86] - * Ideographic ::= <see standard> [87] CombiningChar ::= <see standard> - * [88] Digit ::= <see standard> [89] Extender ::= <see standard> - */ - private static final char fgInitialNameCharRanges[] = { - // - // Ranges: - // - // BaseChar ranges - // - 0x0041, 0x005A, 0x0061, 0x007A, 0x00C0, 0x00D6, 0x00D8, 0x00F6, 0x00F8, 0x0131, 0x0134, 0x013E, 0x0141, 0x0148, 0x014A, 0x017E, 0x0180, 0x01C3, 0x01CD, 0x01F0, 0x01F4, 0x01F5, 0x01FA, 0x0217, 0x0250, 0x02A8, 0x02BB, 0x02C1, 0x0388, 0x038A, 0x038E, 0x03A1, 0x03A3, 0x03CE, 0x03D0, 0x03D6, 0x03E2, 0x03F3, 0x0401, 0x040C, 0x040E, 0x044F, 0x0451, 0x045C, 0x045E, 0x0481, 0x0490, 0x04C4, 0x04C7, 0x04C8, 0x04CB, 0x04CC, 0x04D0, 0x04EB, 0x04EE, 0x04F5, 0x04F8, 0x04F9, 0x0531, 0x0556, 0x0561, 0x0586, 0x05D0, 0x05EA, 0x05F0, 0x05F2, 0x0621, 0x063A, 0x0641, 0x064A, 0x0671, 0x06B7, 0x06BA, 0x06BE, 0x06C0, 0x06CE, 0x06D0, 0x06D3, 0x06E5, 0x06E6, 0x0905, 0x0939, 0x0958, 0x0961, 0x0985, 0x098C, 0x098F, 0x0990, 0x0993, 0x09A8, 0x09AA, 0x09B0, 0x09B6, 0x09B9, 0x09DC, 0x09DD, 0x09DF, 0x09E1, 0x09F0, 0x09F1, 0x0A05, 0x0A0A, 0x0A0F, 0x0A10, 0x0A13, 0x0A28, 0x0A2A, 0x0A30, 0x0A32, 0x0A33, 0x0A35, 0x0A36, 0x0A38, 0x0A39, 0x0A59, 0x0A5C, 0x0A72, 0x0A74, 0x0A85, 0x0A8B, 0x0A8F, 0x0A91, - 0x0A93, 0x0AA8, 0x0AAA, 0x0AB0, 0x0AB2, 0x0AB3, 0x0AB5, 0x0AB9, 0x0B05, 0x0B0C, 0x0B0F, 0x0B10, 0x0B13, 0x0B28, 0x0B2A, 0x0B30, 0x0B32, 0x0B33, 0x0B36, 0x0B39, 0x0B5C, 0x0B5D, 0x0B5F, 0x0B61, 0x0B85, 0x0B8A, 0x0B8E, 0x0B90, 0x0B92, 0x0B95, 0x0B99, 0x0B9A, 0x0B9E, 0x0B9F, 0x0BA3, 0x0BA4, 0x0BA8, 0x0BAA, 0x0BAE, 0x0BB5, 0x0BB7, 0x0BB9, 0x0C05, 0x0C0C, 0x0C0E, 0x0C10, 0x0C12, 0x0C28, 0x0C2A, 0x0C33, 0x0C35, 0x0C39, 0x0C60, 0x0C61, 0x0C85, 0x0C8C, 0x0C8E, 0x0C90, 0x0C92, 0x0CA8, 0x0CAA, 0x0CB3, 0x0CB5, 0x0CB9, 0x0CE0, 0x0CE1, 0x0D05, 0x0D0C, 0x0D0E, 0x0D10, 0x0D12, 0x0D28, 0x0D2A, 0x0D39, 0x0D60, 0x0D61, 0x0E01, 0x0E2E, 0x0E32, 0x0E33, 0x0E40, 0x0E45, 0x0E81, 0x0E82, 0x0E87, 0x0E88, 0x0E94, 0x0E97, 0x0E99, 0x0E9F, 0x0EA1, 0x0EA3, 0x0EAA, 0x0EAB, 0x0EAD, 0x0EAE, 0x0EB2, 0x0EB3, 0x0EC0, 0x0EC4, 0x0F40, 0x0F47, 0x0F49, 0x0F69, 0x10A0, 0x10C5, 0x10D0, 0x10F6, 0x1102, 0x1103, 0x1105, 0x1107, 0x110B, 0x110C, 0x110E, 0x1112, 0x1154, 0x1155, 0x115F, 0x1161, 0x116D, 0x116E, - 0x1172, 0x1173, 0x11AE, 0x11AF, 0x11B7, 0x11B8, 0x11BC, 0x11C2, 0x1E00, 0x1E9B, 0x1EA0, 0x1EF9, 0x1F00, 0x1F15, 0x1F18, 0x1F1D, 0x1F20, 0x1F45, 0x1F48, 0x1F4D, 0x1F50, 0x1F57, 0x1F5F, 0x1F7D, 0x1F80, 0x1FB4, 0x1FB6, 0x1FBC, 0x1FC2, 0x1FC4, 0x1FC6, 0x1FCC, 0x1FD0, 0x1FD3, 0x1FD6, 0x1FDB, 0x1FE0, 0x1FEC, 0x1FF2, 0x1FF4, 0x1FF6, 0x1FFC, 0x212A, 0x212B, 0x2180, 0x2182, 0x3041, 0x3094, 0x30A1, 0x30FA, 0x3105, 0x312C, 0xAC00, 0xD7A3, - // - // Ideographic ranges - // - 0x3021, 0x3029, 0x4E00, 0x9FA5, - // - // Ranges end marker - // - 0x0000, - // - // Single char values - // - 0x003A, // ':' - 0x005F, // '_' - // - // BaseChar singles - // - 0x0386, 0x038C, 0x03DA, 0x03DC, 0x03DE, 0x03E0, 0x0559, 0x06D5, 0x093D, 0x09B2, 0x0A5E, 0x0A8D, 0x0ABD, 0x0AE0, 0x0B3D, 0x0B9C, 0x0CDE, 0x0E30, 0x0E84, 0x0E8A, 0x0E8D, 0x0EA5, 0x0EA7, 0x0EB0, 0x0EBD, 0x1100, 0x1109, 0x113C, 0x113E, 0x1140, 0x114C, 0x114E, 0x1150, 0x1159, 0x1163, 0x1165, 0x1167, 0x1169, 0x1175, 0x119E, 0x11A8, 0x11AB, 0x11BA, 0x11EB, 0x11F0, 0x11F9, 0x1F59, 0x1F5B, 0x1F5D, 0x1FBE, 0x2126, 0x212E, - // - // Ideographic singles - // - 0x3007, - // - // Singles end marker - // - 0x0000}; - private static final char fgNameCharRanges[] = { - // - // Ranges: - // - 0x002D, 0x002E, // '-' and '.' - // - // CombiningChar ranges - // - 0x0300, 0x0345, 0x0360, 0x0361, 0x0483, 0x0486, 0x0591, 0x05A1, 0x05A3, 0x05B9, 0x05BB, 0x05BD, 0x05C1, 0x05C2, 0x064B, 0x0652, 0x06D6, 0x06DC, 0x06DD, 0x06DF, 0x06E0, 0x06E4, 0x06E7, 0x06E8, 0x06EA, 0x06ED, 0x0901, 0x0903, 0x093E, 0x094C, 0x0951, 0x0954, 0x0962, 0x0963, 0x0981, 0x0983, 0x09C0, 0x09C4, 0x09C7, 0x09C8, 0x09CB, 0x09CD, 0x09E2, 0x09E3, 0x0A40, 0x0A42, 0x0A47, 0x0A48, 0x0A4B, 0x0A4D, 0x0A70, 0x0A71, 0x0A81, 0x0A83, 0x0ABE, 0x0AC5, 0x0AC7, 0x0AC9, 0x0ACB, 0x0ACD, 0x0B01, 0x0B03, 0x0B3E, 0x0B43, 0x0B47, 0x0B48, 0x0B4B, 0x0B4D, 0x0B56, 0x0B57, 0x0B82, 0x0B83, 0x0BBE, 0x0BC2, 0x0BC6, 0x0BC8, 0x0BCA, 0x0BCD, 0x0C01, 0x0C03, 0x0C3E, 0x0C44, 0x0C46, 0x0C48, 0x0C4A, 0x0C4D, 0x0C55, 0x0C56, 0x0C82, 0x0C83, 0x0CBE, 0x0CC4, 0x0CC6, 0x0CC8, 0x0CCA, 0x0CCD, 0x0CD5, 0x0CD6, 0x0D02, 0x0D03, 0x0D3E, 0x0D43, 0x0D46, 0x0D48, 0x0D4A, 0x0D4D, 0x0E34, 0x0E3A, 0x0E47, 0x0E4E, 0x0EB4, 0x0EB9, 0x0EBB, 0x0EBC, 0x0EC8, 0x0ECD, 0x0F18, 0x0F19, 0x0F71, 0x0F84, 0x0F86, 0x0F8B, - 0x0F90, 0x0F95, 0x0F99, 0x0FAD, 0x0FB1, 0x0FB7, 0x20D0, 0x20DC, 0x302A, 0x302F, - // - // Digit ranges - // - 0x0030, 0x0039, 0x0660, 0x0669, 0x06F0, 0x06F9, 0x0966, 0x096F, 0x09E6, 0x09EF, 0x0A66, 0x0A6F, 0x0AE6, 0x0AEF, 0x0B66, 0x0B6F, 0x0BE7, 0x0BEF, 0x0C66, 0x0C6F, 0x0CE6, 0x0CEF, 0x0D66, 0x0D6F, 0x0E50, 0x0E59, 0x0ED0, 0x0ED9, 0x0F20, 0x0F29, - // - // Extender ranges - // - 0x3031, 0x3035, 0x309D, 0x309E, 0x30FC, 0x30FE, - // - // Ranges end marker - // - 0x0000, - // - // Single char values - // - // CombiningChar singles - // - 0x05BF, 0x05C4, 0x0670, 0x093C, 0x094D, 0x09BC, 0x09BE, 0x09BF, 0x09D7, 0x0A02, 0x0A3C, 0x0A3E, 0x0A3F, 0x0ABC, 0x0B3C, 0x0BD7, 0x0D57, 0x0E31, 0x0EB1, 0x0F35, 0x0F37, 0x0F39, 0x0F3E, 0x0F3F, 0x0F97, 0x0FB9, 0x20E1, 0x3099, 0x309A, - // - // Extender singles - // - 0x00B7, 0x02D0, 0x02D1, 0x0387, 0x0640, 0x0E46, 0x0EC6, 0x3005, - // - // Singles end marker - // - 0x0000}; -} |