Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 492be84fca3c22f7804b649de0b3fcff0814d660 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*******************************************************************************
 * 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;



import java.util.Collection;
import java.util.Iterator;
import java.util.Vector;

import org.eclipse.wst.common.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.html.core.HTML40Namespace;

/**
 * P.
 */
final class HedP extends HedInlineContainer {

	private static Collection terminators = null;

	/**
	 */
	public HedP(ElementCollection collection) {
		super(HTML40Namespace.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(HTML40Namespace.ATTR_NAME_ALIGN, adec);
	}

	/**
	 */
	public CMNamedNodeMap getProhibitedAncestors() {
		if (prohibitedAncestors != null)
			return prohibitedAncestors;
		String[] names = {HTML40Namespace.ElementName.DIR, HTML40Namespace.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(HTML40Namespace.ElementName.LI);
		terminators.add(HTML40Namespace.ElementName.DT);
		terminators.add(HTML40Namespace.ElementName.DD);
		//D217982
		return terminators.iterator();
	}
}

Back to the top