blob: 0ba233aa50ee4118cfbab31bbe0c4406cf31a518 [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
amywu923ee602007-04-10 18:32:07 +00002 * Copyright (c) 2004, 2005 IBM Corporation and others.
nitind958d79a2004-11-23 19:23:00 +00003 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
amywu923ee602007-04-10 18:32:07 +00007 *
nitind958d79a2004-11-23 19:23:00 +00008 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
david_williams56777022005-04-11 06:21:55 +000011package org.eclipse.wst.html.core.internal.contentmodel;
nitind958d79a2004-11-23 19:23:00 +000012
13
14
david_williamsc06c86f2005-03-18 18:23:41 +000015import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
16import org.eclipse.wst.xml.core.internal.contentmodel.CMNamespace;
17import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
nitind958d79a2004-11-23 19:23:00 +000018
19/**
20 * CMDocument implementation for the HTML.
21 */
22class HCMDocImpl extends CMNodeImpl implements HTMLCMDocument {
23
24 /** Namespace for all names of elements, entities and attributes. */
25 private CMNamespaceImpl namespace = null;
26 private ElementCollection elements = null;
27 private EntityCollection entities = null;
28 private AttributeCollection attributes = null;
29
30 /**
31 */
32 public HCMDocImpl(String docTypeName, CMNamespaceImpl targetNamespace) {
33 super(docTypeName);
34 namespace = targetNamespace;
35 attributes = new AttributeCollection();
36 elements = new ElementCollection(attributes);
37 entities = new EntityCollection();
38 }
39
nitind958d79a2004-11-23 19:23:00 +000040 AttributeCollection getAttributes() {
41 return attributes;
42 }
43
nitind958d79a2004-11-23 19:23:00 +000044 public HTMLElementDeclaration getElementDeclaration(String elementName) {
45 if (elements == null)
46 return null;
47 return (HTMLElementDeclaration) elements.getNamedItem(elementName);
48 }
49
50 /**
david_williamsc06c86f2005-03-18 18:23:41 +000051 * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument
nitind958d79a2004-11-23 19:23:00 +000052 */
53 public CMNamedNodeMap getElements() {
54 return elements;
55 }
56
57 /**
david_williamsc06c86f2005-03-18 18:23:41 +000058 * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument
nitind958d79a2004-11-23 19:23:00 +000059 */
60 public CMNamedNodeMap getEntities() {
61 return entities;
62 }
63
nitind958d79a2004-11-23 19:23:00 +000064 public HTMLEntityDeclaration getEntityDeclaration(String entityName) {
65 if (entities == null)
66 return null;
67 return (HTMLEntityDeclaration) entities.getNamedItem(entityName);
68 }
69
70 /**
david_williamsc06c86f2005-03-18 18:23:41 +000071 * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument
nitind958d79a2004-11-23 19:23:00 +000072 */
73 public CMNamespace getNamespace() {
74 return namespace;
75 }
76
77 /**
78 * @see CMNode
79 */
80 public int getNodeType() {
81 return CMNode.DOCUMENT;
82 }
amywu923ee602007-04-10 18:32:07 +000083}