blob: fee63d247cc7b6d5b0321aa658f18e2104b4cc30 (
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
|
/*******************************************************************************
* Copyright (c) 2002, 2006 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
* Jens Lukowski/Innoopract - initial renaming/restructuring
*
*******************************************************************************/
package org.eclipse.wst.xml.core.internal.contentmodel.basic;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
public class CMNamedNodeMapImpl implements CMNamedNodeMap
{
public static CMNamedNodeMapImpl EMPTY_NAMED_NODE_MAP = new CMNamedNodeMapImpl();
protected Hashtable table = new Hashtable();
/**
* CMNamedNodeMapImpl constructor comment.
*/
public CMNamedNodeMapImpl()
{
super();
}
public CMNamedNodeMapImpl(CMNamedNodeMap initialContentsMap) {
super();
if (initialContentsMap != null) {
int length = initialContentsMap.getLength();
for (int j = 0; j < length; j++) {
put(initialContentsMap.item(j));
}
}
}
/**
* getLength method
* @return int
*/
public int getLength()
{
return table.size();
}
/**
* getNamedItem method
* @return CMNode
* @param name java.lang.String
*/
public CMNode getNamedItem(String name)
{
return (CMNode)table.get(name);
}
/**
* item method
* @return CMNode
* @param index int
*/
public CMNode item(int index)
{
CMNode result = null;
int size = table.size();
if (index < size)
{
Enumeration values = table.elements();
for(int i = 0; i <= index; i++)
{
result = (CMNode)values.nextElement();
}
}
return result;
}
public Hashtable getHashtable()
{
return table;
}
public Iterator iterator()
{
return table.values().iterator();
}
public void put(CMNode cmNode)
{
table.put(cmNode.getNodeName(), cmNode);
}
}
|