diff options
Diffstat (limited to 'bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml')
72 files changed, 7189 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java new file mode 100644 index 0000000000..8b388bd48c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/AttributeCollection.java @@ -0,0 +1,324 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + +/** + * Factory for attribute declarations. + */ +final class AttributeCollection extends CMNamedNodeMapImpl implements CHTMLNamespace { + /** + * constructor. + */ + public AttributeCollection() { + super(); + } + + /** + * Create an attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + * @param attrName java.lang.String + */ + private HTMLAttrDeclImpl create(String attrName) { + HTMLAttrDeclImpl attr = null; + HTMLCMDataTypeImpl atype = null; + + if (attrName.equalsIgnoreCase(ATTR_NAME_ACTION)) { + // (action %URI #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ACTION, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ALT)) { + // (alt %Text; #REQUIRED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.TEXT); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ALT, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_BORDER)) { + // (border %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_BORDER, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CHECKED)) { + // (checked (checked) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_CHECKED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_CHECKED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_CLEAR)) { + // (clear (left | all | right | none) none) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_ALL, ATTR_VALUE_RIGHT, ATTR_VALUE_NONE}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_NONE); + + attr = new HTMLAttrDeclImpl(ATTR_NAME_CLEAR, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_COLS)) { + // (cols NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_COLS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ENCTYPE)) { + // (enctype %ContentType; "application/x-www-form-urlencoded") + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_WWW_FORM_URLENCODED); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ENCTYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HEIGHT)) { + // (height %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HEIGHT, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HREF)) { + // (href %URI; #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HREF, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HSPACE)) { + // (hspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_HTTP_EQUIV)) { + // (http-equiv NAME #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + attr = new HTMLAttrDeclImpl(ATTR_NAME_HTTP_EQUIV, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MAXLENGTH)) { + // (maxlength NUMBER #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MAXLENGTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_METHOD)) { + // (method (GET|POST) GET) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_VALUE_GET, ATTR_VALUE_POST}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, ATTR_VALUE_GET); + attr = new HTMLAttrDeclImpl(ATTR_NAME_METHOD, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_MULTIPLE)) { + // (multiple (multiple) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_MULTIPLE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_MULTIPLE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NAME)) { + // (name CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_NOSHADE)) { + // (noshade (noshade) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_NOSHADE}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_NOSHADE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_ROWS)) { + // (rows NUMBER #REQUIRED) + atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + attr = new HTMLAttrDeclImpl(ATTR_NAME_ROWS, atype, CMAttributeDeclaration.REQUIRED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SELECTED)) { + // (selected (selected) #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {ATTR_NAME_SELECTED}; + atype.setEnumValues(values); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SELECTED, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SIZE)) { + // (size %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_SRC)) { + // (src %URI; #IMPLIED) + // NOTE: "src" attributes are defined in several elements. + // The definition of IMG is different from others. + // So, it should be locally defined. + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(ATTR_NAME_SRC, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_TYPE)) { + // (type %CotentType; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.CONTENT_TYPE); + attr = new HTMLAttrDeclImpl(ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VALUE)) { + // (value CDATA #IMPLIED) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VALUE, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VERSION)) { + // (version CDATA #FIXED '%HTML.Version;) + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_FIXED, ATTR_VALUE_VERSION_TRANSITIONAL); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VERSION, atype, CMAttributeDeclaration.FIXED); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_WIDTH)) { + // (width %Length; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.LENGTH); + attr = new HTMLAttrDeclImpl(ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + + } + else if (attrName.equalsIgnoreCase(ATTR_NAME_VSPACE)) { + // (vspace %Pixels; #IMPLIED) + atype = new HTMLCMDataTypeImpl(HTMLCMDataType.PIXELS); + attr = new HTMLAttrDeclImpl(ATTR_NAME_VSPACE, atype, CMAttributeDeclaration.OPTIONAL); + + // <<D205514 + } + else { + // unknown attribute; maybe error. + // should warn. + attr = null; + } + + return attr; + } + + /** + * Get %bodycolors; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getBodycolors(CMNamedNodeMapImpl declarations) { + } + + /** + * Get align attribute which has %IAlign; as values.. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public static final HTMLAttrDeclImpl createAlignForImage() { + // align (local) + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values + String[] values = {ATTR_VALUE_TOP, ATTR_VALUE_MIDDLE, ATTR_VALUE_BOTTOM, ATTR_VALUE_LEFT, ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Create an attribute declaration for <code>align</code> + * in several elements, like <code>P</code>, <code>DIV</code>. + * The values are different from attributes those have the same name + * in other elements (<code>IMG</code> and <code>TABLE</code>). + * So, it can't treat as global attributes. + * <strong>NOTE: These attribute declaration has + * no owner CMDocument instance.</strong> + * @return com.ibm.sed.contentmodel.html.HTMLAttrDeclImpl + */ + public static final HTMLAttrDeclImpl createAlignForParagraph() { + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + // set enum values: left|center|right|justify + String[] values = {ATTR_VALUE_LEFT, ATTR_VALUE_CENTER, ATTR_VALUE_RIGHT,}; + atype.setEnumValues(values); + + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + return attr; + } + + /** + * Get %attrs; declarations. + * %attrs; consists of %coreattrs;, %i18n, and %events;. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getAttrs(CMNamedNodeMapImpl declarations) { + } + + /** + * Get %coreattrs; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getCore(CMNamedNodeMapImpl declarations) { + } + + /** + * Get a global attribute declaration. + * @return com.ibm.sed.contentmodel.html.HTMLAttrributeDeclaration + * @param attrName java.lang.String + */ + public HTMLAttributeDeclaration getDeclaration(String attrName) { + CMNode cmnode = getNamedItem(attrName); + if (cmnode != null) + return (HTMLAttributeDeclaration) cmnode; // already exists. + + HTMLAttrDeclImpl dec = create(attrName); + if (dec != null) + putNamedItem(attrName, dec); + + return dec; + } + + /** + * Get declarations which are specified by names. + * @param declarations com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMNamedNodeMapImpl declarations, Iterator names) { + while (names.hasNext()) { + String attrName = (String) names.next(); + HTMLAttributeDeclaration dec = getDeclaration(attrName); + if (dec != null) + declarations.putNamedItem(attrName, dec); + } + } + + /** + * Get %events; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getEvents(CMNamedNodeMapImpl declarations) { + } + + /** + * Get %i18n; declarations. + * @param attributes com.ibm.sed.contentmodel.html.CMNamedNodeMapImpl + */ + public void getI18n(CMNamedNodeMapImpl declarations) { + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java new file mode 100644 index 0000000000..d191f98b40 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHCMDocImpl.java @@ -0,0 +1,95 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNamespace; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDocument; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLEntityDeclaration; + +/** + * CMDocument implementation for the HTML. + */ +public class CHCMDocImpl extends CMNodeImpl implements HTMLCMDocument { + + /** Namespace for all names of elements, entities and attributes. */ + private CMNamespace namespace = null; + private ElementCollection elements = null; + private EntityCollection entities = null; + private AttributeCollection attributes = null; + + /** + */ + public CHCMDocImpl(String docTypeName, CMNamespace targetNamespace) { + super(docTypeName); + namespace = targetNamespace; + attributes = new AttributeCollection(); + elements = new ElementCollection(attributes); + entities = new EntityCollection(); + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + AttributeCollection getAttributes() { + return attributes; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLElementDeclaration getElementDeclaration(String elementName) { + if (elements == null) + return null; + return (HTMLElementDeclaration) elements.getNamedItem(elementName); + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getElements() { + return elements; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public CMNamedNodeMap getEntities() { + return entities; + } + + /** + * @see com.ibm.sed.contentmodel.html.HTMLCMDocument + */ + public HTMLEntityDeclaration getEntityDeclaration(String entityName) { + if (entities == null) + return null; + return (HTMLEntityDeclaration) entities.getNamedItem(entityName); + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDocument + */ + public org.eclipse.wst.common.contentmodel.CMNamespace getNamespace() { + return namespace; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DOCUMENT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java new file mode 100644 index 0000000000..d2d2d8e2fd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CHTMLNamespace.java @@ -0,0 +1,152 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTML40Namespace; + + + +/** + * Provide all names defined in the HTML 4.0? specification. + */ +public interface CHTMLNamespace { + + // Element names + public static interface ElementName { + public static final String A = HTML40Namespace.ElementName.A; + public static final String ADDRESS = HTML40Namespace.ElementName.ADDRESS; + public static final String BASE = HTML40Namespace.ElementName.BASE; + public static final String BLOCKQUOTE = HTML40Namespace.ElementName.BLOCKQUOTE; + public static final String BODY = HTML40Namespace.ElementName.BODY; + public static final String BR = HTML40Namespace.ElementName.BR; + public static final String CENTER = HTML40Namespace.ElementName.CENTER; + public static final String DD = HTML40Namespace.ElementName.DD; + public static final String DIR = HTML40Namespace.ElementName.DIR; + public static final String DIV = HTML40Namespace.ElementName.DIV; + public static final String DL = HTML40Namespace.ElementName.DL; + public static final String DT = HTML40Namespace.ElementName.DT; + public static final String FORM = HTML40Namespace.ElementName.FORM; + public static final String H1 = HTML40Namespace.ElementName.H1; + public static final String H2 = HTML40Namespace.ElementName.H2; + public static final String H3 = HTML40Namespace.ElementName.H3; + public static final String H4 = HTML40Namespace.ElementName.H4; + public static final String H5 = HTML40Namespace.ElementName.H5; + public static final String H6 = HTML40Namespace.ElementName.H6; + public static final String HEAD = HTML40Namespace.ElementName.HEAD; + public static final String HR = HTML40Namespace.ElementName.HR; + public static final String HTML = HTML40Namespace.ElementName.HTML; + public static final String IMG = HTML40Namespace.ElementName.IMG; + public static final String INPUT = HTML40Namespace.ElementName.INPUT; + public static final String LI = HTML40Namespace.ElementName.LI; + public static final String MENU = HTML40Namespace.ElementName.MENU; + public static final String META = HTML40Namespace.ElementName.META; + public static final String OL = HTML40Namespace.ElementName.OL; + public static final String OPTION = HTML40Namespace.ElementName.OPTION; + public static final String P = HTML40Namespace.ElementName.P; + public static final String PRE = HTML40Namespace.ElementName.PRE; + public static final String SELECT = HTML40Namespace.ElementName.SELECT; + public static final String TEXTAREA = HTML40Namespace.ElementName.TEXTAREA; + public static final String TITLE = HTML40Namespace.ElementName.TITLE; + public static final String UL = HTML40Namespace.ElementName.UL; + public static final String SSI_CONFIG = HTML40Namespace.ElementName.SSI_CONFIG; + public static final String SSI_ECHO = HTML40Namespace.ElementName.SSI_ECHO; + public static final String SSI_EXEC = HTML40Namespace.ElementName.SSI_EXEC; + public static final String SSI_FSIZE = HTML40Namespace.ElementName.SSI_FSIZE; + public static final String SSI_FLASTMOD = HTML40Namespace.ElementName.SSI_FLASTMOD; + public static final String SSI_INCLUDE = HTML40Namespace.ElementName.SSI_INCLUDE; + public static final String SSI_PRINTENV = HTML40Namespace.ElementName.SSI_PRINTENV; + public static final String SSI_SET = HTML40Namespace.ElementName.SSI_SET; + } + + // Character Entities + public static interface EntityName { + } + + // global attribute names + public static final String ATTR_NAME_VERSION = HTML40Namespace.ATTR_NAME_VERSION; + public static final String ATTR_NAME_SRC = HTML40Namespace.ATTR_NAME_SRC; + public static final String ATTR_NAME_ALT = HTML40Namespace.ATTR_NAME_ALT; + public static final String ATTR_NAME_HEIGHT = HTML40Namespace.ATTR_NAME_HEIGHT; + public static final String ATTR_NAME_WIDTH = HTML40Namespace.ATTR_NAME_WIDTH; + public static final String ATTR_NAME_ALIGN = HTML40Namespace.ATTR_NAME_ALIGN; + public static final String ATTR_NAME_BORDER = HTML40Namespace.ATTR_NAME_BORDER; + public static final String ATTR_NAME_HSPACE = HTML40Namespace.ATTR_NAME_HSPACE; + public static final String ATTR_NAME_VSPACE = HTML40Namespace.ATTR_NAME_VSPACE; + public static final String ATTR_NAME_NAME = HTML40Namespace.ATTR_NAME_NAME; + public static final String ATTR_NAME_CLEAR = HTML40Namespace.ATTR_NAME_CLEAR; + public static final String ATTR_NAME_NOSHADE = HTML40Namespace.ATTR_NAME_NOSHADE; + public static final String ATTR_NAME_CHECKED = HTML40Namespace.ATTR_NAME_CHECKED; + public static final String ATTR_NAME_MAXLENGTH = HTML40Namespace.ATTR_NAME_MAXLENGTH; + public static final String ATTR_NAME_ISTYLE = HTML40Namespace.ATTR_NAME_ISTYLE; + public static final String ATTR_NAME_HTTP_EQUIV = HTML40Namespace.ATTR_NAME_HTTP_EQUIV; + public static final String ATTR_NAME_CONTENT = HTML40Namespace.ATTR_NAME_CONTENT; + + public static final String ATTR_NAME_HREF = HTML40Namespace.ATTR_NAME_HREF; + public static final String ATTR_NAME_MULTIPLE = HTML40Namespace.ATTR_NAME_MULTIPLE; + public static final String ATTR_NAME_SELECTED = HTML40Namespace.ATTR_NAME_SELECTED; + public static final String ATTR_NAME_ROWS = HTML40Namespace.ATTR_NAME_ROWS; + public static final String ATTR_NAME_COLS = HTML40Namespace.ATTR_NAME_COLS; + public static final String ATTR_NAME_ACTION = HTML40Namespace.ATTR_NAME_ACTION; + public static final String ATTR_NAME_METHOD = HTML40Namespace.ATTR_NAME_METHOD; + public static final String ATTR_NAME_ENCTYPE = HTML40Namespace.ATTR_NAME_ENCTYPE; + public static final String ATTR_NAME_SIZE = HTML40Namespace.ATTR_NAME_SIZE; + public static final String ATTR_NAME_TYPE = HTML40Namespace.ATTR_NAME_TYPE; + public static final String ATTR_NAME_VALUE = HTML40Namespace.ATTR_NAME_VALUE; + + + + public static final String ATTR_NAME_ERRMSG = HTML40Namespace.ATTR_NAME_ERRMSG; + public static final String ATTR_NAME_SIZEFMT = HTML40Namespace.ATTR_NAME_SIZEFMT; + public static final String ATTR_NAME_TIMEFMT = HTML40Namespace.ATTR_NAME_TIMEFMT; + public static final String ATTR_NAME_VAR = HTML40Namespace.ATTR_NAME_VAR; + public static final String ATTR_NAME_CGI = HTML40Namespace.ATTR_NAME_CGI; + public static final String ATTR_NAME_CMD = HTML40Namespace.ATTR_NAME_CMD; + public static final String ATTR_NAME_FILE = HTML40Namespace.ATTR_NAME_FILE; + public static final String ATTR_NAME_VIRTUAL = HTML40Namespace.ATTR_NAME_VIRTUAL; + + // global attribute values; mainly used in enumeration. + public static final String ATTR_VALUE_VERSION_TRANSITIONAL = "-//W3C//DTD Compact HTML 1.0 Draft//EN"; //$NON-NLS-1$ + // for align (top|middle|bottom|left|right) + public static final String ATTR_VALUE_TOP = HTML40Namespace.ATTR_VALUE_TOP; + public static final String ATTR_VALUE_MIDDLE = HTML40Namespace.ATTR_VALUE_MIDDLE; + public static final String ATTR_VALUE_BOTTOM = HTML40Namespace.ATTR_VALUE_BOTTOM; + public static final String ATTR_VALUE_LEFT = HTML40Namespace.ATTR_VALUE_LEFT; + public static final String ATTR_VALUE_CENTER = HTML40Namespace.ATTR_VALUE_CENTER; + public static final String ATTR_VALUE_RIGHT = HTML40Namespace.ATTR_VALUE_RIGHT; + // for clear (left|all|right|none): left and right are already defined above. + public static final String ATTR_VALUE_ALL = HTML40Namespace.ATTR_VALUE_ALL; + public static final String ATTR_VALUE_NONE = HTML40Namespace.ATTR_VALUE_NONE; + // for type of INPUT + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + public static final String ATTR_VALUE_TEXT = HTML40Namespace.ATTR_VALUE_TEXT; + public static final String ATTR_VALUE_PASSWORD = HTML40Namespace.ATTR_VALUE_PASSWORD; + public static final String ATTR_VALUE_CHECKBOX = HTML40Namespace.ATTR_VALUE_CHECKBOX; + public static final String ATTR_VALUE_RADIO = HTML40Namespace.ATTR_VALUE_RADIO; + public static final String ATTR_VALUE_SUBMIT = HTML40Namespace.ATTR_VALUE_SUBMIT; + public static final String ATTR_VALUE_RESET = HTML40Namespace.ATTR_VALUE_RESET; + public static final String ATTR_VALUE_HIDDEN = HTML40Namespace.ATTR_VALUE_HIDDEN; + // for span, colspan, rowspan + public static final String ATTR_VALUE_1 = HTML40Namespace.ATTR_VALUE_1; + // for frameborder + public static final String ATTR_VALUE_0 = HTML40Namespace.ATTR_VALUE_0; + // for method of FORM + public static final String ATTR_VALUE_GET = HTML40Namespace.ATTR_VALUE_GET; + public static final String ATTR_VALUE_POST = HTML40Namespace.ATTR_VALUE_POST; + public static final String ATTR_VALUE_WWW_FORM_URLENCODED = HTML40Namespace.ATTR_VALUE_WWW_FORM_URLENCODED; + // for behaviro of MARQUEE + public static final String ATTR_VALUE_SCROLL = HTML40Namespace.ATTR_VALUE_SCROLL; + public static final String ATTR_VALUE_SLIDE = HTML40Namespace.ATTR_VALUE_SLIDE; + public static final String ATTR_VALUE_ALTERNATE = HTML40Namespace.ATTR_VALUE_ALTERNATE; + // for direction of MARQUEE + public static final String ATTR_VALUE_UP = HTML40Namespace.ATTR_VALUE_UP; + public static final String ATTR_VALUE_DOWN = HTML40Namespace.ATTR_VALUE_DOWN; +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java new file mode 100644 index 0000000000..c9f5219d8f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMContentImpl.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Implementation of CMContent for HTML CM. + */ +abstract class CMContentImpl extends CMNodeImpl implements org.eclipse.wst.common.contentmodel.CMContent { + + public static final int UNBOUNDED = -1; + /** -1: it's UNBOUNDED. */ + private int maxOccur = UNBOUNDED; + /** 0: it's OPTIONAL, 1, it's REQUIRED. */ + private int minOccur = 0; + + /** + * The primary consturctor. + * Use this one for usual cases.<br> + */ + public CMContentImpl(String name, int min, int max) { + super(name); + minOccur = min; + maxOccur = max; + } + + /** + * getMaxOccur method + * @return int + * + * If -1, it's UNBOUNDED. + */ + public int getMaxOccur() { + return maxOccur; + } + + /** + * getMinOccur method + * @return int + * + * If 0, it's OPTIONAL. + * If 1, it's REQUIRED. + */ + public int getMinOccur() { + return minOccur; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java new file mode 100644 index 0000000000..509bf9e173 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMGroupImpl.java @@ -0,0 +1,83 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.common.contentmodel.CMNodeList; + +/** + */ +class CMGroupImpl extends CMContentImpl implements CMGroup { + + private int operator = CMGroup.SEQUENCE; + private CMNodeListImpl children = null; + + /** + * CMGroupImpl constructor comment. + */ + public CMGroupImpl(int op, int minOccur, int maxOccur) { + super(null, minOccur, maxOccur); + switch (op) { + case CMGroup.ALL : + case CMGroup.CHOICE : + case CMGroup.SEQUENCE : + operator = op; + break; + default : + // should warn. + break; + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendChild(CMNode child) { + if (child == null) + return null; + if (children == null) + children = new CMNodeListImpl(); + return children.appendNode(child); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNodeList + */ + public CMNodeList getChildNodes() { + return children; + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.GROUP; + } + + /** + * getOperation method + * @return int + * + * Returns one of : + * ALONE (a), SEQUENCE (a,b), CHOICE (a|b), ALL (a&b). + */ + public int getOperator() { + return operator; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java new file mode 100644 index 0000000000..39a7ba9a81 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNamedNodeMapImpl.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * An implementation of the CMNamedNodeMap interface. + * This class is intented to be used as a container of attribute declarations. + * If someone wants to use this class for other purpose, he must pay attention + * to the fact that this class is tolerant of the key name case. That is, this + * class does not distinguish "name", "NAME", and "Name" as a key name. + */ +class CMNamedNodeMapImpl implements org.eclipse.wst.common.contentmodel.CMNamedNodeMap { + + private java.util.Hashtable items = null; + + /** + */ + public CMNamedNodeMapImpl() { + super(); + items = new java.util.Hashtable(); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return items.size(); + } + + /** + * getNamedItem method + * @return CMNode <code>null</code> for unknown keys. + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + String cookedName = makeCanonicalForm(name); + if (!items.containsKey(cookedName)) + return null; + return (CMNode) items.get(cookedName); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + Iterator iter = iterator(); + while (iter.hasNext()) { + CMNode node = (CMNode) iter.next(); + if (--index < 0) + return node; + } + return null; + } + + /** + * @return java.util.Iterator + */ + public Iterator iterator() { + return items.values().iterator(); + } + + /** + * @return java.lang.String + * @param rawForm java.lang.String + */ + private String makeCanonicalForm(String rawForm) { + return rawForm.toUpperCase(); + } + + /** + * @param key java.lang.String + * @param item java.lang.String + */ + void putNamedItem(String name, CMNode item) { + String cookedName = makeCanonicalForm(name); + if (items.containsKey(cookedName)) + return; // already registered. + items.put(cookedName, item); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java new file mode 100644 index 0000000000..69707962d5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeImpl.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTMLCMProperties; + + + +/** + */ +abstract class CMNodeImpl implements org.eclipse.wst.common.contentmodel.CMNode { + + private java.lang.String name = null; + + /** + * CMNodeImpl constructor comment. + */ + public CMNodeImpl(String nm) { + super(); + name = nm; + } + + /** + * getNodeName method + * @return java.lang.String + */ + public String getNodeName() { + return name; + } + + /** + * getProperty method + * @return java.lang.Object + * + * Returns the object property desciped by the propertyName + * + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return new Boolean(false); + return null; + } + + /** + * supports method + * @return boolean + * + * Returns true if the CMNode supports a specified property + * + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.IS_XHTML)) + return true; + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java new file mode 100644 index 0000000000..1aba885873 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CMNodeListImpl.java @@ -0,0 +1,61 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Analog of dom.NodeList for CM. + * So, the implementation is very similar to + * {@link com.ibm.sed.model.xml.NodeListImpl}.<br> + */ +class CMNodeListImpl implements org.eclipse.wst.common.contentmodel.CMNodeList { + + private java.util.Vector nodes = null; + + /** + * CMNodeListImpl constructor comment. + */ + public CMNodeListImpl() { + super(); + nodes = new java.util.Vector(); + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param node org.eclipse.wst.common.contentmodel.CMNode + */ + protected CMNode appendNode(CMNode node) { + nodes.addElement(node); + return node; + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return nodes.size(); + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (index < 0 || index >= nodes.size()) + return null; + return (CMNode) nodes.elementAt(index); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java new file mode 100644 index 0000000000..c3d730496b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinition.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + +/** + * This class is intended to represent a complex type definition + * in XML Schema.<br> + */ +abstract class ComplexTypeDefinition { + + protected CMGroupImpl content = null; + protected ElementCollection collection = null; + protected String primaryCandidateName = null; + + /** + * ComplexTypeDefinition constructor comment. + */ + public ComplexTypeDefinition(ElementCollection elementCollection) { + super(); + collection = elementCollection; + createContent(); + } + + /** + * Create an actual content model. + * This method should be called once and only once in the constructor.<br> + */ + protected abstract void createContent(); + + /** + * @return org.eclipse.wst.common.contentmodel.CMGroup + */ + public CMGroup getContent() { + return content; + } + + /** + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + /* NOTE: Do we need LOGICAL type? + * -- 3/7/2001 + */ + public abstract int getContentType(); + + /** + * Get content hint. + * @return com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLElementDeclaration getPrimaryCandidate() { + if (primaryCandidateName == null) + return null; + return (HTMLElementDeclaration) collection.getNamedItem(primaryCandidateName); + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public abstract String getTypeName(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java new file mode 100644 index 0000000000..4d66fb5f30 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ComplexTypeDefinitionFactory.java @@ -0,0 +1,146 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Factory of ComplexTypeDefinition. + */ +final class ComplexTypeDefinitionFactory { + + private static ComplexTypeDefinitionFactory instance = null; + private java.util.Hashtable definitions = null; + // constants for complex type name + /** for ADDRESS. */ + public final static String CTYPE_ADDRESS = "CTYPE_ADDRESS";//$NON-NLS-1$ + /** CDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_CDATA = "CTYPE_CDATA";//$NON-NLS-1$ + /** col group content. COL* */ + public final static String CTYPE_COLUMN_GROUP = "CTYPE_COLUMN_GROUP";//$NON-NLS-1$ + /** for DL. */ + public final static String CTYPE_DEFINITION_LIST = "CTYPE_DEFINITION_LIST";//$NON-NLS-1$ + /** for EMBED. */ + public final static String CTYPE_EMBED = "CTYPE_EMBED";//$NON-NLS-1$ + /** empty content. No ComplexTypeDefinition instance should be created. */ + public final static String CTYPE_EMPTY = "CTYPE_EMPTY";//$NON-NLS-1$ + /** for FIELDSET. */ + public final static String CTYPE_FIELDSET = "CTYPE_FIELDSET";//$NON-NLS-1$ + /** for FRAMESET. */ + public final static String CTYPE_FRAMESET = "CTYPE_FRAMESET";//$NON-NLS-1$ + /** flow content. (%flow;)* */ + public final static String CTYPE_FLOW_CONTAINER = "CTYPE_FLOW_CONTAINER";//$NON-NLS-1$ + /** html content. HEAD, (FRAMESET|BODY) */ + public final static String CTYPE_HTML = "CTYPE_HTML";//$NON-NLS-1$ + /** head content. TITLE & ISINDEX? & BASE? */ + public final static String CTYPE_HEAD = "CTYPE_HEAD";//$NON-NLS-1$ + /** inline content. (%inline;)* */ + public final static String CTYPE_INLINE_CONTAINER = "CTYPE_INLINE_CONTAINER";//$NON-NLS-1$ + /** list item container. (LI)+ */ + public final static String CTYPE_LI_CONTAINER = "CTYPE_LI_CONTAINER";//$NON-NLS-1$ + /** for MAP. */ + public final static String CTYPE_MAP = "CTYPE_MAP";//$NON-NLS-1$ + /** noframes content. */ + public final static String CTYPE_NOFRAMES_CONTENT = "CTYPE_NOFRAMES_CONTENT";//$NON-NLS-1$ + /** for OPTGROUP. */ + public final static String CTYPE_OPTION_CONTAINER = "CTYPE_OPTION_CONTAINER";//$NON-NLS-1$ + /** param container. For OBJECT/APPLET. */ + public final static String CTYPE_PARAM_CONTAINER = "CTYPE_PARAM_CONTAINER";//$NON-NLS-1$ + /** PCDATA content. No ComplexTypeDefinition instance shuld be created. */ + public final static String CTYPE_PCDATA = "CTYPE_PCDATA";//$NON-NLS-1$ + /** for SELECT. */ + public final static String CTYPE_SELECT = "CTYPE_SELECT";//$NON-NLS-1$ + /** table content. CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+ */ + public final static String CTYPE_TABLE = "CTYPE_TABLE";//$NON-NLS-1$ + /** table cell contaier. (TH|TD)+ */ + public final static String CTYPE_TCELL_CONTAINER = "CTYPE_TCELL_CONTAINER";//$NON-NLS-1$ + /** table record container. (TR)+ */ + public final static String CTYPE_TR_CONTAINER = "CTYPE_TR_CONTAINER";//$NON-NLS-1$ + + /** + * ComplexTypeDefinitionFactory constructor comment. + */ + private ComplexTypeDefinitionFactory() { + super(); + definitions = new java.util.Hashtable(); + } + + /** + * Factory method for ComplexTypeDefinition. + * Each instance created in this method must be registered into + * the map with its name. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + * @param definitionName java.lang.String + * @param elementCollection ElementCollection + */ + public ComplexTypeDefinition createTypeDefinition(String definitionName, ElementCollection elementCollection) { + if (definitions.containsKey(definitionName)) { + return (ComplexTypeDefinition) definitions.get(definitionName); + } + + ComplexTypeDefinition def = null; + if (definitionName == CTYPE_ADDRESS) { + def = new CtdAddress(elementCollection); + + } + else if (definitionName == CTYPE_DEFINITION_LIST) { + def = new CtdDl(elementCollection); + + } + else if (definitionName == CTYPE_FLOW_CONTAINER) { + def = new CtdFlowContainer(elementCollection); + + } + else if (definitionName == CTYPE_HEAD) { + def = new CtdHead(elementCollection); + + } + else if (definitionName == CTYPE_HTML) { + def = new CtdHtml(elementCollection); + + } + else if (definitionName == CTYPE_INLINE_CONTAINER) { + def = new CtdInlineContainer(elementCollection); + + } + else if (definitionName == CTYPE_LI_CONTAINER) { + def = new CtdLiContainer(elementCollection); + + + } + else if (definitionName == CTYPE_OPTION_CONTAINER) { + def = new CtdOptionContainer(elementCollection); + + } + else if (definitionName == CTYPE_SELECT) { + def = new CtdSelect(elementCollection); + + } + else { + def = null; + } + if (def == null) + return null; // fail to create. + definitions.put(definitionName, def); + return def; + } + + /** + * For singleton.<br> + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinitionFactory + */ + public synchronized static ComplexTypeDefinitionFactory getInstance() { + if (instance != null) + return instance; + instance = new ComplexTypeDefinitionFactory(); + return instance; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java new file mode 100644 index 0000000000..8b2392e7ff --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdAddress.java @@ -0,0 +1,70 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for ADDRESS. + */ +final class CtdAddress extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdAddress(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * ((%inline) | P)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )* + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + // (%inline) + CMGroupImpl inlines = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (inlines == null) + return; + collection.getInline(inlines); + content.appendChild(inlines); + // P + CMNode p = collection.getNamedItem(CHTMLNamespace.ElementName.P); + if (p != null) + content.appendChild(p); + } + + /** + * ((%inline) | P)*. + * Because %inline; contains #PCDATA, the type is MIXED. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java new file mode 100644 index 0000000000..51cd5ad75d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdDl.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for DL. + */ +final class CtdDl extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdDl(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.DT; + } + + /** + * (DT | DD)+ + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // DT + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.DT); + if (dec != null) + content.appendChild(dec); + // DD + dec = collection.getNamedItem(CHTMLNamespace.ElementName.DD); + if (dec != null) + content.appendChild(dec); + } + + /** + * (DT | DD)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java new file mode 100644 index 0000000000..cbf733a867 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdFlowContainer.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for containers of <code>%flow;</code>. + */ +final class CtdFlowContainer extends ComplexTypeDefinition { + + /** + */ + public CtdFlowContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%flow;)* + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getFlow(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java new file mode 100644 index 0000000000..a3172351ef --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHead.java @@ -0,0 +1,175 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Complex type definition for the head content. + * Content Model: (TITLE & ISINDEX? & BASE?) + */ +final class CtdHead extends ComplexTypeDefinition { + + /** + */ + public CtdHead(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.TITLE; + } + + /** + * for HEAD. + * To avoid using inclusion, the content model comes from the XHTML 1.0. + * + * (%head.misc;, ((title, %head.misc;, (base, %head.misc;)?) | (base, %head.misc;, (title, %head.misc;)))) + * And %head.misc; is: + * (script|style|meta|link|object|isindex)* + * + * 0: (%head.misc, A) + * A: (B | C) + * B: (title, %head.misc;, D) + * C: (base, %head.misc;, E) + * D: (base, %head.misc;)? + * E: (title, %head.misc;) + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // At 1st, create %head.misc; content. + // %head.misc; + // ( | )* + CMGroupImpl misc = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + if (misc == null) + return; + String[] names = {CHTMLNamespace.ElementName.META,}; + collection.getDeclarations(misc, Arrays.asList(names).iterator()); + // 2nd, get a title + CMNode title = collection.getNamedItem(CHTMLNamespace.ElementName.TITLE); + // 3rd, get a base + CMNode base = collection.getNamedItem(CHTMLNamespace.ElementName.BASE); + if (title == null || base == null) + return; + + // Top level content is a sequence of %head.misc; and A. + // 0: (%head.misc;, A) + // create a sequence + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + // append %head.misc; + content.appendChild(misc); + // create A and append it to the top level. + { + // A is a choice of B and C. + // A: (B | C) + // create a choice + CMGroupImpl gA = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + if (gA == null) + return; + // append A to the top level. + content.appendChild(gA); + + // create B and append it to A + { + // B is a sequence of title, %head.misc;, and D. + // B: (title, %head.misc;, D) + // create a sequence + CMGroupImpl gB = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gB == null) + return; + // append B to A. + gA.appendChild(gB); + + // append title to B + gB.appendChild(title); + // append %head.misc; to B + gB.appendChild(misc); + // create D and append it to B. + { + // D is a sequence of base, %head.misc;. + // D: (base, %head.misc;)? + // create a sequence + CMGroupImpl gD = new CMGroupImpl(CMGroup.SEQUENCE, 0, 1); + if (gD == null) + return; + // append D to B. + gB.appendChild(gD); + + // append base to D + gD.appendChild(base); + // append %head.misc; to D. + gD.appendChild(misc); + } + } + // create C and append it to A + { + // C is a sequence of base, %head.misc;, and E + // C: (base, %head.misc;, E) + // create a sequence + CMGroupImpl gC = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gC == null) + return; + // append C to A. + gA.appendChild(gC); + + // append base to C + gC.appendChild(base); + // append %head.misc; to C + gC.appendChild(misc); + + // create E and append it to C. + { + // E is a sequence of title and %head.misc;. + // E: (title, %head.misc;) + // create a sequence + CMGroupImpl gE = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (gE == null) + return; + // append E to C. + gC.appendChild(gE); + + // append title to E + gE.appendChild(title); + // append %head.misc; to E. + gE.appendChild(misc); + } + } + } + } + + /** + * Element content.<br> + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HEAD; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java new file mode 100644 index 0000000000..34db54866f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdHtml.java @@ -0,0 +1,79 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Complex type definition for <code>HTML</code>.<br> + * Content Model: + * HEAD, (FRAMESET|BODY)<br> + */ +final class CtdHtml extends ComplexTypeDefinition { + + /** + */ + public CtdHtml(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.HEAD; + } + + /** + * (%html.content;). + * %html.content; is HEAD, (FRAMESET | BODY). + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( ) + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, 1); + if (content == null) + return; + + // HEAD + CMNode edec = collection.getNamedItem(CHTMLNamespace.ElementName.HEAD); + if (edec != null) + content.appendChild(edec); + + // ( | ) + CMGroupImpl group = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + content.appendChild(group); + + // FRAMESET, BODY + String[] names = {CHTMLNamespace.ElementName.BODY}; + collection.getDeclarations(group, Arrays.asList(names).iterator()); + } + + /** + * Element content. + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_HTML; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java new file mode 100644 index 0000000000..b00c3acf6b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdInlineContainer.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * Complex type definition for (%inline;)*. + */ +final class CtdInlineContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdInlineContainer(ElementCollection elementCollection) { + super(elementCollection); + } + + /** + * (%inline)*. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + content = new CMGroupImpl(CMGroup.CHOICE, 0, CMContentImpl.UNBOUNDED); + collection.getInline(content); + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public int getContentType() { + return CMElementDeclaration.MIXED; + } + + /** + * @see com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java new file mode 100644 index 0000000000..7b8cb714ed --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdLiContainer.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * List item container. + * (LI)+ + */ +final class CtdLiContainer extends ComplexTypeDefinition { + + /** + * @param elemenCollection ElementCollection + */ + public CtdLiContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.LI; + } + + /** + * (LI)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // (LI)+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + CMNode li = collection.getNamedItem(CHTMLNamespace.ElementName.LI); + if (li != null) + content.appendChild(li); + } + + /** + * ELEMENT content.<br> + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java new file mode 100644 index 0000000000..45f8430586 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdOptionContainer.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * OPTION container. + * (OPTION)+ + */ +final class CtdOptionContainer extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdOptionContainer(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.OPTION; + } + + /** + * (OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( )+ + content = new CMGroupImpl(CMGroup.SEQUENCE, 1, CMContentImpl.UNBOUNDED); + // OPTION + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTION)+ + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * Name of complex type definition. + * Each singleton must know its own name. + * All names should be defined in + * {@link <code>ComplexTypeDefinitionFactory</code>} as constants.<br> + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_OPTION_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java new file mode 100644 index 0000000000..ea83c5991c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/CtdSelect.java @@ -0,0 +1,64 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * for SELECT. + */ +final class CtdSelect extends ComplexTypeDefinition { + + /** + * @param elementCollection ElementCollection + */ + public CtdSelect(ElementCollection elementCollection) { + super(elementCollection); + primaryCandidateName = CHTMLNamespace.ElementName.OPTION; + } + + /** + * (OPTGROUP | OPTION)+. + */ + protected void createContent() { + if (content != null) + return; // already created. + if (collection == null) + return; + + // ( | )+ + content = new CMGroupImpl(CMGroup.CHOICE, 1, CMContentImpl.UNBOUNDED); + // OPTION + CMNode dec = collection.getNamedItem(CHTMLNamespace.ElementName.OPTION); + if (dec != null) + content.appendChild(dec); + } + + /** + * (OPTGROUP | OPTION)+. + * @return int; Should be one of ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA, + * those are defined in CMElementDeclaration. + */ + public int getContentType() { + return CMElementDeclaration.ELEMENT; + } + + /** + * @return java.lang.String + */ + public String getTypeName() { + return ComplexTypeDefinitionFactory.CTYPE_SELECT; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java new file mode 100644 index 0000000000..62809a8cdd --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/DeclCollection.java @@ -0,0 +1,238 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.HashMap; +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + */ +abstract class DeclCollection implements CMNamedNodeMap { + + + protected class DualMap { + public DualMap() { + super(); + } + + public DualMap(Object[] objects) { + super(); + initialize(objects); + } + + public int size() { + return table.length; + } + + public Object getValue(int key) { + if (!isValidIndex(key)) + return null; + return table[key]; + } + + public int getKey(Object value) { + Integer keyObj = (Integer) map.get(value); + if (keyObj == null) + return ID_UNKNOWN; + return keyObj.intValue(); + } + + protected void initialize(Object[] objects) { + if (objects == null) + return; + table = objects; + map = new HashMap(); + for (int key = 0; key < objects.length; key++) { + Object value = table[key]; + map.put(value, new Integer(key)); + } + } + + private Object[] table = null; + private HashMap map = null; + + private boolean isValidIndex(int index) { + return index >= 0 && index < table.length; + } + } + + protected class TolerantStringDualMap extends DualMap { + public TolerantStringDualMap(String[] names) { + super(); + Object[] objects = new Object[names.length]; + for (int i = 0; i < names.length; i++) { + objects[i] = makeCanonicalForm(names[i]); + } + initialize(objects); + } + + public int getKey(Object value) { + try { + String name = (String) value; + return super.getKey(makeCanonicalForm(name)); + } + catch (ClassCastException e) { + return ID_UNKNOWN; + } + } + + private String makeCanonicalForm(String raw) { + return raw.toUpperCase(); + } + } + + private class DeclIterator implements Iterator { + public DeclIterator() { + maxid = fDecls.length - 1; + } + + public boolean hasNext() { + return id < maxid; + } + + public Object next() { + if (!hasNext()) + return null; + return item(++id); + } + + public void remove() { /* nothing should be done. */ + } + + private int id = -1; + private int maxid = -1; + } + + CMNode[] fDecls = null; + protected final static boolean STRICT_CASE = false; + protected final static boolean TOLERANT_CASE = true; + protected final static int ID_UNKNOWN = -1; + private DualMap fMap = null; + + /** + */ + public DeclCollection(String[] names, boolean tolerant) { + super(); + fDecls = new CMNode[names.length]; + if (tolerant) { + fMap = new TolerantStringDualMap(names); + } + else { + fMap = new DualMap(names); + } + } + + /** + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param id int + */ + protected abstract CMNode create(String name); + + /** + */ + public CMNamedNodeMap getDeclarations(String[] names) { + CMNamedNodeMapImpl map = new CMNamedNodeMapImpl(); + for (int i = 0; i < names.length; i++) { + String name = names[i]; + CMNode node = getNamedItem(name); + if (node == null) + continue; + map.putNamedItem(name, node); + } + return map; + } + + /** + * @param declarations com.ibm.sed.contentmodel.html.CMGroupImpl + * @param names java.util.Iterator + */ + public void getDeclarations(CMGroupImpl group, Iterator names) { + while (names.hasNext()) { + String entityName = (String) names.next(); + CMNode dec = getNamedItem(entityName); + if (dec != null) + group.appendChild(dec); + } + } + + /** + * Map name to id. + * @return int + * @param name java.lang.String + */ + protected int getID(String name) { + return fMap.getKey(name); + } + + /** + * getLength method + * @return int + */ + public int getLength() { + return fDecls.length; + } + + /** + * @return java.lang.String + * @param id int + */ + protected String getName(int id) { + return (String) fMap.getValue(id); + } + + /** + * getNamedItem method + * @return CMNode + * @param name java.lang.String + */ + public CMNode getNamedItem(String name) { + int id = getID(name); + if (!isValidID(id)) + return null; + return item(id); + } + + /** + * @return boolean + * @param id int + */ + private boolean isValidID(int id) { + return id >= 0 && id < fDecls.length; + } + + /** + * item method + * @return CMNode + * @param index int + */ + public CMNode item(int index) { + if (!isValidID(index)) + return null; + CMNode decl = fDecls[index]; + if (decl != null) + return decl; // already exist. + + decl = create(getName(index)); + fDecls[index] = decl; + return decl; + } + + /** + */ + public Iterator iterator() { + return new DeclIterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java new file mode 100644 index 0000000000..854806427d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/ElementCollection.java @@ -0,0 +1,495 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.lang.reflect.Field; +import java.util.Arrays; +import java.util.Collection; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for element declarations. + */ +final class ElementCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.ElementName { + + + // Element IDs + private static class Ids { + public static final int ID_A = 0; + public static final int ID_ADDRESS = 1; + public static final int ID_BASE = 2; + public static final int ID_BLOCKQUOTE = 3; + public static final int ID_BODY = 4; + public static final int ID_BR = 5; + public static final int ID_CENTER = 6; + public static final int ID_DD = 7; + public static final int ID_DIR = 8; + public static final int ID_DIV = 9; + public static final int ID_DL = 10; + public static final int ID_DT = 11; + public static final int ID_FORM = 12; + public static final int ID_H1 = 13; + public static final int ID_H2 = 14; + public static final int ID_H3 = 15; + public static final int ID_H4 = 16; + public static final int ID_H5 = 17; + public static final int ID_H6 = 18; + public static final int ID_HEAD = 19; + public static final int ID_HR = 20; + public static final int ID_HTML = 21; + public static final int ID_IMG = 22; + public static final int ID_INPUT = 23; + public static final int ID_LI = 24; + public static final int ID_MENU = 25; + public static final int ID_META = 26; + public static final int ID_OL = 27; + public static final int ID_OPTION = 28; + public static final int ID_P = 29; + public static final int ID_PRE = 30; + public static final int ID_SELECT = 31; + public static final int ID_TEXTAREA = 32; + public static final int ID_TITLE = 33; + public static final int ID_UL = 34; + public static final int ID_SSI_CONFIG = 35; + public static final int ID_SSI_ECHO = 36; + public static final int ID_SSI_EXEC = 37; + public static final int ID_SSI_FSIZE = 38; + public static final int ID_SSI_FLASTMOD = 39; + public static final int ID_SSI_INCLUDE = 40; + public static final int ID_SSI_PRINTENV = 41; + public static final int ID_SSI_SET = 42; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 105. + // -- 5/25/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + /** %formctl;. INPUT | SELECT | TEXTAREA */ + private static final String[] FORMCTL = {INPUT, SELECT, TEXTAREA}; + /** %phrase;. + * DFN + */ + private static final String[] PHRASE = {DFN}; + /** %special;. + * A | IMG | BR + */ + private static final String[] SPECIAL = {A, IMG, BR}; + /** %heading;. H[1-6] */ + private static final String[] HEADING = {H1, H2, H3, H4, H5, H6}; + /** %list;. UL | OL | DIR | MENU */ + private static final String[] LIST = {UL, OL, DIR, MENU}; + /** %preformatted;. PRE */ + private static final String[] PREFORMATTED = {PRE}; + private AttributeCollection attributeCollection = null; + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_A] = A; + names[Ids.ID_ADDRESS] = ADDRESS; + names[Ids.ID_BASE] = BASE; + names[Ids.ID_BLOCKQUOTE] = BLOCKQUOTE; + names[Ids.ID_BODY] = BODY; + names[Ids.ID_BR] = BR; + names[Ids.ID_CENTER] = CENTER; + names[Ids.ID_DD] = DD; + names[Ids.ID_DIR] = DIR; + names[Ids.ID_DIV] = DIV; + names[Ids.ID_DL] = DL; + names[Ids.ID_DT] = DT; + names[Ids.ID_FORM] = FORM; + names[Ids.ID_H1] = H1; + names[Ids.ID_H2] = H2; + names[Ids.ID_H3] = H3; + names[Ids.ID_H4] = H4; + names[Ids.ID_H5] = H5; + names[Ids.ID_H6] = H6; + names[Ids.ID_HEAD] = HEAD; + names[Ids.ID_HR] = HR; + names[Ids.ID_HTML] = HTML; + names[Ids.ID_IMG] = IMG; + names[Ids.ID_INPUT] = INPUT; + names[Ids.ID_LI] = LI; + names[Ids.ID_MENU] = MENU; + names[Ids.ID_META] = META; + names[Ids.ID_OL] = OL; + names[Ids.ID_OPTION] = OPTION; + names[Ids.ID_P] = P; + names[Ids.ID_PRE] = PRE; + names[Ids.ID_SELECT] = SELECT; + names[Ids.ID_TEXTAREA] = TEXTAREA; + names[Ids.ID_TITLE] = TITLE; + names[Ids.ID_UL] = UL; + names[Ids.ID_SSI_CONFIG] = SSI_CONFIG; + names[Ids.ID_SSI_ECHO] = SSI_ECHO; + names[Ids.ID_SSI_EXEC] = SSI_EXEC; + names[Ids.ID_SSI_FSIZE] = SSI_FSIZE; + names[Ids.ID_SSI_FLASTMOD] = SSI_FLASTMOD; + names[Ids.ID_SSI_INCLUDE] = SSI_INCLUDE; + names[Ids.ID_SSI_PRINTENV] = SSI_PRINTENV; + names[Ids.ID_SSI_SET] = SSI_SET; + } + + /** + */ + public ElementCollection(AttributeCollection collection) { + super(names, TOLERANT_CASE); + attributeCollection = collection; + } + + /** + * Actually creates HTMLElementDeclaration instance. + * @return HTMLElementDeclaration + */ + protected CMNode create(String elementName) { + HTMLElemDeclImpl edec = null; + + if (elementName.equalsIgnoreCase(A)) { + edec = new HedA(this); + + } + else if (elementName.equalsIgnoreCase(ADDRESS)) { + edec = new HedADDRESS(this); + + } + else if (elementName.equalsIgnoreCase(BASE)) { + edec = new HedBASE(this); + + } + else if (elementName.equalsIgnoreCase(BLOCKQUOTE)) { + edec = new HedBLOCKQUOTE(this); + + } + else if (elementName.equalsIgnoreCase(BODY)) { + edec = new HedBODY(this); + + } + else if (elementName.equalsIgnoreCase(BR)) { + edec = new HedBR(this); + + } + else if (elementName.equalsIgnoreCase(CENTER)) { + edec = new HedCENTER(this); + + } + else if (elementName.equalsIgnoreCase(DD)) { + edec = new HedDD(this); + + } + else if (elementName.equalsIgnoreCase(DIR)) { + edec = new HedMENU(DIR, this); + + } + else if (elementName.equalsIgnoreCase(DIV)) { + edec = new HedDIV(this); + + } + else if (elementName.equalsIgnoreCase(DL)) { + edec = new HedDL(this); + + } + else if (elementName.equalsIgnoreCase(DT)) { + edec = new HedDT(this); + + } + else if (elementName.equalsIgnoreCase(FORM)) { + edec = new HedFORM(this); + + } + else if (elementName.equalsIgnoreCase(H1)) { + edec = new HedHeading(H1, this); + + } + else if (elementName.equalsIgnoreCase(H2)) { + edec = new HedHeading(H2, this); + + } + else if (elementName.equalsIgnoreCase(H3)) { + edec = new HedHeading(H3, this); + + } + else if (elementName.equalsIgnoreCase(H4)) { + edec = new HedHeading(H4, this); + + } + else if (elementName.equalsIgnoreCase(H5)) { + edec = new HedHeading(H5, this); + + } + else if (elementName.equalsIgnoreCase(H6)) { + edec = new HedHeading(H6, this); + + } + else if (elementName.equalsIgnoreCase(HEAD)) { + edec = new HedHEAD(this); + + } + else if (elementName.equalsIgnoreCase(HR)) { + edec = new HedHR(this); + + } + else if (elementName.equalsIgnoreCase(HTML)) { + edec = new HedHTML(this); + + } + else if (elementName.equalsIgnoreCase(IMG)) { + edec = new HedIMG(this); + + } + else if (elementName.equalsIgnoreCase(INPUT)) { + edec = new HedINPUT(this); + + } + else if (elementName.equalsIgnoreCase(LI)) { + edec = new HedLI(this); + + } + else if (elementName.equalsIgnoreCase(MENU)) { + edec = new HedMENU(MENU, this); + + } + else if (elementName.equalsIgnoreCase(META)) { + edec = new HedMETA(this); + + } + else if (elementName.equalsIgnoreCase(OL)) { + edec = new HedOL(this); + + } + else if (elementName.equalsIgnoreCase(OPTION)) { + edec = new HedOPTION(this); + + } + else if (elementName.equalsIgnoreCase(P)) { + edec = new HedP(this); + + } + else if (elementName.equalsIgnoreCase(PRE)) { + edec = new HedPRE(this); + + } + else if (elementName.equalsIgnoreCase(SELECT)) { + edec = new HedSELECT(this); + + } + else if (elementName.equalsIgnoreCase(TEXTAREA)) { + edec = new HedTEXTAREA(this); + + } + else if (elementName.equalsIgnoreCase(TITLE)) { + edec = new HedTITLE(this); + + } + else if (elementName.equalsIgnoreCase(UL)) { + edec = new HedUL(this); + + } + else if (elementName.equalsIgnoreCase(SSI_CONFIG)) { + edec = new HedSSIConfig(this); + + } + else if (elementName.equalsIgnoreCase(SSI_ECHO)) { + edec = new HedSSIEcho(this); + + } + else if (elementName.equalsIgnoreCase(SSI_EXEC)) { + edec = new HedSSIExec(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FSIZE)) { + edec = new HedSSIFsize(this); + + } + else if (elementName.equalsIgnoreCase(SSI_FLASTMOD)) { + edec = new HedSSIFlastmod(this); + + } + else if (elementName.equalsIgnoreCase(SSI_INCLUDE)) { + edec = new HedSSIInclude(this); + + } + else if (elementName.equalsIgnoreCase(SSI_PRINTENV)) { + edec = new HedSSIPrintenv(this); + + } + else if (elementName.equalsIgnoreCase(SSI_SET)) { + edec = new HedSSISet(this); + + } // unknown + else { + // NOTE: We don't define the UNKNOWN element declaration. + // <code>null</code> for a declaration is a sign of + // the target element is unknown. + // -- 3/9/2001 + edec = null; + } + return edec; + } + + /** + * @return com.ibm.sed.contentmodel.html.AttributeCollection + */ + public AttributeCollection getAttributeCollection() { + return attributeCollection; + } + + /** + */ + public final Collection getNamesOfBlock() { + // P | %list | %preformatted | DL | DIV | CENTER | BLOCKQUOTE | FORM | HR + String[] blockMisc = {P, DL, DIV, CENTER, BLOCKQUOTE, FORM, HR,}; + Vector blockNames = new Vector(Arrays.asList(blockMisc)); + // %heading; + blockNames.addAll(Arrays.asList(HEADING)); + // %list; + blockNames.addAll(Arrays.asList(LIST)); + // %preformatted; + blockNames.addAll(Arrays.asList(PREFORMATTED)); + + return blockNames; + } + + /** + * %block;. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS.<br> + * @param group CMGroupImpl Return values. + */ + public final void getBlock(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, getNamesOfBlock().iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getFlow(CMGroupImpl group) { + if (group == null) + return; + getBlock(group); + getInline(group); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFontstyle(CMGroupImpl group) { + return; + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getFormctrl(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(FORMCTL).iterator()); + } + + /** + * %heading;. + * @param group CMGroupImpl Return values. + */ + public final void getHeading(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(HEADING).iterator()); + } + + /** + * Create element declarations and store them + * into a <code>CMGroupImpl</code> instance. + * @param group CMGroupImpl Return values. + */ + public final void getInline(CMGroupImpl group) { + if (group == null) + return; + getFontstyle(group); + getPhrase(group); + getSpecial(group); + getFormctrl(group); + } + + /** + * %list;. + * @param group CMGroupImpl Return values. + */ + public final void getList(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(LIST).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getPhrase(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(PHRASE).iterator()); + } + + /** + * %preformatted; + * @param group CMGroupImpl Return values. + */ + public final void getPreformatted(CMGroupImpl group) { + if (group == null) + return; + + getDeclarations(group, Arrays.asList(PREFORMATTED).iterator()); + } + + /** + * Create element declarations and store them into a <code>CMGroupImpl</code> + * instance.<br> + * @param group CMGroupImpl Return values. + */ + public final void getSpecial(CMGroupImpl group) { + if (group == null) + return; + getDeclarations(group, Arrays.asList(SPECIAL).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java new file mode 100644 index 0000000000..1ae092584c --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/EntityCollection.java @@ -0,0 +1,837 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.lang.reflect.Field; + +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * Factory for entity declarations. + */ +final class EntityCollection extends DeclCollection implements org.eclipse.wst.html.core.HTML40Namespace.EntityName { + + + private static class Ids { + public static final int ID_AACUTE_L = 0; + public static final int ID_AACUTE_U = 1; + public static final int ID_ACIRC_L = 2; + public static final int ID_ACIRC_U = 3; + public static final int ID_ACUTE = 4; + public static final int ID_AELIG_L = 5; + public static final int ID_AELIG_U = 6; + public static final int ID_AGRAVE_L = 7; + public static final int ID_AGRAVE_U = 8; + public static final int ID_ALEFSYM = 9; + public static final int ID_ALPHA_L = 10; + public static final int ID_ALPHA_U = 11; + public static final int ID_AMP = 12; + public static final int ID_AND = 13; + public static final int ID_ANG = 14; + public static final int ID_ARING_L = 15; + public static final int ID_ARING_U = 16; + public static final int ID_ASYMP = 17; + public static final int ID_ATILDE_L = 18; + public static final int ID_ATILDE_U = 19; + public static final int ID_AUML_L = 20; + public static final int ID_AUML_U = 21; + public static final int ID_BDQUO = 22; + public static final int ID_BETA_L = 23; + public static final int ID_BETA_U = 24; + public static final int ID_BRVBAR = 25; + public static final int ID_BULL = 26; + public static final int ID_CAP = 27; + public static final int ID_CCEDIL_L = 28; + public static final int ID_CCEDIL_U = 29; + public static final int ID_CEDIL = 30; + public static final int ID_CENT = 31; + public static final int ID_CHI_L = 32; + public static final int ID_CHI_U = 33; + public static final int ID_CIRC = 34; + public static final int ID_CLUBS = 35; + public static final int ID_CONG = 36; + public static final int ID_COPY = 37; + public static final int ID_CRARR = 38; + public static final int ID_CUP = 39; + public static final int ID_CURREN = 40; + public static final int ID_DAGGER_L = 41; + public static final int ID_DAGGER_U = 42; + public static final int ID_DARR_L = 43; + public static final int ID_DARR_U = 44; + public static final int ID_DEG = 45; + public static final int ID_DELTA_L = 46; + public static final int ID_DELTA_U = 47; + public static final int ID_DIAMS = 48; + public static final int ID_DIVIDE = 49; + public static final int ID_EACUTE_L = 50; + public static final int ID_EACUTE_U = 51; + public static final int ID_ECIRC_L = 52; + public static final int ID_ECIRC_U = 53; + public static final int ID_EGRAVE_L = 54; + public static final int ID_EGRAVE_U = 55; + public static final int ID_EMPTY = 56; + public static final int ID_EMSP = 57; + public static final int ID_ENSP = 58; + public static final int ID_EPSILON_L = 59; + public static final int ID_EPSILON_U = 60; + public static final int ID_EQUIV = 61; + public static final int ID_ETA_L = 62; + public static final int ID_ETA_U = 63; + public static final int ID_ETH_L = 64; + public static final int ID_ETH_U = 65; + public static final int ID_EUML_L = 66; + public static final int ID_EUML_U = 67; + public static final int ID_EURO = 68; + public static final int ID_EXIST = 69; + public static final int ID_FNOF = 70; + public static final int ID_FORALL = 71; + public static final int ID_FRAC12 = 72; + public static final int ID_FRAC14 = 73; + public static final int ID_FRAC34 = 74; + public static final int ID_FRASL = 75; + public static final int ID_GAMMA_L = 76; + public static final int ID_GAMMA_U = 77; + public static final int ID_GE = 78; + public static final int ID_GT = 79; + public static final int ID_HARR_L = 80; + public static final int ID_HARR_U = 81; + public static final int ID_HEARTS = 82; + public static final int ID_HELLIP = 83; + public static final int ID_IACUTE_L = 84; + public static final int ID_IACUTE_U = 85; + public static final int ID_ICIRC_L = 86; + public static final int ID_ICIRC_U = 87; + public static final int ID_IEXCL = 88; + public static final int ID_IGRAVE_L = 89; + public static final int ID_IGRAVE_U = 90; + public static final int ID_IMAGE = 91; + public static final int ID_INFIN = 92; + public static final int ID_INT = 93; + public static final int ID_IOTA_L = 94; + public static final int ID_IOTA_U = 95; + public static final int ID_IQUEST = 96; + public static final int ID_ISIN = 97; + public static final int ID_IUML_L = 98; + public static final int ID_IUML_U = 99; + public static final int ID_KAPPA_L = 100; + public static final int ID_KAPPA_U = 101; + public static final int ID_LAMBDA_L = 102; + public static final int ID_LAMBDA_U = 103; + public static final int ID_LANG = 104; + public static final int ID_LAQUO = 105; + public static final int ID_LARR_L = 106; + public static final int ID_LARR_U = 107; + public static final int ID_LCEIL = 108; + public static final int ID_LDQUO = 109; + public static final int ID_LE = 110; + public static final int ID_LFLOOR = 111; + public static final int ID_LOWAST = 112; + public static final int ID_LOZ = 113; + public static final int ID_LRM = 114; + public static final int ID_LSAQUO = 115; + public static final int ID_LSQUO = 116; + public static final int ID_LT = 117; + public static final int ID_MACR = 118; + public static final int ID_MDASH = 119; + public static final int ID_MICRO = 120; + public static final int ID_MIDDOT = 121; + public static final int ID_MINUS = 122; + public static final int ID_MU_L = 123; + public static final int ID_MU_U = 124; + public static final int ID_NABLA = 125; + public static final int ID_NBSP = 126; + public static final int ID_NDASH = 127; + public static final int ID_NE = 128; + public static final int ID_NI = 129; + public static final int ID_NOT = 130; + public static final int ID_NOTIN = 131; + public static final int ID_NSUB = 132; + public static final int ID_NTILDE_L = 133; + public static final int ID_NTILDE_U = 134; + public static final int ID_NU_L = 135; + public static final int ID_NU_U = 136; + public static final int ID_OACUTE_L = 137; + public static final int ID_OACUTE_U = 138; + public static final int ID_OCIRC_L = 139; + public static final int ID_OCIRC_U = 140; + public static final int ID_OELIG_L = 141; + public static final int ID_OELIG_U = 142; + public static final int ID_OGRAVE_L = 143; + public static final int ID_OGRAVE_U = 144; + public static final int ID_OLINE = 145; + public static final int ID_OMEGA_L = 146; + public static final int ID_OMEGA_U = 147; + public static final int ID_OMICRON_L = 148; + public static final int ID_OMICRON_U = 149; + public static final int ID_OPLUS = 150; + public static final int ID_OR = 151; + public static final int ID_ORDF = 152; + public static final int ID_ORDM = 153; + public static final int ID_OSLASH_L = 154; + public static final int ID_OSLASH_U = 155; + public static final int ID_OTILDE_L = 156; + public static final int ID_OTILDE_U = 157; + public static final int ID_OTIMES = 158; + public static final int ID_OUML_L = 159; + public static final int ID_OUML_U = 160; + public static final int ID_PARA = 161; + public static final int ID_PART = 162; + public static final int ID_PERMIL = 163; + public static final int ID_PERP = 164; + public static final int ID_PHI_L = 165; + public static final int ID_PHI_U = 166; + public static final int ID_PIV = 167; + public static final int ID_PI_L = 168; + public static final int ID_PI_U = 169; + public static final int ID_PLUSMN = 170; + public static final int ID_POUND = 171; + public static final int ID_PRIME_L = 172; + public static final int ID_PRIME_U = 173; + public static final int ID_PROD = 174; + public static final int ID_PROP = 175; + public static final int ID_PSI_L = 176; + public static final int ID_PSI_U = 177; + public static final int ID_QUOT = 178; + public static final int ID_RADIC = 179; + public static final int ID_RANG = 180; + public static final int ID_RAQUO = 181; + public static final int ID_RARR_L = 182; + public static final int ID_RARR_U = 183; + public static final int ID_RCEIL = 184; + public static final int ID_RDQUO = 185; + public static final int ID_REAL = 186; + public static final int ID_REG = 187; + public static final int ID_RFLOOR = 188; + public static final int ID_RHO_L = 189; + public static final int ID_RHO_U = 190; + public static final int ID_RLM = 191; + public static final int ID_RSAQUO = 192; + public static final int ID_RSQUO = 193; + public static final int ID_SBQUO = 194; + public static final int ID_SCARON_L = 195; + public static final int ID_SCARON_U = 196; + public static final int ID_SDOT = 197; + public static final int ID_SECT = 198; + public static final int ID_SHY = 199; + public static final int ID_SIGMAF = 200; + public static final int ID_SIGMA_L = 201; + public static final int ID_SIGMA_U = 202; + public static final int ID_SIM = 203; + public static final int ID_SPADES = 204; + public static final int ID_SUB = 205; + public static final int ID_SUBE = 206; + public static final int ID_SUM = 207; + public static final int ID_SUP = 208; + public static final int ID_SUP1 = 209; + public static final int ID_SUP2 = 210; + public static final int ID_SUP3 = 211; + public static final int ID_SUPE = 212; + public static final int ID_SZLIG = 213; + public static final int ID_TAU_L = 214; + public static final int ID_TAU_U = 215; + public static final int ID_THERE4 = 216; + public static final int ID_THETASYM = 217; + public static final int ID_THETA_L = 218; + public static final int ID_THETA_U = 219; + public static final int ID_THINSP = 220; + public static final int ID_THORN_L = 221; + public static final int ID_THORN_U = 222; + public static final int ID_TILDE = 223; + public static final int ID_TIMES = 224; + public static final int ID_TRADE = 225; + public static final int ID_UACUTE_L = 226; + public static final int ID_UACUTE_U = 227; + public static final int ID_UARR_L = 228; + public static final int ID_UARR_U = 229; + public static final int ID_UCIRC_L = 230; + public static final int ID_UCIRC_U = 231; + public static final int ID_UGRAVE_L = 232; + public static final int ID_UGRAVE_U = 233; + public static final int ID_UML = 234; + public static final int ID_UPSIH = 235; + public static final int ID_UPSILON_L = 236; + public static final int ID_UPSILON_U = 237; + public static final int ID_UUML_L = 238; + public static final int ID_UUML_U = 239; + public static final int ID_WEIERP = 240; + public static final int ID_XI_L = 241; + public static final int ID_XI_U = 242; + public static final int ID_YACUTE_L = 243; + public static final int ID_YACUTE_U = 244; + public static final int ID_YEN = 245; + public static final int ID_YUML_L = 246; + public static final int ID_YUML_U = 247; + public static final int ID_ZETA_L = 248; + public static final int ID_ZETA_U = 249; + public static final int ID_ZWJ = 250; + public static final int ID_ZWNJ = 251; + + public static int getNumOfIds() { + if (numofids != -1) + return numofids; + + // NOTE: If the reflection is too slow, this method should + // just return the literal value, like 252. + // -- 5/24/2001 + Class clazz = Ids.class; + Field[] fields = clazz.getFields(); + numofids = 0; + for (int i = 0; i < fields.length; i++) { + String name = fields[i].getName(); + if (name.startsWith("ID_"))//$NON-NLS-1$ + numofids++; + } + return numofids; + } + + // chache the result of the reflection. + private static int numofids = -1; + } + + private static String[] names = null; + + static { + names = new String[Ids.getNumOfIds()]; + names[Ids.ID_AACUTE_L] = AACUTE_L; + names[Ids.ID_AACUTE_U] = AACUTE_U; + names[Ids.ID_ACIRC_L] = ACIRC_L; + names[Ids.ID_ACIRC_U] = ACIRC_U; + names[Ids.ID_ACUTE] = ACUTE; + names[Ids.ID_AELIG_L] = AELIG_L; + names[Ids.ID_AELIG_U] = AELIG_U; + names[Ids.ID_AGRAVE_L] = AGRAVE_L; + names[Ids.ID_AGRAVE_U] = AGRAVE_U; + names[Ids.ID_ALEFSYM] = ALEFSYM; + names[Ids.ID_ALPHA_L] = ALPHA_L; + names[Ids.ID_ALPHA_U] = ALPHA_U; + names[Ids.ID_AMP] = AMP; + names[Ids.ID_AND] = AND; + names[Ids.ID_ANG] = ANG; + names[Ids.ID_ARING_L] = ARING_L; + names[Ids.ID_ARING_U] = ARING_U; + names[Ids.ID_ASYMP] = ASYMP; + names[Ids.ID_ATILDE_L] = ATILDE_L; + names[Ids.ID_ATILDE_U] = ATILDE_U; + names[Ids.ID_AUML_L] = AUML_L; + names[Ids.ID_AUML_U] = AUML_U; + names[Ids.ID_BDQUO] = BDQUO; + names[Ids.ID_BETA_L] = BETA_L; + names[Ids.ID_BETA_U] = BETA_U; + names[Ids.ID_BRVBAR] = BRVBAR; + names[Ids.ID_BULL] = BULL; + names[Ids.ID_CAP] = CAP; + names[Ids.ID_CCEDIL_L] = CCEDIL_L; + names[Ids.ID_CCEDIL_U] = CCEDIL_U; + names[Ids.ID_CEDIL] = CEDIL; + names[Ids.ID_CENT] = CENT; + names[Ids.ID_CHI_L] = CHI_L; + names[Ids.ID_CHI_U] = CHI_U; + names[Ids.ID_CIRC] = CIRC; + names[Ids.ID_CLUBS] = CLUBS; + names[Ids.ID_CONG] = CONG; + names[Ids.ID_COPY] = COPY; + names[Ids.ID_CRARR] = CRARR; + names[Ids.ID_CUP] = CUP; + names[Ids.ID_CURREN] = CURREN; + names[Ids.ID_DAGGER_L] = DAGGER_L; + names[Ids.ID_DAGGER_U] = DAGGER_U; + names[Ids.ID_DARR_L] = DARR_L; + names[Ids.ID_DARR_U] = DARR_U; + names[Ids.ID_DEG] = DEG; + names[Ids.ID_DELTA_L] = DELTA_L; + names[Ids.ID_DELTA_U] = DELTA_U; + names[Ids.ID_DIAMS] = DIAMS; + names[Ids.ID_DIVIDE] = DIVIDE; + names[Ids.ID_EACUTE_L] = EACUTE_L; + names[Ids.ID_EACUTE_U] = EACUTE_U; + names[Ids.ID_ECIRC_L] = ECIRC_L; + names[Ids.ID_ECIRC_U] = ECIRC_U; + names[Ids.ID_EGRAVE_L] = EGRAVE_L; + names[Ids.ID_EGRAVE_U] = EGRAVE_U; + names[Ids.ID_EMPTY] = EMPTY; + names[Ids.ID_EMSP] = EMSP; + names[Ids.ID_ENSP] = ENSP; + names[Ids.ID_EPSILON_L] = EPSILON_L; + names[Ids.ID_EPSILON_U] = EPSILON_U; + names[Ids.ID_EQUIV] = EQUIV; + names[Ids.ID_ETA_L] = ETA_L; + names[Ids.ID_ETA_U] = ETA_U; + names[Ids.ID_ETH_L] = ETH_L; + names[Ids.ID_ETH_U] = ETH_U; + names[Ids.ID_EUML_L] = EUML_L; + names[Ids.ID_EUML_U] = EUML_U; + names[Ids.ID_EURO] = EURO; + names[Ids.ID_EXIST] = EXIST; + names[Ids.ID_FNOF] = FNOF; + names[Ids.ID_FORALL] = FORALL; + names[Ids.ID_FRAC12] = FRAC12; + names[Ids.ID_FRAC14] = FRAC14; + names[Ids.ID_FRAC34] = FRAC34; + names[Ids.ID_FRASL] = FRASL; + names[Ids.ID_GAMMA_L] = GAMMA_L; + names[Ids.ID_GAMMA_U] = GAMMA_U; + names[Ids.ID_GE] = GE; + names[Ids.ID_GT] = GT; + names[Ids.ID_HARR_L] = HARR_L; + names[Ids.ID_HARR_U] = HARR_U; + names[Ids.ID_HEARTS] = HEARTS; + names[Ids.ID_HELLIP] = HELLIP; + names[Ids.ID_IACUTE_L] = IACUTE_L; + names[Ids.ID_IACUTE_U] = IACUTE_U; + names[Ids.ID_ICIRC_L] = ICIRC_L; + names[Ids.ID_ICIRC_U] = ICIRC_U; + names[Ids.ID_IEXCL] = IEXCL; + names[Ids.ID_IGRAVE_L] = IGRAVE_L; + names[Ids.ID_IGRAVE_U] = IGRAVE_U; + names[Ids.ID_IMAGE] = IMAGE; + names[Ids.ID_INFIN] = INFIN; + names[Ids.ID_INT] = INT; + names[Ids.ID_IOTA_L] = IOTA_L; + names[Ids.ID_IOTA_U] = IOTA_U; + names[Ids.ID_IQUEST] = IQUEST; + names[Ids.ID_ISIN] = ISIN; + names[Ids.ID_IUML_L] = IUML_L; + names[Ids.ID_IUML_U] = IUML_U; + names[Ids.ID_KAPPA_L] = KAPPA_L; + names[Ids.ID_KAPPA_U] = KAPPA_U; + names[Ids.ID_LAMBDA_L] = LAMBDA_L; + names[Ids.ID_LAMBDA_U] = LAMBDA_U; + names[Ids.ID_LANG] = LANG; + names[Ids.ID_LAQUO] = LAQUO; + names[Ids.ID_LARR_L] = LARR_L; + names[Ids.ID_LARR_U] = LARR_U; + names[Ids.ID_LCEIL] = LCEIL; + names[Ids.ID_LDQUO] = LDQUO; + names[Ids.ID_LE] = LE; + names[Ids.ID_LFLOOR] = LFLOOR; + names[Ids.ID_LOWAST] = LOWAST; + names[Ids.ID_LOZ] = LOZ; + names[Ids.ID_LRM] = LRM; + names[Ids.ID_LSAQUO] = LSAQUO; + names[Ids.ID_LSQUO] = LSQUO; + names[Ids.ID_LT] = LT; + names[Ids.ID_MACR] = MACR; + names[Ids.ID_MDASH] = MDASH; + names[Ids.ID_MICRO] = MICRO; + names[Ids.ID_MIDDOT] = MIDDOT; + names[Ids.ID_MINUS] = MINUS; + names[Ids.ID_MU_L] = MU_L; + names[Ids.ID_MU_U] = MU_U; + names[Ids.ID_NABLA] = NABLA; + names[Ids.ID_NBSP] = NBSP; + names[Ids.ID_NDASH] = NDASH; + names[Ids.ID_NE] = NE; + names[Ids.ID_NI] = NI; + names[Ids.ID_NOT] = NOT; + names[Ids.ID_NOTIN] = NOTIN; + names[Ids.ID_NSUB] = NSUB; + names[Ids.ID_NTILDE_L] = NTILDE_L; + names[Ids.ID_NTILDE_U] = NTILDE_U; + names[Ids.ID_NU_L] = NU_L; + names[Ids.ID_NU_U] = NU_U; + names[Ids.ID_OACUTE_L] = OACUTE_L; + names[Ids.ID_OACUTE_U] = OACUTE_U; + names[Ids.ID_OCIRC_L] = OCIRC_L; + names[Ids.ID_OCIRC_U] = OCIRC_U; + names[Ids.ID_OELIG_L] = OELIG_L; + names[Ids.ID_OELIG_U] = OELIG_U; + names[Ids.ID_OGRAVE_L] = OGRAVE_L; + names[Ids.ID_OGRAVE_U] = OGRAVE_U; + names[Ids.ID_OLINE] = OLINE; + names[Ids.ID_OMEGA_L] = OMEGA_L; + names[Ids.ID_OMEGA_U] = OMEGA_U; + names[Ids.ID_OMICRON_L] = OMICRON_L; + names[Ids.ID_OMICRON_U] = OMICRON_U; + names[Ids.ID_OPLUS] = OPLUS; + names[Ids.ID_OR] = OR; + names[Ids.ID_ORDF] = ORDF; + names[Ids.ID_ORDM] = ORDM; + names[Ids.ID_OSLASH_L] = OSLASH_L; + names[Ids.ID_OSLASH_U] = OSLASH_U; + names[Ids.ID_OTILDE_L] = OTILDE_L; + names[Ids.ID_OTILDE_U] = OTILDE_U; + names[Ids.ID_OTIMES] = OTIMES; + names[Ids.ID_OUML_L] = OUML_L; + names[Ids.ID_OUML_U] = OUML_U; + names[Ids.ID_PARA] = PARA; + names[Ids.ID_PART] = PART; + names[Ids.ID_PERMIL] = PERMIL; + names[Ids.ID_PERP] = PERP; + names[Ids.ID_PHI_L] = PHI_L; + names[Ids.ID_PHI_U] = PHI_U; + names[Ids.ID_PIV] = PIV; + names[Ids.ID_PI_L] = PI_L; + names[Ids.ID_PI_U] = PI_U; + names[Ids.ID_PLUSMN] = PLUSMN; + names[Ids.ID_POUND] = POUND; + names[Ids.ID_PRIME_L] = PRIME_L; + names[Ids.ID_PRIME_U] = PRIME_U; + names[Ids.ID_PROD] = PROD; + names[Ids.ID_PROP] = PROP; + names[Ids.ID_PSI_L] = PSI_L; + names[Ids.ID_PSI_U] = PSI_U; + names[Ids.ID_QUOT] = QUOT; + names[Ids.ID_RADIC] = RADIC; + names[Ids.ID_RANG] = RANG; + names[Ids.ID_RAQUO] = RAQUO; + names[Ids.ID_RARR_L] = RARR_L; + names[Ids.ID_RARR_U] = RARR_U; + names[Ids.ID_RCEIL] = RCEIL; + names[Ids.ID_RDQUO] = RDQUO; + names[Ids.ID_REAL] = REAL; + names[Ids.ID_REG] = REG; + names[Ids.ID_RFLOOR] = RFLOOR; + names[Ids.ID_RHO_L] = RHO_L; + names[Ids.ID_RHO_U] = RHO_U; + names[Ids.ID_RLM] = RLM; + names[Ids.ID_RSAQUO] = RSAQUO; + names[Ids.ID_RSQUO] = RSQUO; + names[Ids.ID_SBQUO] = SBQUO; + names[Ids.ID_SCARON_L] = SCARON_L; + names[Ids.ID_SCARON_U] = SCARON_U; + names[Ids.ID_SDOT] = SDOT; + names[Ids.ID_SECT] = SECT; + names[Ids.ID_SHY] = SHY; + names[Ids.ID_SIGMAF] = SIGMAF; + names[Ids.ID_SIGMA_L] = SIGMA_L; + names[Ids.ID_SIGMA_U] = SIGMA_U; + names[Ids.ID_SIM] = SIM; + names[Ids.ID_SPADES] = SPADES; + names[Ids.ID_SUB] = SUB; + names[Ids.ID_SUBE] = SUBE; + names[Ids.ID_SUM] = SUM; + names[Ids.ID_SUP] = SUP; + names[Ids.ID_SUP1] = SUP1; + names[Ids.ID_SUP2] = SUP2; + names[Ids.ID_SUP3] = SUP3; + names[Ids.ID_SUPE] = SUPE; + names[Ids.ID_SZLIG] = SZLIG; + names[Ids.ID_TAU_L] = TAU_L; + names[Ids.ID_TAU_U] = TAU_U; + names[Ids.ID_THERE4] = THERE4; + names[Ids.ID_THETASYM] = THETASYM; + names[Ids.ID_THETA_L] = THETA_L; + names[Ids.ID_THETA_U] = THETA_U; + names[Ids.ID_THINSP] = THINSP; + names[Ids.ID_THORN_L] = THORN_L; + names[Ids.ID_THORN_U] = THORN_U; + names[Ids.ID_TILDE] = TILDE; + names[Ids.ID_TIMES] = TIMES; + names[Ids.ID_TRADE] = TRADE; + names[Ids.ID_UACUTE_L] = UACUTE_L; + names[Ids.ID_UACUTE_U] = UACUTE_U; + names[Ids.ID_UARR_L] = UARR_L; + names[Ids.ID_UARR_U] = UARR_U; + names[Ids.ID_UCIRC_L] = UCIRC_L; + names[Ids.ID_UCIRC_U] = UCIRC_U; + names[Ids.ID_UGRAVE_L] = UGRAVE_L; + names[Ids.ID_UGRAVE_U] = UGRAVE_U; + names[Ids.ID_UML] = UML; + names[Ids.ID_UPSIH] = UPSIH; + names[Ids.ID_UPSILON_L] = UPSILON_L; + names[Ids.ID_UPSILON_U] = UPSILON_U; + names[Ids.ID_UUML_L] = UUML_L; + names[Ids.ID_UUML_U] = UUML_U; + names[Ids.ID_WEIERP] = WEIERP; + names[Ids.ID_XI_L] = XI_L; + names[Ids.ID_XI_U] = XI_U; + names[Ids.ID_YACUTE_L] = YACUTE_L; + names[Ids.ID_YACUTE_U] = YACUTE_U; + names[Ids.ID_YEN] = YEN; + names[Ids.ID_YUML_L] = YUML_L; + names[Ids.ID_YUML_U] = YUML_U; + names[Ids.ID_ZETA_L] = ZETA_L; + names[Ids.ID_ZETA_U] = ZETA_U; + names[Ids.ID_ZWJ] = ZWJ; + names[Ids.ID_ZWNJ] = ZWNJ; + } + private static char[] values = null; + + static { + values = new char[Ids.getNumOfIds()]; + values[Ids.ID_AACUTE_L] = 225; + values[Ids.ID_AACUTE_U] = 193; + values[Ids.ID_ACIRC_L] = 226; + values[Ids.ID_ACIRC_U] = 194; + values[Ids.ID_ACUTE] = 180; + values[Ids.ID_AELIG_L] = 230; + values[Ids.ID_AELIG_U] = 198; + values[Ids.ID_AGRAVE_L] = 224; + values[Ids.ID_AGRAVE_U] = 192; + values[Ids.ID_ALEFSYM] = 8501; + values[Ids.ID_ALPHA_L] = 945; + values[Ids.ID_ALPHA_U] = 913; + values[Ids.ID_AMP] = 38; + values[Ids.ID_AND] = 8743; + values[Ids.ID_ANG] = 8736; + values[Ids.ID_ARING_L] = 229; + values[Ids.ID_ARING_U] = 197; + values[Ids.ID_ASYMP] = 8776; + values[Ids.ID_ATILDE_L] = 227; + values[Ids.ID_ATILDE_U] = 195; + values[Ids.ID_AUML_L] = 228; + values[Ids.ID_AUML_U] = 196; + values[Ids.ID_BDQUO] = 8222; + values[Ids.ID_BETA_L] = 946; + values[Ids.ID_BETA_U] = 914; + values[Ids.ID_BRVBAR] = 166; + values[Ids.ID_BULL] = 8226; + values[Ids.ID_CAP] = 8745; + values[Ids.ID_CCEDIL_L] = 231; + values[Ids.ID_CCEDIL_U] = 199; + values[Ids.ID_CEDIL] = 184; + values[Ids.ID_CENT] = 162; + values[Ids.ID_CHI_L] = 967; + values[Ids.ID_CHI_U] = 935; + values[Ids.ID_CIRC] = 710; + values[Ids.ID_CLUBS] = 9827; + values[Ids.ID_CONG] = 8773; + values[Ids.ID_COPY] = 169; + values[Ids.ID_CRARR] = 8629; + values[Ids.ID_CUP] = 8746; + values[Ids.ID_CURREN] = 164; + values[Ids.ID_DAGGER_L] = 8224; + values[Ids.ID_DAGGER_U] = 8225; + values[Ids.ID_DARR_L] = 8595; + values[Ids.ID_DARR_U] = 8659; + values[Ids.ID_DEG] = 176; + values[Ids.ID_DELTA_L] = 948; + values[Ids.ID_DELTA_U] = 916; + values[Ids.ID_DIAMS] = 9830; + values[Ids.ID_DIVIDE] = 247; + values[Ids.ID_EACUTE_L] = 233; + values[Ids.ID_EACUTE_U] = 201; + values[Ids.ID_ECIRC_L] = 234; + values[Ids.ID_ECIRC_U] = 202; + values[Ids.ID_EGRAVE_L] = 232; + values[Ids.ID_EGRAVE_U] = 200; + values[Ids.ID_EMPTY] = 8709; + values[Ids.ID_EMSP] = 8195; + values[Ids.ID_ENSP] = 8194; + values[Ids.ID_EPSILON_L] = 949; + values[Ids.ID_EPSILON_U] = 917; + values[Ids.ID_EQUIV] = 8801; + values[Ids.ID_ETA_L] = 951; + values[Ids.ID_ETA_U] = 919; + values[Ids.ID_ETH_L] = 240; + values[Ids.ID_ETH_U] = 208; + values[Ids.ID_EUML_L] = 235; + values[Ids.ID_EUML_U] = 203; + values[Ids.ID_EURO] = 8364; + values[Ids.ID_EXIST] = 8707; + values[Ids.ID_FNOF] = 402; + values[Ids.ID_FORALL] = 8704; + values[Ids.ID_FRAC12] = 189; + values[Ids.ID_FRAC14] = 188; + values[Ids.ID_FRAC34] = 190; + values[Ids.ID_FRASL] = 8260; + values[Ids.ID_GAMMA_L] = 947; + values[Ids.ID_GAMMA_U] = 915; + values[Ids.ID_GE] = 8805; + values[Ids.ID_GT] = 62; + values[Ids.ID_HARR_L] = 8596; + values[Ids.ID_HARR_U] = 8660; + values[Ids.ID_HEARTS] = 9829; + values[Ids.ID_HELLIP] = 8230; + values[Ids.ID_IACUTE_L] = 237; + values[Ids.ID_IACUTE_U] = 205; + values[Ids.ID_ICIRC_L] = 238; + values[Ids.ID_ICIRC_U] = 206; + values[Ids.ID_IEXCL] = 161; + values[Ids.ID_IGRAVE_L] = 236; + values[Ids.ID_IGRAVE_U] = 204; + values[Ids.ID_IMAGE] = 8465; + values[Ids.ID_INFIN] = 8734; + values[Ids.ID_INT] = 8747; + values[Ids.ID_IOTA_L] = 953; + values[Ids.ID_IOTA_U] = 921; + values[Ids.ID_IQUEST] = 191; + values[Ids.ID_ISIN] = 8712; + values[Ids.ID_IUML_L] = 239; + values[Ids.ID_IUML_U] = 207; + values[Ids.ID_KAPPA_L] = 954; + values[Ids.ID_KAPPA_U] = 922; + values[Ids.ID_LAMBDA_L] = 955; + values[Ids.ID_LAMBDA_U] = 923; + values[Ids.ID_LANG] = 9001; + values[Ids.ID_LAQUO] = 171; + values[Ids.ID_LARR_L] = 8592; + values[Ids.ID_LARR_U] = 8656; + values[Ids.ID_LCEIL] = 8968; + values[Ids.ID_LDQUO] = 8220; + values[Ids.ID_LE] = 8804; + values[Ids.ID_LFLOOR] = 8970; + values[Ids.ID_LOWAST] = 8727; + values[Ids.ID_LOZ] = 9674; + values[Ids.ID_LRM] = 8206; + values[Ids.ID_LSAQUO] = 8249; + values[Ids.ID_LSQUO] = 8216; + values[Ids.ID_LT] = 60; + values[Ids.ID_MACR] = 175; + values[Ids.ID_MDASH] = 8212; + values[Ids.ID_MICRO] = 181; + values[Ids.ID_MIDDOT] = 183; + values[Ids.ID_MINUS] = 8722; + values[Ids.ID_MU_L] = 956; + values[Ids.ID_MU_U] = 924; + values[Ids.ID_NABLA] = 8711; + values[Ids.ID_NBSP] = 160; + values[Ids.ID_NDASH] = 8211; + values[Ids.ID_NE] = 8800; + values[Ids.ID_NI] = 8715; + values[Ids.ID_NOT] = 172; + values[Ids.ID_NOTIN] = 8713; + values[Ids.ID_NSUB] = 8836; + values[Ids.ID_NTILDE_L] = 241; + values[Ids.ID_NTILDE_U] = 209; + values[Ids.ID_NU_L] = 957; + values[Ids.ID_NU_U] = 925; + values[Ids.ID_OACUTE_L] = 243; + values[Ids.ID_OACUTE_U] = 211; + values[Ids.ID_OCIRC_L] = 244; + values[Ids.ID_OCIRC_U] = 212; + values[Ids.ID_OELIG_L] = 339; + values[Ids.ID_OELIG_U] = 338; + values[Ids.ID_OGRAVE_L] = 242; + values[Ids.ID_OGRAVE_U] = 210; + values[Ids.ID_OLINE] = 8254; + values[Ids.ID_OMEGA_L] = 969; + values[Ids.ID_OMEGA_U] = 937; + values[Ids.ID_OMICRON_L] = 959; + values[Ids.ID_OMICRON_U] = 927; + values[Ids.ID_OPLUS] = 8853; + values[Ids.ID_OR] = 8744; + values[Ids.ID_ORDF] = 170; + values[Ids.ID_ORDM] = 186; + values[Ids.ID_OSLASH_L] = 248; + values[Ids.ID_OSLASH_U] = 216; + values[Ids.ID_OTILDE_L] = 245; + values[Ids.ID_OTILDE_U] = 213; + values[Ids.ID_OTIMES] = 8855; + values[Ids.ID_OUML_L] = 246; + values[Ids.ID_OUML_U] = 214; + values[Ids.ID_PARA] = 182; + values[Ids.ID_PART] = 8706; + values[Ids.ID_PERMIL] = 8240; + values[Ids.ID_PERP] = 8869; + values[Ids.ID_PHI_L] = 966; + values[Ids.ID_PHI_U] = 934; + values[Ids.ID_PIV] = 982; + values[Ids.ID_PI_L] = 960; + values[Ids.ID_PI_U] = 928; + values[Ids.ID_PLUSMN] = 177; + values[Ids.ID_POUND] = 163; + values[Ids.ID_PRIME_L] = 8242; + values[Ids.ID_PRIME_U] = 8243; + values[Ids.ID_PROD] = 8719; + values[Ids.ID_PROP] = 8733; + values[Ids.ID_PSI_L] = 968; + values[Ids.ID_PSI_U] = 936; + values[Ids.ID_QUOT] = 34; + values[Ids.ID_RADIC] = 8730; + values[Ids.ID_RANG] = 9002; + values[Ids.ID_RAQUO] = 187; + values[Ids.ID_RARR_L] = 8594; + values[Ids.ID_RARR_U] = 8658; + values[Ids.ID_RCEIL] = 8969; + values[Ids.ID_RDQUO] = 8221; + values[Ids.ID_REAL] = 8476; + values[Ids.ID_REG] = 174; + values[Ids.ID_RFLOOR] = 8971; + values[Ids.ID_RHO_L] = 961; + values[Ids.ID_RHO_U] = 929; + values[Ids.ID_RLM] = 8207; + values[Ids.ID_RSAQUO] = 8250; + values[Ids.ID_RSQUO] = 8217; + values[Ids.ID_SBQUO] = 8218; + values[Ids.ID_SCARON_L] = 353; + values[Ids.ID_SCARON_U] = 352; + values[Ids.ID_SDOT] = 8901; + values[Ids.ID_SECT] = 167; + values[Ids.ID_SHY] = 173; + values[Ids.ID_SIGMAF] = 962; + values[Ids.ID_SIGMA_L] = 963; + values[Ids.ID_SIGMA_U] = 931; + values[Ids.ID_SIM] = 8764; + values[Ids.ID_SPADES] = 9824; + values[Ids.ID_SUB] = 8834; + values[Ids.ID_SUBE] = 8838; + values[Ids.ID_SUM] = 8721; + values[Ids.ID_SUP] = 8835; + values[Ids.ID_SUP1] = 185; + values[Ids.ID_SUP2] = 178; + values[Ids.ID_SUP3] = 179; + values[Ids.ID_SUPE] = 8839; + values[Ids.ID_SZLIG] = 223; + values[Ids.ID_TAU_L] = 964; + values[Ids.ID_TAU_U] = 932; + values[Ids.ID_THERE4] = 8756; + values[Ids.ID_THETASYM] = 977; + values[Ids.ID_THETA_L] = 952; + values[Ids.ID_THETA_U] = 920; + values[Ids.ID_THINSP] = 8201; + values[Ids.ID_THORN_L] = 254; + values[Ids.ID_THORN_U] = 222; + values[Ids.ID_TILDE] = 732; + values[Ids.ID_TIMES] = 215; + values[Ids.ID_TRADE] = 8482; + values[Ids.ID_UACUTE_L] = 250; + values[Ids.ID_UACUTE_U] = 218; + values[Ids.ID_UARR_L] = 8593; + values[Ids.ID_UARR_U] = 8657; + values[Ids.ID_UCIRC_L] = 251; + values[Ids.ID_UCIRC_U] = 219; + values[Ids.ID_UGRAVE_L] = 249; + values[Ids.ID_UGRAVE_U] = 217; + values[Ids.ID_UML] = 168; + values[Ids.ID_UPSIH] = 978; + values[Ids.ID_UPSILON_L] = 965; + values[Ids.ID_UPSILON_U] = 933; + values[Ids.ID_UUML_L] = 252; + values[Ids.ID_UUML_U] = 220; + values[Ids.ID_WEIERP] = 8472; + values[Ids.ID_XI_L] = 958; + values[Ids.ID_XI_U] = 926; + values[Ids.ID_YACUTE_L] = 253; + values[Ids.ID_YACUTE_U] = 221; + values[Ids.ID_YEN] = 165; + values[Ids.ID_YUML_L] = 255; + values[Ids.ID_YUML_U] = 376; + values[Ids.ID_ZETA_L] = 950; + values[Ids.ID_ZETA_U] = 918; + values[Ids.ID_ZWJ] = 8205; + values[Ids.ID_ZWNJ] = 8204; + } + + /** + */ + public EntityCollection() { + super(names, STRICT_CASE); + } + + /** + * Create an entity declaration. + * @return org.eclipse.wst.common.contentmodel.CMNode + * @param attrName java.lang.String + */ + protected CMNode create(String entityName) { + int id = getID(entityName); + if (id == ID_UNKNOWN) + return null; + + String value = String.valueOf(values[id]); + HTMLEntityDeclImpl dec = new HTMLEntityDeclImpl(entityName, value); + + return dec; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java new file mode 100644 index 0000000000..e0fbc52466 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLAttrDeclImpl.java @@ -0,0 +1,118 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Enumeration; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + +/** + * Implementation class of {@link <code>HTMLAttributeDeclaration</code>} interface.<br> + */ +class HTMLAttrDeclImpl extends CMNodeImpl implements HTMLAttributeDeclaration { + + private HTMLCMDataTypeImpl type = null; + private int usage = 0; + + /** + */ + public HTMLAttrDeclImpl(String attrName, HTMLCMDataTypeImpl valueType, int valueUsage) { + super(attrName); + this.type = valueType; + + switch (valueUsage) { + case OPTIONAL : + case REQUIRED : + case FIXED : + case PROHIBITED : + this.usage = valueUsage; + break; + default : + // should warn... + this.usage = OPTIONAL; // fall back + break; + } + } + + /** + * getAttrName method + * @return java.lang.String + */ + public String getAttrName() { + return getNodeName(); + } + + /** + * getAttrType method + * @return CMDataType + */ + public CMDataType getAttrType() { + return type; + } + + /** + * @deprecated in superclass + */ + public String getDefaultValue() { + if (type.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_DEFAULT) + return null; + return type.getImpliedValue(); + } + + /** + * @deprecated in superclass + */ + public Enumeration getEnumAttr() { + Vector v = new Vector(Arrays.asList(type.getEnumeratedValues())); + return v.elements(); + } + + /** + * getNodeType method + * @return int + * + * Returns one of : + * ELEMENT_DECLARATION, ATTRIBUTE_DECLARATION, GROUP, ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ATTRIBUTE_DECLARATION; + } + + /** + * @return int + */ + public int getUsage() { + return usage; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + return super.supports(propertyName); + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java new file mode 100644 index 0000000000..3757c6eea7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMDataTypeImpl.java @@ -0,0 +1,126 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + + + +/** + */ +class HTMLCMDataTypeImpl extends CMNodeImpl implements HTMLCMDataType { + + private int impliedValueKind = IMPLIED_VALUE_NONE; + private String impliedValue = null; + private final static String[] emptyArray = new String[0]; + private String[] enumValues = emptyArray; + private String instanceValue = null; + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName) { + super(typeName); + } + + /** + * HTMLCMDataTypeImpl constructor comment. + * @param nm java.lang.String + */ + public HTMLCMDataTypeImpl(String typeName, String instanceValue) { + super(typeName); + this.instanceValue = instanceValue; + } + + /** + * getTypeName method + * @return java.lang.String + * + * This method returns a suitable default value that can be used when an instance of the data type is created. + * This returns null of a suitable default is not available. + */ + public String generateInstanceValue() { + return instanceValue; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMDataType + */ + public String getDataTypeName() { + return getNodeName(); + } + + /** + * getTypeName method + * @return java.lang.String[] + * + */ + public String[] getEnumeratedValues() { + return enumValues; + } + + /** + * getTypeName method + * @return java.lang.String + * + * Returns the implied value or null if none exists. + */ + public String getImpliedValue() { + return impliedValue; + } + + /** + * getImpliedValueKind method + * @return int + * + * Returns one of : + * IMPLIED_VALUE_NONE, IMPLIED_VALUE_FIXED, IMPLIED_VALUE_DEFAULT. + */ + public int getImpliedValueKind() { + return impliedValueKind; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.DATA_TYPE; + } + + /** + */ + void setEnumValues(String[] values) { + enumValues = new String[values.length]; + for (int i = 0; i < values.length; i++) { + enumValues[i] = values[i]; + } + } + + /** + * package scope. + */ + void setImpliedValue(int kind, String value) { + switch (kind) { + case IMPLIED_VALUE_FIXED : + case IMPLIED_VALUE_DEFAULT : + impliedValueKind = kind; + impliedValue = value; + break; + case IMPLIED_VALUE_NONE : + default : + impliedValueKind = IMPLIED_VALUE_NONE; + impliedValue = null; // maybe a null string? + break; + } + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java new file mode 100644 index 0000000000..26166410de --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLCMNode.java @@ -0,0 +1,32 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + +/** + * In HTML Documents, name and value of an attribute/element/entity + * should be treated ignoring theirs case. However, in XML documents, + * they should be distinguished with sensitiveness of their case. + * CMNode is basically designed to represent DTDs or Schemas for XML + * documents. So, it doesn't have interfaces to retrieve such information. + * However, declarations in the HTML CM should provide such information. + * This intermediate interface is intended to provide whether ignore cases + * or not.<br> + */ +interface HTMLCMNode extends org.eclipse.wst.common.contentmodel.CMNode { + + /** + * Returns <code>true</code>, if declaration is for HTML attribute/element/entity. + * Otherwise, returns <code>false</code>. + * @return boolean + */ + boolean shouldIgnoreCase(); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java new file mode 100644 index 0000000000..c1fac6421f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLElemDeclImpl.java @@ -0,0 +1,380 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Iterator; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLPropertyDeclaration; + +/** + * Base class for all Hed???? classes. + */ +abstract class HTMLElemDeclImpl extends CMContentImpl implements HTMLElementDeclaration, HTMLPropertyDeclaration { + + // DTD + protected CMNamedNodeMapImpl attributes = null; + protected String typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + /** Never access this field directly. Instead, use getComplexTypeDefinition method. */ + private ComplexTypeDefinition typeDefinition = null; + protected CMGroupImpl inclusion = null; + protected CMGroupImpl exclusion = null; + // advanced information + protected CMNamedNodeMap prohibitedAncestors = null; + protected int correctionType = CORRECT_NONE; + protected int formatType = FORMAT_HTML; + protected int layoutType = LAYOUT_NONE; + protected int omitType = OMIT_NONE; + protected boolean keepSpaces = false; + protected boolean indentChild = false; + protected ElementCollection elementCollection = null; + protected AttributeCollection attributeCollection = null; + protected final static CMNamedNodeMap EMPTY_MAP = new CMNamedNodeMap() { + public int getLength() { + return 0; + } + + public CMNode getNamedItem(String name) { + return null; + } + + public CMNode item(int index) { + return null; + } + + public Iterator iterator() { + return new Iterator() { + public boolean hasNext() { + return false; + } + + public Object next() { + return null; + } + + public void remove() { + } + }; + } + }; + + /** + * HTMLElemDeclImpl constructor. + * In the HTML DTD, an element declaration has no specification + * for its occurrence. Occurrence is specifed in content model, like + * <code>(LI)+</code>. To avoid confusion (and complexity), + * occurrence of an element declaration is always 1 (it means, min = 1 and + * max = 1). Instead, occurrence of CMGroup represents actual occurrence + * of the content. + * <br> + * @param name java.lang.String + */ + public HTMLElemDeclImpl(String elementName, ElementCollection collection) { + super(elementName, 1, 1); + elementCollection = collection; + attributeCollection = collection.getAttributeCollection(); + } + + /** + */ + protected abstract void createAttributeDeclarations(); + + /** + * + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition createComplexTypeDefinition() { + if (typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_CDATA) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_EMPTY) || typeDefinitionName.equals(ComplexTypeDefinitionFactory.CTYPE_PCDATA)) + return null; + + ComplexTypeDefinitionFactory factory = ComplexTypeDefinitionFactory.getInstance(); + if (factory == null) + return null; // fatal error. + + ComplexTypeDefinition def = factory.createTypeDefinition(typeDefinitionName, elementCollection); + return def; + } + + /** + * Get an attribute declaration. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public HTMLAttributeDeclaration getAttributeDeclaration(String attrName) { + if (attributes == null) { + createAttributeDeclarations(); + if (attributes == null) + return null; // fail to create + } + + CMNode cmnode = attributes.getNamedItem(attrName); + if (cmnode == null) { + return null; + } + else { + return (HTMLAttributeDeclaration) cmnode; // already exists. + } + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getAttributes() { + if (attributes == null) + createAttributeDeclarations(); // lazy eval. + return attributes; + } + + /** + * Get an instance of complex type definition. + * @return com.ibm.sed.contentmodel.html.ComplexTypeDefinition + */ + private ComplexTypeDefinition getComplexTypeDefinition() { + if (typeDefinition == null) + typeDefinition = createComplexTypeDefinition(); + return typeDefinition; + } + + /** + * Content.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and always return null. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMContent getContent() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContent() : null; + } + + /** + * Content type.<br> + * Element declarations which type is EMPTY or CDATA (maybe PCDATA) + * <strong>MUST</strong> override this method and return an appropriate type. + * This default implementation always tries to create a complex type definition + * instance and access to it. + * <br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + ComplexTypeDefinition def = getComplexTypeDefinition(); // lazy eval. + return (def != null) ? def.getContentType() : CMElementDeclaration.CDATA; + } + + /** + * @see HTMLElementDeclaration#getCorrectionType + */ + public int getCorrectionType() { + return correctionType; + } + + /** + * HTML element doesn't have any data type. So, this method always + * returns <code>null</code>.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMDataType getDataType() { + return null; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public String getElementName() { + return getNodeName(); + } + + /** + * Exclusion. + * Almost elements don't have a exclusion. + * Only classes those have exclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + return null; + } + + /** + * Default format type is <code>FORMAT_HTML</code>.<br> + */ + public int getFormatType() { + return formatType; + } + + /** + * Inclusion. + * Almost elements don't have a inclusion. + * Only classes those have inclusion should override this method. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getInclusion() { + return null; + } + + /** + */ + public int getLayoutType() { + return layoutType; + } + + /** + * Line break hint is strongly related to layout type. + * Indeed, in the C++DOM, it is determined from layout type only. + * So, this implementation, as the default implementation for all declarations, + * also determines from layout type only.<br> + * @return int + */ + public int getLineBreakHint() { + switch (getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + case HTMLElementDeclaration.LAYOUT_BREAK : + return HTMLElementDeclaration.BREAK_AFTER_START; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + return HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END; + default : + return HTMLElementDeclaration.BREAK_NONE; + } + } + + /** + * No HTML element has local elements. So, this method always + * returns an empty map. + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public CMNamedNodeMap getLocalElements() { + return EMPTY_MAP; + } + + /** + * @see org.eclipse.wst.common.contentmodel.CMNode + */ + public int getNodeType() { + return CMNode.ELEMENT_DECLARATION; + } + + /** + */ + public int getOmitType() { + return omitType; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + return EMPTY_MAP; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return true; + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null); + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return false; + return pp.supports(this); + } + + } + + /** + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) { + return new Boolean(true); + } + else if (propertyName.equals(HTMLCMProperties.CONTENT_HINT)) { + ComplexTypeDefinition def = getComplexTypeDefinition(); + return (def != null) ? def.getPrimaryCandidate() : null; + } + else { + PropertyProvider pp = PropertyProviderFactory.getProvider(propertyName); + if (pp == null) + return null; + return pp.get(this); + } + } + + /** + * Return element names which terminates this element.<br> + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return null; + } + + /** + * return true when the element is a JSP element. + */ + public boolean isJSP() { + return false; + } + + /** + * In some elements, such as APPLET, a source generator should indent child + * elements that their parents. That is, a source generator should generate + * source of APPLET and PARAMS like this: + * <PRE> + * <APPLET ...> + * <PARAM ... > + * <PARAM ... > + * </APPLET> + * <PRE> + * @return boolean + */ + public boolean shouldIndentChildSource() { + return indentChild; + } + + /** + * Most of elements can compact spaces in their child text nodes. + * Some special elements should keep them in their source. + * @return boolean + */ + public boolean shouldKeepSpaces() { + return keepSpaces; + } + + /** + * @return boolean + */ + public boolean shouldTerminateAt(HTMLElementDeclaration nextElement) { + Iterator i = getTerminators(); + if (i == null) + return false; + String nextName = nextElement.getElementName(); + while (i.hasNext()) { + if (nextName.equals(i.next())) + return true; + } + return false; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java new file mode 100644 index 0000000000..5d91c853d2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HTMLEntityDeclImpl.java @@ -0,0 +1,77 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.common.contentmodel.CMNode; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLEntityDeclaration; + + + +/** + */ +class HTMLEntityDeclImpl extends CMNodeImpl implements HTMLEntityDeclaration { + + private java.lang.String value = null; + + /** + * CMEntityDeclImpl constructor comment. + * @param entityName java.lang.String; Entity name. + * @param entityValue java.lang.String; Value string. + */ + public HTMLEntityDeclImpl(String entityName, String entityValue) { + super(entityName); + value = entityValue; + } + + /** + * getName method + * @return java.lang.String + */ + public String getName() { + return getNodeName(); + } + + /** + * Get CMNode type.<br> + * @return int; Always return ENTITY_DECLARATION. + */ + public int getNodeType() { + return CMNode.ENTITY_DECLARATION; + } + + /** + * getValue method + * @return java.lang.String + */ + public String getValue() { + return value; + } + + /** + */ + public boolean supports(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return true; + return super.supports(propertyName); + } + + /** + * Entities in HTML documents are always treated with ignoring cases. + * Because no special entities are defined in JSP 1.0, this method + * can always return <code>true</code>.<br> + */ + public Object getProperty(String propertyName) { + if (propertyName.equals(HTMLCMProperties.SHOULD_IGNORE_CASE)) + return new Boolean(true); + return super.getProperty(propertyName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java new file mode 100644 index 0000000000..60aa5ba8f0 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedA.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * A. + */ +final class HedA extends HedInlineContainer { + + /** + */ + public HedA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.A, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + } + + /** + * %attrs; + * (charset %Charset; #IMPLIED) + * (type %ContentType; #IMPLIED) + * (name CDATA #IMPLIED) + * (href %URI; #IMPLIED) + * (hreflang %LanguageCode; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (rel %LinkTypes; #IMPLIED) + * (rev %LinkTypes; #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (directkey %Character; #IMPLIED) + * (shape %Shape; rect) + * (coords %Coords; #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_HREF,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>A</code> has the exclusion. + * It is <code>A</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode a = elementCollection.getNamedItem(CHTMLNamespace.ElementName.A); + if (a != null) + exclusion.appendChild(a); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.A,}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java new file mode 100644 index 0000000000..3126e0d748 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedADDRESS.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * ADDRESS. + */ +final class HedADDRESS extends HTMLElemDeclImpl { + + /** + */ + public HedADDRESS(ElementCollection collection) { + super(CHTMLNamespace.ElementName.ADDRESS, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_ADDRESS; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java new file mode 100644 index 0000000000..a8564f192d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBASE.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * BASE. + */ +final class HedBASE extends HedEmpty { + + /** + */ + public HedBASE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BASE, collection); + // LAYOUT_HIDDEN. + // Because, BASE is GROUP_HIDDEN in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_HIDDEN; + } + + /** + * BASE. + * (href %URI; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_HREF,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java new file mode 100644 index 0000000000..e730d080e5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBLOCKQUOTE.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * BLOCKQUOTE. + */ +final class HedBLOCKQUOTE extends HedFlowContainer { + + /** + */ + public HedBLOCKQUOTE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BLOCKQUOTE, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (cite %URI; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java new file mode 100644 index 0000000000..7b0b2fde86 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBODY.java @@ -0,0 +1,68 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * BODY. + */ +final class HedBODY extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.HEAD, CHTMLNamespace.ElementName.BODY, CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedBODY(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BODY, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_BOTH; + } + + /** + * %attrs; + * %bodycolors; + * (onload %Script; #IMPLIED) + * (onunload %Script; #IMPLIED) + * (background %URI; #IMPLIED) + * (marginwidth %Pixels; #IMPLIED) ... D205514 + * (marginheight %Pixels; #IMPLIED) .. D205514 + * (topmargin, CDATA, #IMPLIED) ...... D205514 + * (bottommargin, CDATA, #IMPLIED) ... D205514 + * (leftmargin, CDATA, #IMPLIED) ..... D205514 + * (rightmargin, CDATA, #IMPLIED) .... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %bodycolors; + attributeCollection.getBodycolors(attributes); + + } + + /** + * BODY has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java new file mode 100644 index 0000000000..62d1e6400d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedBR.java @@ -0,0 +1,51 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + + + +/** + * BR. + */ +final class HedBR extends HedEmpty { + + /** + */ + public HedBR(ElementCollection collection) { + super(CHTMLNamespace.ElementName.BR, collection); + // LAYOUT_BREAK. + // Because, BR is GROUP_BREAK in the C++DOM/DTDParser.cpp. + layoutType = LAYOUT_BREAK; + } + + /** + * BR. + * %coreattrs; + * (clear (left | all | right | none) none) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %coreattrs; + attributeCollection.getCore(attributes); + // clear + HTMLAttributeDeclaration attr = attributeCollection.getDeclaration(CHTMLNamespace.ATTR_NAME_CLEAR); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_CLEAR, attr); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java new file mode 100644 index 0000000000..115f7e22c1 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedCENTER.java @@ -0,0 +1,55 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * CENTER. + */ +final class HedCENTER extends HedFlowContainer { + + /** + */ + public HedCENTER(ElementCollection collection) { + super(CHTMLNamespace.ElementName.CENTER, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java new file mode 100644 index 0000000000..d27bd32da5 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDD.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * DD. + */ +final class HedDD extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.DT, CHTMLNamespace.ElementName.DD}; + + /** + */ + public HedDD(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DD, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java new file mode 100644 index 0000000000..95b6c64007 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDIV.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * DIV. + */ +final class HedDIV extends HedFlowContainer { + + /** + */ + public HedDIV(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DIV, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * %align; + * %reserved; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // %align; + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + // %reserved; ... empty + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java new file mode 100644 index 0000000000..9274ddf31f --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDL.java @@ -0,0 +1,59 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * DL. + */ +final class HedDL extends HTMLElemDeclImpl { + + /** + */ + public HedDL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DL, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_DEFINITION_LIST; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } + + /** + * %arrays; + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java new file mode 100644 index 0000000000..6dca71ec97 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedDT.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * DT. + */ +final class HedDT extends HedInlineContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.DT, CHTMLNamespace.ElementName.DD}; + + /** + */ + public HedDT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.DT, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + } + + /** + * DT has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java new file mode 100644 index 0000000000..188c107de3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedEmpty.java @@ -0,0 +1,49 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for EMPTY type element declarations. + */ +abstract class HedEmpty extends HTMLElemDeclImpl { + + /** + */ + public HedEmpty(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_EMPTY; + // EMPTY type has no end tag. + omitType = OMIT_END_MUST; + } + + /** + * Content.<br> + * EMPTY type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.EMPTY; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java new file mode 100644 index 0000000000..3c05641966 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFORM.java @@ -0,0 +1,92 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; +import org.eclipse.wst.common.contentmodel.CMNode; + +/** + * FORM. + */ +final class HedFORM extends HedFlowContainer { + + /** + */ + public HedFORM(ElementCollection collection) { + super(CHTMLNamespace.ElementName.FORM, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs; + * (action %URI; #REQUIRED) + * (method (GET|POST) GET) + * (enctype %ContentType; "application/x-www-form-urlencoded") + * (accept %ContentTypes; #IMPLIED) + * (name CDATA #IMPLIED) + * (onsubmit %Script; #IMPLIED) + * (onreset %Script; #IMPLIED) + * (target %FrameTarget; #IMPLIED) + * (accept-charset %Charsets; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_ACTION, CHTMLNamespace.ATTR_NAME_METHOD, CHTMLNamespace.ATTR_NAME_ENCTYPE, CHTMLNamespace.ATTR_NAME_NAME,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * Exclusion. + * <code>FORM</code> has the exclusion. + * It is <code>FORM</code> itself. + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; // fatal + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + CMNode form = elementCollection.getNamedItem(CHTMLNamespace.ElementName.FORM); + if (form != null) + exclusion.appendChild(form); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.FORM, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java new file mode 100644 index 0000000000..9820507b01 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedFlowContainer.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for (%flow;)* containers. + */ +abstract class HedFlowContainer extends HTMLElemDeclImpl { + + /** + */ + public HedFlowContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_FLOW_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java new file mode 100644 index 0000000000..f22d4f0f57 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHEAD.java @@ -0,0 +1,71 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * HTML. + */ +final class HedHEAD extends HTMLElemDeclImpl { + + private static String[] terminators = {CHTMLNamespace.ElementName.HEAD, CHTMLNamespace.ElementName.BODY, CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedHEAD(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HEAD, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HEAD; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HEAD</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%i18n;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>profile</td><td>URI</td><td>#IMPLIED</td><td>N/A</td><td>-</td> + * </tr> + * </tbody> + * </table> + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + } + + /** + * HEAD has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java new file mode 100644 index 0000000000..c94fd0d6c3 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHR.java @@ -0,0 +1,75 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * HR. + */ +final class HedHR extends HedEmpty { + + /** + */ + public HedHR(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HR, collection); + layoutType = LAYOUT_BLOCK; + } + + /** + * %attrs + * (align (left|center|right) #IMPLIED) ... should be defined locally. + * (noshade (noshade) #IMPLIED) + * (size %Pixels; #IMPLIED) + * (width %Length; #IMPLIED) + * (color %Color; #IMPLIED) ... D205514 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (align (left|center|right) #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {CHTMLNamespace.ATTR_VALUE_LEFT, CHTMLNamespace.ATTR_VALUE_CENTER, CHTMLNamespace.ATTR_VALUE_RIGHT}; + atype.setEnumValues(values); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_ALIGN, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {CHTMLNamespace.ATTR_NAME_NOSHADE, CHTMLNamespace.ATTR_NAME_SIZE, CHTMLNamespace.ATTR_NAME_WIDTH,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java new file mode 100644 index 0000000000..c39f6661d6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHTML.java @@ -0,0 +1,81 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +import org.eclipse.wst.html.core.contentmodel.HTMLAttributeDeclaration; + + +/** + * HTML. + */ +final class HedHTML extends HTMLElemDeclImpl { + + private static String[] terminators = {CHTMLNamespace.ElementName.HTML}; + + /** + */ + public HedHTML(ElementCollection collection) { + super(CHTMLNamespace.ElementName.HTML, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_HTML; + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_BOTH; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>HTML</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td><code>%i18n;</code></td><td>-</td><td>-</td><td>-</td> + * <td>{@link PDCMDocImpl#getAttrDeclarationsI18n}</td> + * </tr> + * <tr> + * <td>version</td><td>CDATA</td><td>#FIXED</td> + * <td>{@link HTML_VERSION_TRANSITIONAL}</td><td>deplecated in HTML4.01</td> + * </tr> + * </tbody> + * </table><br> + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + // version + HTMLAttributeDeclaration adec = attributeCollection.getDeclaration(CHTMLNamespace.ATTR_NAME_VERSION); + if (adec != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_VERSION, adec); + } + + /** + * HTML has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java new file mode 100644 index 0000000000..b93ecfa212 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedHeading.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * H[1-6]. + */ +final class HedHeading extends HedInlineContainer { + + /** + */ + public HedHeading(String elementName, ElementCollection collection) { + super(elementName, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>H1</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl attr = AttributeCollection.createAlignForParagraph(); + if (attr != null) + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java new file mode 100644 index 0000000000..f6ace06817 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedIMG.java @@ -0,0 +1,88 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * IMG. + */ +final class HedIMG extends HedEmpty { + + /** + */ + public HedIMG(ElementCollection collection) { + super(CHTMLNamespace.ElementName.IMG, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * IMG. + * %attrs; + * (src %URI; #REQUIRED): should be defined locally. + * (alt %Text; #REQUIRED) + * (longdesc %URI; #IMPLIED) + * (name CDATA #IMPLIED) + * (height %Length; #IMPLIED) + * (width %Length; #IMPLIED) + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (align %IAlign; #IMPLIED): should be defined locally. + * (border %Pixels; #IMPLIED) + * (hspace %Pixels; #IMPLIED) + * (vspace %Pixels; #IMPLIED) + * (mapfile %URI; #IMPLIED) + * @see com.ibm.sed.contentmodel.html.AbstractHTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (src %URI; #REQUIRED): should be defined locally. + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + atype = new HTMLCMDataTypeImpl(CMDataType.URI); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SRC, atype, CMAttributeDeclaration.REQUIRED); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SRC, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_ALT, CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_HEIGHT, CHTMLNamespace.ATTR_NAME_WIDTH, CHTMLNamespace.ATTR_NAME_BORDER, CHTMLNamespace.ATTR_NAME_HSPACE, CHTMLNamespace.ATTR_NAME_VSPACE,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + + // align (local); should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.PRE}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java new file mode 100644 index 0000000000..a4959345ec --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedINPUT.java @@ -0,0 +1,108 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + * INPUT. + */ +final class HedINPUT extends HedEmpty { + + /** + */ + public HedINPUT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.INPUT, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + * INPUT. + * %attrs; + * (type %InputType; TEXT) ... should be defined locally. + * (name CDATA #IMPLIED) + * (value CDATA #IMPLIED) + * (checked (checked) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (size CDATA #IMPLIED) ... should be defined locally. + * (maxlength NUMBER #IMPLIED) + * (src %URI; #IMPLIED) + * (alt CDATA #IMPLIED) ... should be defined locally. + * (usemap %URI; #IMPLIED) + * (ismap (ismap) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (accept %ContentTypes; #IMPLIED) + * (align %IAlign; #IMPLIED) ... should be defined locally. + * (istyle CDATA #IMPLIED) + * <<D215684 + * (width CDATA; #IMPLIED) + * (height CDATA; #IMPLIED) + * (border CDATA; #IMPLIED) + * D215684 + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + HTMLCMDataTypeImpl atype = null; + HTMLAttrDeclImpl attr = null; + // (type %InputType; TEXT) ... should be defined locally. + // NOTE: %InputType is ENUM; + // (text | password | checkbox | radio | submit | reset | + // file | hidden | image | button) + atype = new HTMLCMDataTypeImpl(CMDataType.ENUM); + String[] values = {CHTMLNamespace.ATTR_VALUE_TEXT, CHTMLNamespace.ATTR_VALUE_PASSWORD, CHTMLNamespace.ATTR_VALUE_CHECKBOX, CHTMLNamespace.ATTR_VALUE_RADIO, CHTMLNamespace.ATTR_VALUE_SUBMIT, CHTMLNamespace.ATTR_VALUE_RESET, CHTMLNamespace.ATTR_VALUE_HIDDEN,}; + atype.setEnumValues(values); + atype.setImpliedValue(CMDataType.IMPLIED_VALUE_DEFAULT, CHTMLNamespace.ATTR_VALUE_TEXT); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_TYPE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_TYPE, attr); + + // (size CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SIZE, attr); + + // (alt CDATA #IMPLIED) ... should be defined locally. + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_ALT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALT, attr); + + // (align %IAlign; #IMPLIED) ... should be defined locally. + attr = AttributeCollection.createAlignForImage(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, attr); + + // the rest. + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_VALUE, CHTMLNamespace.ATTR_NAME_CHECKED, CHTMLNamespace.ATTR_NAME_SIZE, CHTMLNamespace.ATTR_NAME_MAXLENGTH, CHTMLNamespace.ATTR_NAME_SRC, CHTMLNamespace.ATTR_NAME_ALT, CHTMLNamespace.ATTR_NAME_ALIGN, CHTMLNamespace.ATTR_NAME_ISTYLE, + //<<D215684 + CHTMLNamespace.ATTR_NAME_WIDTH, CHTMLNamespace.ATTR_NAME_HEIGHT, CHTMLNamespace.ATTR_NAME_BORDER + //<D215684 + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java new file mode 100644 index 0000000000..ba04b6673b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedInlineContainer.java @@ -0,0 +1,29 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for (%inline;)* containers. + */ +abstract class HedInlineContainer extends HTMLElemDeclImpl { + + /** + * HedInlineContainer. + * @param elementName java.lang.String + * @param collection ElementCollection + */ + public HedInlineContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_INLINE_CONTAINER; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java new file mode 100644 index 0000000000..bfdb17c610 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedLI.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * LI. + */ +final class HedLI extends HedFlowContainer { + + private static String[] terminators = {CHTMLNamespace.ElementName.LI}; + + /** + */ + public HedLI(ElementCollection collection) { + super(CHTMLNamespace.ElementName.LI, collection); + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END_DEFAULT; + } + + /** + * %attrs; + * (type %LIStyle; #IMPLIED) ... should be defined locally. + * (value NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + * LI has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java new file mode 100644 index 0000000000..96343ea914 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedListItemContainer.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +/** + * Base class for list item container declarations. + * - OL, UL, MENU, DIR. + */ +abstract class HedListItemContainer extends HTMLElemDeclImpl { + + /** + */ + public HedListItemContainer(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_LI_CONTAINER; + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + indentChild = true; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java new file mode 100644 index 0000000000..ff8cc21618 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMENU.java @@ -0,0 +1,87 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * MENU/DIR. + */ +final class HedMENU extends HedListItemContainer { + + /** + */ + public HedMENU(String elementName, ElementCollection collection) { + super(elementName, collection); + } + + /** + * MENU/DIR. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + * Exclusion. + * <code>MENU/DIR</code> has the exclusion. + * It is <code>%block;</code>. + * %block; is: + * P | %heading; | %list; | %preformatted; | DL | DIV | CENTER | + * NOSCRIPT | NOFRAMES | BLOCKQUOTE | FORM | ISINDEX | HR | + * TABLE | FIELDSET | ADDRESS. + * %heading; is: H1 | H2 | H3 | H4 | H5 | H6. + * %list; is : UL | OL | DIR | MENU. + * %preformatted; is PRE. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // %block; + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {CHTMLNamespace.ElementName.P, CHTMLNamespace.ElementName.H1, CHTMLNamespace.ElementName.H2, CHTMLNamespace.ElementName.H3, CHTMLNamespace.ElementName.H4, CHTMLNamespace.ElementName.H5, CHTMLNamespace.ElementName.H6, CHTMLNamespace.ElementName.UL, CHTMLNamespace.ElementName.OL, CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU, CHTMLNamespace.ElementName.PRE, CHTMLNamespace.ElementName.DL, CHTMLNamespace.ElementName.DIV, CHTMLNamespace.ElementName.CENTER, CHTMLNamespace.ElementName.BLOCKQUOTE, CHTMLNamespace.ElementName.FORM, CHTMLNamespace.ElementName.HR, CHTMLNamespace.ElementName.ADDRESS}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java new file mode 100644 index 0000000000..b7eac5d11b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedMETA.java @@ -0,0 +1,67 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.html.core.contentmodel.HTMLCMDataType; + +/** + * META. + */ +final class HedMETA extends HedEmpty { + + /** + */ + public HedMETA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.META, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * META. + * %i18n; + * (http-equiv NAME #IMPLIED) + * (name NAME #IMPLIED) ... should be defined locally. + * (content CDATA #REQUIRED) + * (scheme CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + + // (name NAME #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(HTMLCMDataType.NAME); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_NAME, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_NAME, attr); + + // 249493 + atype = new HTMLCMDataTypeImpl(CMDataType.CDATA); + attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_CONTENT, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_CONTENT, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_HTTP_EQUIV, + // CHTMLNamespace.ATTR_NAME_CONTENT + }; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java new file mode 100644 index 0000000000..9e0fe9a9f9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOL.java @@ -0,0 +1,58 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * OL. + */ +final class HedOL extends HedListItemContainer { + + /** + */ + public HedOL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.OL, collection); + } + + /** + * OL. + * (type %OLStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + * (start NUMBER #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java new file mode 100644 index 0000000000..6cb7cfbfe7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedOPTION.java @@ -0,0 +1,63 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; +import java.util.Iterator; + +/** + * OPTION. + */ +final class HedOPTION extends HedPcdata { + + private static String[] terminators = {CHTMLNamespace.ElementName.OPTION}; + + /** + */ + public HedOPTION(ElementCollection collection) { + super(CHTMLNamespace.ElementName.OPTION, collection); + layoutType = LAYOUT_HIDDEN; + omitType = OMIT_END; + } + + /** + * OPTION. + * %attrs; + * (selected (selected) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (label %Text; #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_SELECTED, CHTMLNamespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } + + /** + * OPTION has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + return Arrays.asList(terminators).iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java new file mode 100644 index 0000000000..d04ffbcc6b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedP.java @@ -0,0 +1,105 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Collection; +import java.util.Iterator; +import java.util.Vector; + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * P. + */ +final class HedP extends HedInlineContainer { + + private static Collection terminators = null; + + /** + */ + public HedP(ElementCollection collection) { + super(CHTMLNamespace.ElementName.P, collection); + correctionType = CORRECT_EMPTY; + layoutType = LAYOUT_BLOCK; + omitType = OMIT_END; + } + + /** + * Create all attribute declarations. + * This method is called once in the constructor of the super class. + * The <code>P</code> element may have the following attributes: + * <table> + * <tbody> + * <tr> + * <th>NAME</th><th>TYPE</th><th>USAGE</th><th>DEFAULT (INITIAL) VALUE</th><th>MEMO</th> + * </tr> + * <tr> + * <td>%attrs;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * <tr> + * <td>%align;</td><td>-</td><td>-</td><td>-</td><td>-</td> + * </tr> + * </tbody> + * </table> + * <p><b>%align;</b> means <code>align (left|center|right|justify) #IMPLIED</code>. + * Unfortunately, this <code>align</code> is different from one in + * <code>IMG</code> or <code>TABLE</code>. So, the attribute declaration + * of <code>align</code> should be localy created and it shouldn't be registered + * in a <code>HCMDocImpl</code> instance.</p> + * <p>However, %align is used in sevaral times. I wouldn't write same code + * in many times. So, I add a new utility method into <code>CMUtil</code> + * to create the attribute declaration.</p> + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElemDeclImpl + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + // %attrs; + attributeCollection.getAttrs(attributes); + // align + HTMLAttrDeclImpl adec = AttributeCollection.createAlignForParagraph(); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_ALIGN, adec); + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + return prohibitedAncestors; + } + + /** + * Return names of terminators. + * <code>P</code> has terminators. + * @return java.util.Iterator + */ + protected Iterator getTerminators() { + if (terminators != null) + return terminators.iterator(); + //<<D217982 + terminators = new Vector(); + terminators.addAll(elementCollection.getNamesOfBlock()); + terminators.add(CHTMLNamespace.ElementName.LI); + terminators.add(CHTMLNamespace.ElementName.DT); + terminators.add(CHTMLNamespace.ElementName.DD); + //D217982 + return terminators.iterator(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java new file mode 100644 index 0000000000..f82d15ec5b --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPRE.java @@ -0,0 +1,91 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMDataType; +import org.eclipse.wst.common.contentmodel.CMGroup; +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * PRE. + */ +final class HedPRE extends HedInlineContainer { + + /** + * PRE element should keep spaces in its source. + */ + public HedPRE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.PRE, collection); + // CORRECT_EMPTY - GROUP_COMPACT + correctionType = CORRECT_EMPTY; + + keepSpaces = true; + } + + /** + * %attrs; + * (width NUMBER #IMPLIED) ... should be defined locally. + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + // (width NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_WIDTH, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_WIDTH, attr); + } + + /** + * Exclusion. + * <code>PRE</code> has the exclusion. + * It is <code>%pre.exclusion;</code>. + * %pre.exclusion is: + * IMG | OBJECT | APPLET | BIG | SMALL | SUB | SUP | FONT | BASEFONT + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + String[] names = {CHTMLNamespace.ElementName.IMG,}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + + return exclusion; + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java new file mode 100644 index 0000000000..07460073d7 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedPcdata.java @@ -0,0 +1,47 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMElementDeclaration; + +/** + * Base class for PCDATA type element declarations.<br> + */ +abstract class HedPcdata extends HTMLElemDeclImpl { + + /** + */ + public HedPcdata(String elementName, ElementCollection collection) { + super(elementName, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_PCDATA; + } + + /** + * Content.<br> + * PCDATA type always returns <code>null</code>. + * <br> + * @return org.eclipse.wst.common.contentmodel.CMContent + */ + public CMContent getContent() { + return null; + } + + /** + * Content type.<br> + * @see org.eclipse.wst.common.contentmodel.CMElementDeclaration + */ + public int getContentType() { + return CMElementDeclaration.PCDATA; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java new file mode 100644 index 0000000000..cc844f8c88 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSELECT.java @@ -0,0 +1,65 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMAttributeDeclaration; +import org.eclipse.wst.common.contentmodel.CMDataType; + +/** + * SELECT. + */ +final class HedSELECT extends HTMLElemDeclImpl { + + /** + */ + public HedSELECT(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SELECT, collection); + typeDefinitionName = ComplexTypeDefinitionFactory.CTYPE_SELECT; + layoutType = LAYOUT_OBJECT; + indentChild = true; + } + + /** + * %attrs; + * %reserved; + * (name CDATA #IMPLIED) + * (size NUMBER #IMPLIED) ... should be defined locally. + * (multiple (multiple) #IMPLIED) + * (disabled (disabled) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + // (size NUMBER #IMPLIED) ... should be defined locally. + HTMLCMDataTypeImpl atype = new HTMLCMDataTypeImpl(CMDataType.NUMBER); + HTMLAttrDeclImpl attr = new HTMLAttrDeclImpl(CHTMLNamespace.ATTR_NAME_SIZE, atype, CMAttributeDeclaration.OPTIONAL); + attributes.putNamedItem(CHTMLNamespace.ATTR_NAME_SIZE, attr); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_MULTIPLE,}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java new file mode 100644 index 0000000000..fd64d4a315 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIBase.java @@ -0,0 +1,52 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + + + + +/** + * Base class for SSI declarations. + */ +abstract class HedSSIBase extends HedEmpty { + + /** + */ + public HedSSIBase(String elementName, ElementCollection collection) { + super(elementName, collection); + layoutType = LAYOUT_OBJECT; + } + + /** + */ + public int getFormatType() { + return HTMLElementDeclaration.FORMAT_SSI; + } + + /** + */ + public boolean supports(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return true; + return super.supports(propName); + } + + /* + */ + public Object getProperty(String propName) { + if (propName.equals(HTMLCMProperties.IS_SSI)) + return new Boolean(true); + return super.getProperty(propName); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java new file mode 100644 index 0000000000..a98fb71bf6 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIConfig.java @@ -0,0 +1,45 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:CONFIG. + */ +final class HedSSIConfig extends HedSSIBase { + + /** + */ + public HedSSIConfig(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_CONFIG, collection); + } + + /** + * SSI:CONFIG. + * (errmsg CDATA #IMPLIED) + * (sizefmt CDATA #IMPLIED) + * (timefmt CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_ERRMSG, CHTMLNamespace.ATTR_NAME_SIZEFMT, CHTMLNamespace.ATTR_NAME_TIMEFMT}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java new file mode 100644 index 0000000000..5e58a49256 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIEcho.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:ECHO. + */ +final class HedSSIEcho extends HedSSIBase { + + /** + */ + public HedSSIEcho(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_ECHO, collection); + } + + /** + * SSI:ECHO + * (var CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_VAR}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java new file mode 100644 index 0000000000..7ddc7c6d00 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIExec.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:EXEC. + */ +final class HedSSIExec extends HedSSIBase { + + /** + */ + public HedSSIExec(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_EXEC, collection); + } + + /** + * SSI:EXEC + * (cgi %URI; #IMPLIED) + * (cmd CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_CGI, CHTMLNamespace.ATTR_NAME_CMD}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java new file mode 100644 index 0000000000..1e5eac975a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFlastmod.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:FLASTMOD. + */ +final class HedSSIFlastmod extends HedSSIBase { + + /** + */ + public HedSSIFlastmod(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_FLASTMOD, collection); + } + + /** + * SSI:FLASTMOD + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java new file mode 100644 index 0000000000..b3acb6d5e9 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIFsize.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:FSIZE. + */ +final class HedSSIFsize extends HedSSIBase { + + /** + */ + public HedSSIFsize(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_FSIZE, collection); + } + + /** + * SSI:FSIZE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java new file mode 100644 index 0000000000..0a06ca7815 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIInclude.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:INCLUDE. + */ +final class HedSSIInclude extends HedSSIBase { + + /** + */ + public HedSSIInclude(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_INCLUDE, collection); + } + + /** + * SSI:INCLUDE + * (file %URI; #IMPLIED) + * (virtual %URI #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_FILE, CHTMLNamespace.ATTR_NAME_VIRTUAL}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java new file mode 100644 index 0000000000..ff252708b2 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSIPrintenv.java @@ -0,0 +1,48 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * SSI:PRINTENV. + */ +final class HedSSIPrintenv extends HedSSIBase { + + /** + */ + public HedSSIPrintenv(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_PRINTENV, collection); + } + + /** + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + } + + /** + * SSI:PRINTENV has no attributes. So, this method should + * always return <code>null</code>. + * Note: Since somebody doesn't expect null is returned, return the empty attribute + * like a custom tag which doesn't have attributes + */ + public CMNamedNodeMap getAttributes() { + return super.getAttributes(); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java new file mode 100644 index 0000000000..30210913c8 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedSSISet.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * SSI:SET. + */ +final class HedSSISet extends HedSSIBase { + + /** + */ + public HedSSISet(ElementCollection collection) { + super(CHTMLNamespace.ElementName.SSI_SET, collection); + } + + /** + * SSI:SET + * (var CDATA #IMPLIED) + * (value CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + String[] names = {CHTMLNamespace.ATTR_NAME_VAR, CHTMLNamespace.ATTR_NAME_VALUE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java new file mode 100644 index 0000000000..229e52b71a --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTEXTAREA.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +/** + * TEXTAREA. + */ +final class HedTEXTAREA extends HedPcdata { + + /** + * TEXTAREA should keep spaces in its source. + */ + public HedTEXTAREA(ElementCollection collection) { + super(CHTMLNamespace.ElementName.TEXTAREA, collection); + layoutType = LAYOUT_OBJECT; + + keepSpaces = true; + } + + /** + * TEXTAREA. + * %attrs; + * %reserved; ... empty + * (name CDATA #IMPLIED) + * (rows NUMBER #REQUIRED) + * (cols NUMBER #REQUIRED) + * (disabled (disabled) #IMPLIED) + * (readonly (readonly) #IMPLIED) + * (tabindex NUMBER #IMPLIED) + * (accesskey %Character; #IMPLIED) + * (onfocus %Script; #IMPLIED) + * (onblur %Script; #IMPLIED) + * (onselect %Script; #IMPLIED) + * (onchange %Script; #IMPLIED) + * (istyle CDATA #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + String[] names = {CHTMLNamespace.ATTR_NAME_NAME, CHTMLNamespace.ATTR_NAME_ROWS, CHTMLNamespace.ATTR_NAME_COLS, CHTMLNamespace.ATTR_NAME_ISTYLE}; + attributeCollection.getDeclarations(attributes, Arrays.asList(names).iterator()); + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java new file mode 100644 index 0000000000..545848b40d --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedTITLE.java @@ -0,0 +1,69 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import java.util.Arrays; + +import org.eclipse.wst.common.contentmodel.CMContent; +import org.eclipse.wst.common.contentmodel.CMGroup; + +/** + * TITLE. + */ +final class HedTITLE extends HedPcdata { + + /** + */ + public HedTITLE(ElementCollection collection) { + super(CHTMLNamespace.ElementName.TITLE, collection); + layoutType = LAYOUT_HIDDEN; + } + + /** + * TITLE. + * %i18n; + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %i18n; + attributeCollection.getI18n(attributes); + } + + /** + * Exclusion. + * <code>TITLE</code> has the exclusion. + * It is <code>%head.misc;</code>. + * %head.misc; is <code>SCRIPT|STYLE|META|LINK|OBJECT</code>. + * <br> + * @see com.ibm.sed.contentmodel.html.HTMLElementDeclaration + */ + public CMContent getExclusion() { + if (exclusion != null) + return exclusion; // already created. + if (elementCollection == null) + return null; + + // (SCRIPT|STYLE|META|LINK|OBJECT) + exclusion = new CMGroupImpl(CMGroup.CHOICE, 1, 1); + + String[] names = {CHTMLNamespace.ElementName.META,}; + elementCollection.getDeclarations(exclusion, Arrays.asList(names).iterator()); + return exclusion; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java new file mode 100644 index 0000000000..e7a23c0226 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/HedUL.java @@ -0,0 +1,57 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + + + +import org.eclipse.wst.common.contentmodel.CMNamedNodeMap; + +/** + * UL. + */ +final class HedUL extends HedListItemContainer { + + /** + */ + public HedUL(ElementCollection collection) { + super(CHTMLNamespace.ElementName.UL, collection); + } + + /** + * UL. + * (type %ULStyle; #IMPLIED) ... should be defined locally. + * (compact (compact) #IMPLIED) + */ + protected void createAttributeDeclarations() { + if (attributes != null) + return; // already created. + if (attributeCollection == null) + return; // fatal + + attributes = new CMNamedNodeMapImpl(); + + // %attrs; + attributeCollection.getAttrs(attributes); + + } + + /** + */ + public CMNamedNodeMap getProhibitedAncestors() { + if (prohibitedAncestors != null) + return prohibitedAncestors; + + String[] names = {CHTMLNamespace.ElementName.DIR, CHTMLNamespace.ElementName.MENU}; + prohibitedAncestors = elementCollection.getDeclarations(names); + + return prohibitedAncestors; + } +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java new file mode 100644 index 0000000000..db31375b90 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProvider.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; + + + +/** + * PropertyProvider class. + * This class is intended to be used in HTMLElementDeclaration instances. + */ +interface PropertyProvider { + + boolean supports(HTMLElementDeclaration edecl); + + Object get(HTMLElementDeclaration edecl); +}
\ No newline at end of file diff --git a/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java new file mode 100644 index 0000000000..5512025995 --- /dev/null +++ b/bundles/org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/contentmodel/chtml/PropertyProviderFactory.java @@ -0,0 +1,363 @@ +/******************************************************************************* + * Copyright (c) 2004 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.wst.html.core.contentmodel.chtml; + +import java.util.Hashtable; + +import org.eclipse.wst.common.contentmodel.annotation.AnnotationMap; +import org.eclipse.wst.html.core.HTMLCMProperties; +import org.eclipse.wst.html.core.contentmodel.HTMLElementDeclaration; +import org.eclipse.wst.html.core.contentmodel.HTMLPropertyDeclaration; + +/** + * The factory object of PropertyProvider. + */ +final class PropertyProviderFactory { + + + /** + * DefaultProvider is intended to be used for unknown properties. + * It always returns null value for any properties. + */ + class DefaultProvider implements PropertyProvider { + public DefaultProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return false; + } + + public Object get(HTMLElementDeclaration edecl) { + return null; + } + } + + abstract class AbstractElementPropertyProvider implements PropertyProvider { + protected AbstractElementPropertyProvider() { + super(); + } + + public boolean supports(HTMLElementDeclaration edecl) { + return (edecl != null); + } + + public Object get(HTMLElementDeclaration edecl) { + if (!(edecl instanceof HTMLPropertyDeclaration)) + return null; + return getElementProperty((HTMLPropertyDeclaration)edecl); + } + + abstract protected Object getElementProperty(HTMLPropertyDeclaration decl); + } + + /* + * "tagInfo" + * gets documentation for the element + */ + class PPTagInfo extends AbstractElementPropertyProvider { + private final static String htmlAnnotationLoc = "platform:/plugin/org.eclipse.wst.html.core/data/htmref.xml"; //$NON-NLS-1$ + protected AnnotationMap fAnnotationMap = null; + + public PPTagInfo() { + super(); + } + + /** + * Gets the annotationMap. + * @return Returns a AnnotationMap + */ + protected AnnotationMap getAnnotationMap() { + if (fAnnotationMap == null) { + fAnnotationMap = new AnnotationMap(); + try { + fAnnotationMap.load(htmlAnnotationLoc); + } + catch (Exception e) { + // no annotation available + } + } + return fAnnotationMap; + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (decl instanceof HTMLElementDeclaration) { + return getAnnotationMap().getProperty(((HTMLElementDeclaration)decl).getElementName(), "tagInfo"); //$NON-NLS-1$ + } else { + return null; + } + } + } + + /* + * "shouldKeepSpace" + */ + class PPShouldKeepSpace extends AbstractElementPropertyProvider { + public PPShouldKeepSpace() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldKeepSpaces()); + } + } + + /* + * "shouldIndentChildSource" + */ + class PPShouldIndentChildSource extends AbstractElementPropertyProvider { + public PPShouldIndentChildSource() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.shouldIndentChildSource()); + } + } + + /* + * "terminators" + */ + class PPTerminators extends AbstractElementPropertyProvider { + public PPTerminators() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + if (decl == null) + return null; + if (! (decl instanceof HTMLElemDeclImpl)) return null; + return ((HTMLElemDeclImpl)decl).getTerminators(); + } + } + + /* + * "prohibitedAncestors" + */ + class PPProhibitedAncestors extends AbstractElementPropertyProvider { + public PPProhibitedAncestors() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getProhibitedAncestors(); + } + } + + /* + * "isJSP" + */ + class PPIsJSP extends AbstractElementPropertyProvider { + public PPIsJSP() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(decl.isJSP()); + } + } + + /* + * "isXHTML" + * HTMLElementDeclaration itself never represent any XHTML element declaration. + * So, this property must be always false. + */ + class PPIsXHTML extends AbstractElementPropertyProvider { + public PPIsXHTML() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "isSSI" + * Each declaration class for SSI elements must provide this property itself, + * and then return true. Other declaration must always return false. + */ + class PPIsSSI extends AbstractElementPropertyProvider { + public PPIsSSI() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return new Boolean(false); + } + } + + /* + * "lineBreakHint" + */ + class PPLineBreakHint extends AbstractElementPropertyProvider { + public PPLineBreakHint() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String hint = HTMLCMProperties.Values.BREAK_NONE; + switch (decl.getLineBreakHint()) { + case HTMLElementDeclaration.BREAK_AFTER_START : + hint = HTMLCMProperties.Values.BREAK_AFTER_START; + break; + case HTMLElementDeclaration.BREAK_BEFORE_START_AND_AFTER_END : + hint = HTMLCMProperties.Values.BREAK_BEFORE_START_AND_AFTER_END; + break; + case HTMLElementDeclaration.BREAK_NONE : + // nothing to do + default : + break; + } + return hint; + } + } + + /* + * "layoutType" + */ + class PPLayoutType extends AbstractElementPropertyProvider { + public PPLayoutType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.LAYOUT_NONE; + switch (decl.getLayoutType()) { + case HTMLElementDeclaration.LAYOUT_BLOCK : + type = HTMLCMProperties.Values.LAYOUT_BLOCK; + break; + case HTMLElementDeclaration.LAYOUT_BREAK : + type = HTMLCMProperties.Values.LAYOUT_BREAK; + break; + case HTMLElementDeclaration.LAYOUT_HIDDEN : + type = HTMLCMProperties.Values.LAYOUT_HIDDEN; + break; + case HTMLElementDeclaration.LAYOUT_OBJECT : + type = HTMLCMProperties.Values.LAYOUT_OBJECT; + break; + case HTMLElementDeclaration.LAYOUT_WRAP : + type = HTMLCMProperties.Values.LAYOUT_WRAP; + break; + case HTMLElementDeclaration.LAYOUT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "omitType" + */ + class PPOmitType extends AbstractElementPropertyProvider { + public PPOmitType() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + String type = HTMLCMProperties.Values.OMIT_NONE; + switch (decl.getOmitType()) { + case HTMLElementDeclaration.OMIT_BOTH : + type = HTMLCMProperties.Values.OMIT_BOTH; + break; + case HTMLElementDeclaration.OMIT_END : + type = HTMLCMProperties.Values.OMIT_END; + break; + case HTMLElementDeclaration.OMIT_END_DEFAULT : + type = HTMLCMProperties.Values.OMIT_END_DEFAULT; + break; + case HTMLElementDeclaration.OMIT_END_MUST : + type = HTMLCMProperties.Values.OMIT_END_MUST; + break; + case HTMLElementDeclaration.OMIT_NONE : + // nothing to do. + default : + break; + } + return type; + } + } + + /* + * "inclusion" + */ + class PPInclusion extends AbstractElementPropertyProvider { + public PPInclusion() { + super(); + } + + protected Object getElementProperty(HTMLPropertyDeclaration decl) { + return decl.getInclusion(); + } + } + + public static PropertyProvider getProvider(String propName) { + PropertyProviderFactory factory = getInstance(); + PropertyProvider pp = (PropertyProvider) factory.registry.get(propName); + if (pp != null) + return pp; + + pp = factory.create(propName); + if (pp == null) + return factory.defaultProvider; + + factory.registry.put(propName, pp); + return pp; + } + + private static PropertyProviderFactory instance = null; + + private synchronized static PropertyProviderFactory getInstance() { + if (instance != null) + return instance; + instance = new PropertyProviderFactory(); + return instance; + } + + private Hashtable registry = new Hashtable(); + private PropertyProvider defaultProvider = new DefaultProvider(); + + private PropertyProviderFactory() { + super(); + } + + private PropertyProvider create(String propName) { + PropertyProvider pp = null; + if (propName.equals(HTMLCMProperties.IS_JSP)) + pp = new PPIsJSP(); + else if (propName.equals(HTMLCMProperties.IS_XHTML)) + pp = new PPIsXHTML(); + else if (propName.equals(HTMLCMProperties.IS_SSI)) + pp = new PPIsSSI(); + else if (propName.equals(HTMLCMProperties.LAYOUT_TYPE)) + pp = new PPLayoutType(); + else if (propName.equals(HTMLCMProperties.LINE_BREAK_HINT)) + pp = new PPLineBreakHint(); + else if (propName.equals(HTMLCMProperties.PROHIBITED_ANCESTORS)) + pp = new PPProhibitedAncestors(); + else if (propName.equals(HTMLCMProperties.SHOULD_KEEP_SPACE)) + pp = new PPShouldKeepSpace(); + else if (propName.equals(HTMLCMProperties.SHOULD_INDENT_CHILD_SOURCE)) + pp = new PPShouldIndentChildSource(); + else if (propName.equals(HTMLCMProperties.TERMINATORS)) + pp = new PPTerminators(); + else if (propName.equals(HTMLCMProperties.TAGINFO)) + pp = new PPTagInfo(); + else if (propName.equals(HTMLCMProperties.OMIT_TYPE)) + pp = new PPOmitType(); + else if (propName.equals(HTMLCMProperties.INCLUSION)) + pp = new PPInclusion(); + + return pp; + } +}
\ No newline at end of file |