~ubuntu-branches/ubuntu/quantal/netbeans/quantal

« back to all changes in this revision

Viewing changes to languages/xml/src/org/netbeans/modules/languages/xml/api/XMLRoot.java

  • Committer: Bazaar Package Importer
  • Author(s): Marek Slama
  • Date: 2008-01-29 14:11:22 UTC
  • Revision ID: james.westby@ubuntu.com-20080129141122-fnzjbo11ntghxfu7
Tags: upstream-6.0.1
ImportĀ upstreamĀ versionĀ 6.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * XMLRoot.java
 
3
 *
 
4
 * Created on March 31, 2007, 2:16 PM
 
5
 *
 
6
 * To change this template, choose Tools | Template Manager
 
7
 * and open the template in the editor.
 
8
 */
 
9
 
 
10
package org.netbeans.modules.languages.xml.api;
 
11
 
 
12
import java.util.ArrayList;
 
13
import java.util.Iterator;
 
14
import java.util.List;
 
15
 
 
16
import org.netbeans.api.languages.ASTItem;
 
17
import org.netbeans.api.languages.ASTNode;
 
18
import org.netbeans.api.languages.ASTToken;
 
19
 
 
20
 
 
21
/**
 
22
 *
 
23
 * @author Jan Jancura
 
24
 */
 
25
public class XMLRoot {
 
26
    
 
27
    private ASTNode root;
 
28
    /** Creates a new instance of XMLRoot */
 
29
    XMLRoot (ASTNode root) {
 
30
        this.root = root;
 
31
    }
 
32
    
 
33
    private List<XMLItem> items;
 
34
    public List<XMLItem> getItems () {
 
35
        if (items == null) {
 
36
            items = new ArrayList<XMLItem> ();
 
37
            Iterator<ASTItem> it = root.getChildren ().iterator ();
 
38
            while (it.hasNext ()) {
 
39
                ASTItem item = it.next ();
 
40
                if (item instanceof ASTToken) continue;
 
41
                ASTNode node = (ASTNode) item;
 
42
                if (node.getNT ().equals("etext"))
 
43
                    items.add (new XMLText (node.getAsText ()));
 
44
                else
 
45
                    items.add (new XMLTag ((ASTNode) item));
 
46
            }
 
47
        }
 
48
        return items;
 
49
    }
 
50
}
 
51
 
 
52
 
 
53
 
 
54