nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
amywu | 923ee60 | 2007-04-10 18:32:07 +0000 | [diff] [blame] | 2 | * Copyright (c) 2004, 2005 IBM Corporation and others. |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 3 | * 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 |
amywu | 923ee60 | 2007-04-10 18:32:07 +0000 | [diff] [blame] | 7 | * |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 8 | * Contributors: |
| 9 | * IBM Corporation - initial API and implementation |
| 10 | *******************************************************************************/ |
david_williams | 5677702 | 2005-04-11 06:21:55 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.html.core.internal.contentmodel; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 12 | |
| 13 | |
| 14 | |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 15 | import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap; |
| 16 | import org.eclipse.wst.xml.core.internal.contentmodel.CMNamespace; |
| 17 | import org.eclipse.wst.xml.core.internal.contentmodel.CMNode; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 18 | |
| 19 | /** |
| 20 | * CMDocument implementation for the HTML. |
| 21 | */ |
| 22 | class 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 | |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 40 | AttributeCollection getAttributes() { |
| 41 | return attributes; |
| 42 | } |
| 43 | |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 44 | public HTMLElementDeclaration getElementDeclaration(String elementName) { |
| 45 | if (elements == null) |
| 46 | return null; |
| 47 | return (HTMLElementDeclaration) elements.getNamedItem(elementName); |
| 48 | } |
| 49 | |
| 50 | /** |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 51 | * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 52 | */ |
| 53 | public CMNamedNodeMap getElements() { |
| 54 | return elements; |
| 55 | } |
| 56 | |
| 57 | /** |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 58 | * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 59 | */ |
| 60 | public CMNamedNodeMap getEntities() { |
| 61 | return entities; |
| 62 | } |
| 63 | |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 64 | public HTMLEntityDeclaration getEntityDeclaration(String entityName) { |
| 65 | if (entities == null) |
| 66 | return null; |
| 67 | return (HTMLEntityDeclaration) entities.getNamedItem(entityName); |
| 68 | } |
| 69 | |
| 70 | /** |
david_williams | c06c86f | 2005-03-18 18:23:41 +0000 | [diff] [blame] | 71 | * @see org.eclipse.wst.xml.core.internal.contentmodel.CMDocument |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 72 | */ |
| 73 | public CMNamespace getNamespace() { |
| 74 | return namespace; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * @see CMNode |
| 79 | */ |
| 80 | public int getNodeType() { |
| 81 | return CMNode.DOCUMENT; |
| 82 | } |
amywu | 923ee60 | 2007-04-10 18:32:07 +0000 | [diff] [blame] | 83 | } |