1 19 20 package org.netbeans.test.xml.schema.core.lib.dom.parser; 21 22 import org.w3c.dom.NamedNodeMap ; 23 import org.w3c.dom.Node ; 24 import org.netbeans.test.xml.schema.core.lib.util.Helpers; 25 26 30 public class ExtraNodeInfo { 31 32 private String m_strComponentName; 33 private int m_lineNmb; 34 private Node m_node; 35 private boolean m_bGlobal; 36 37 public ExtraNodeInfo(int lineNmb, String componentName, Node node, boolean bGlobal) { 38 m_bGlobal = bGlobal; 39 m_lineNmb = lineNmb; 40 m_strComponentName = componentName; 41 m_node = node; 42 } 43 44 public String getComponentName() { 45 return m_strComponentName; 46 } 47 48 public int getLineNmb() { 49 return m_lineNmb; 50 } 51 52 public String getColumnViewName() { 53 String strName = getNamedAttrValue("name"); 54 55 if (strName != null) return strName; 56 57 strName = getNamedAttrValue("ref"); 58 if (strName != null) { 59 return Helpers.getUnqualifiedName(strName); } 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 getNamedAttrValue(String attrName) { 80 String strAttrValue = null; 81 82 NamedNodeMap map = m_node.getAttributes(); 83 84 String strName = ""; 85 if (map != null) { 86 Node 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 getParentColumnViewName() { 100 Node 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 node) { 110 return (ExtraNodeInfo) node.getUserData(""); 111 } 112 } | Popular Tags |