KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > test > xml > schema > core > lib > dom > parser > ExtraNodeInfo


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.test.xml.schema.core.lib.dom.parser;
21
22 import org.w3c.dom.NamedNodeMap JavaDoc;
23 import org.w3c.dom.Node JavaDoc;
24 import org.netbeans.test.xml.schema.core.lib.util.Helpers;
25
26 /**
27  *
28  * @author ca@netbeans.org
29  */

30 public class ExtraNodeInfo {
31     
32     private String JavaDoc m_strComponentName;
33     private int m_lineNmb;
34     private Node JavaDoc m_node;
35     private boolean m_bGlobal;
36     
37     public ExtraNodeInfo(int lineNmb, String JavaDoc componentName, Node JavaDoc node, boolean bGlobal) {
38         m_bGlobal = bGlobal;
39         m_lineNmb = lineNmb;
40         m_strComponentName = componentName;
41         m_node = node;
42     }
43     
44     public String JavaDoc getComponentName() {
45         return m_strComponentName;
46     }
47     
48     public int getLineNmb() {
49         return m_lineNmb;
50     }
51     
52     public String JavaDoc getColumnViewName() {
53         String JavaDoc strName = getNamedAttrValue("name");
54         
55         if (strName != null) return strName;
56
57         strName = getNamedAttrValue("ref");
58         if (strName != null) {
59             return Helpers.getUnqualifiedName(strName); // + " (->)";
60
}
61         
62         if (m_strComponentName.equals("enumeration")) {
63             strName = "\"" + getNamedAttrValue("value") + "\"";
64         } else if (m_strComponentName.equals("whiteSpace")) {
65             strName = "whitespace";
66         }
67         
68         if (strName != null) return strName;
69         
70         strName = getNamedAttrValue("value");
71         
72         if (strName != null) return strName;
73         
74         strName = m_strComponentName;
75         
76         return strName;
77     }
78     
79     public String JavaDoc getNamedAttrValue(String JavaDoc attrName) {
80         String JavaDoc strAttrValue = null;
81         
82         NamedNodeMap JavaDoc map = m_node.getAttributes();
83         
84         String JavaDoc strName = "";
85         if (map != null) {
86             Node JavaDoc attr = map.getNamedItem(attrName);
87             if (attr != null) {
88                 strAttrValue = attr.getNodeValue();
89             }
90         }
91
92         return strAttrValue;
93     }
94     
95     public boolean isGlobal() {
96         return m_bGlobal;
97     }
98     
99     public String JavaDoc getParentColumnViewName() {
100         Node JavaDoc parentNode = m_node.getParentNode();
101         ExtraNodeInfo sn = (ExtraNodeInfo) parentNode.getUserData("");
102         return sn.getColumnViewName();
103     }
104     
105     public int getLineNumber() {
106         return m_lineNmb;
107     }
108     
109     public static ExtraNodeInfo getExtraNodeInfo(Node JavaDoc node) {
110         return (ExtraNodeInfo) node.getUserData("");
111     }
112 }
Popular Tags