~ubuntu-branches/ubuntu/vivid/eclipse-wtp/vivid

« back to all changes in this revision

Viewing changes to org.eclipse.wst.html.core/src/org/eclipse/wst/html/core/internal/modelquery/CMNamedNodeMapForBuddySystem.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2013-06-28 08:42:01 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130628084201-houvqyt5uc6a3p27
Tags: 3.5.0-1
* New upstream release.
* Refreshed d/patches:
  - debian-custom-build.patch
  - regenerate-xpath2-parser.patch.
* Add patch for compatibility with rhino 1.7R4.
* Regenerate code from EMF models.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*******************************************************************************
2
 
 * Copyright (c) 2004, 2007 IBM Corporation and others.
 
2
 * Copyright (c) 2004, 2012 IBM Corporation and others.
3
3
 * All rights reserved. This program and the accompanying materials
4
4
 * are made available under the terms of the Eclipse Public License v1.0
5
5
 * which accompanies this distribution, and is available at
17
17
 
18
18
import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
19
19
import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
 
20
import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
20
21
 
21
22
/**
22
23
 */
57
58
         * @see CMNamedNodeMap#item(int)
58
59
         */
59
60
        public CMNode item(int index) {
60
 
                Iterator iter = iterator();
61
 
                while (iter.hasNext()) {
62
 
                        Object node = iter.next();
63
 
                        if (--index < 0)
64
 
                                return (CMNode) node;
 
61
                synchronized (map) {
 
62
                        Iterator iter = iterator();
 
63
                        while (iter.hasNext()) {
 
64
                                Object node = iter.next();
 
65
                                if (--index < 0)
 
66
                                        return (CMNode) node;
 
67
                        }
65
68
                }
66
69
                return null;
67
70
        }
93
96
         * to build up its contents.
94
97
         */
95
98
        protected void makeBuddySystem(CMNamedNodeMap original) {
96
 
                Iterator i = original.iterator();
 
99
                if (original instanceof CMNamedNodeMapImpl) {
 
100
                        final Hashtable table = ((CMNamedNodeMapImpl) original).getHashtable();
 
101
                        if (table != null) {
 
102
                                synchronized (table) {
 
103
                                        buddy(table.values().iterator());
 
104
                                }
 
105
                        }
 
106
                }
 
107
                else {
 
108
                        buddy(original.iterator());
 
109
                }
 
110
        }
 
111
 
 
112
        private void buddy(Iterator i) {
97
113
                if (i == null)
98
114
                        return;
99
115
                while (i.hasNext()) {