1 19 package org.openharmonise.vfs.metadata; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import org.w3c.dom.Element ; 26 import org.w3c.dom.Node ; 27 import org.w3c.dom.NodeList ; 28 import org.w3c.dom.Text ; 29 30 39 public class PropertyGroup { 40 41 44 private String m_sHREF; 45 46 49 private int m_nVersion; 50 51 54 private String m_sName; 55 56 59 private String m_sDisplayName; 60 61 64 private ArrayList m_aChildren = new ArrayList (5); 65 66 69 private ArrayList m_aSubGroups = new ArrayList (5); 70 71 74 public PropertyGroup() { 75 super(); 76 } 77 78 83 public void setName(String sName) { 84 this.m_sName = sName; 85 } 86 87 92 public void setHREF(String sHREF) { 93 this.m_sHREF = sHREF; 94 } 95 96 101 public String getHREF() { 102 return this.m_sHREF; 103 } 104 105 111 public List getChildren() { 112 ArrayList vals = new ArrayList (); 113 Iterator itor = m_aChildren.iterator(); 114 while(itor.hasNext()) { 115 String sHREF = (String )itor.next(); 116 vals.add(PropertyCache.getInstance().getPropertyByPath(sHREF)); 117 } 118 119 return vals; 120 } 121 122 128 public List getChildrenHREFs() { 129 return this.m_aChildren; 130 } 131 132 138 public void setChildrenHREFs(List aHREFs) { 139 this.m_aChildren = new ArrayList (aHREFs); 140 } 141 142 148 public List getSubGroups() { 149 ArrayList vals = new ArrayList (); 150 Iterator itor = m_aSubGroups.iterator(); 151 while(itor.hasNext()) { 152 String sHREF = (String )itor.next(); 153 vals.add(PropertyCache.getInstance().getPropertyGroup(sHREF)); 154 } 155 156 return vals; 157 } 158 159 164 public void instantiate(Element elValue) { 165 this.m_sName = 166 elValue.getAttributeNS( 167 "http://www.simulacramedia.com/harmoniseclient/propdefs", 168 "name"); 169 NodeList nl = elValue.getChildNodes(); 170 for (int i = 0; i < nl.getLength(); i++) { 171 Node node = nl.item(i); 172 if (node.getNodeType() == Node.ELEMENT_NODE) { 173 Element element = (Element ) node; 174 if (element.getLocalName().equalsIgnoreCase("displayname")) { 175 Node node2 = element.getFirstChild(); 176 if (node2.getNodeType() == Node.TEXT_NODE) { 177 this.m_sDisplayName = ((Text ) node2).getNodeValue(); 178 } 179 } else if ( 180 element.getLocalName().equalsIgnoreCase("version")) { 181 Node node2 = element.getFirstChild(); 182 if (node2.getNodeType() == Node.TEXT_NODE) { 183 this.m_nVersion = 184 Integer.parseInt(((Text ) node2).getNodeValue()); 185 } 186 } else if (element.getLocalName().equalsIgnoreCase("href")) { 187 Node node2 = element.getFirstChild(); 188 if (node2.getNodeType() == Node.TEXT_NODE) { 189 this.m_sHREF = ((Text ) node2).getNodeValue(); 190 } 191 } else if ( 192 element.getLocalName().equalsIgnoreCase("children")) { 193 NodeList nl2 = element.getChildNodes(); 194 for (int j = 0; j < nl2.getLength(); j++) { 195 Node childNode = (Node ) nl2.item(j); 196 if (childNode.getNodeType() == Node.ELEMENT_NODE) { 197 Element childElement = (Element ) childNode; 198 Node node2 = childElement.getFirstChild(); 199 if (node2.getNodeType() == Node.TEXT_NODE) { 200 String sTemp = ((Text ) node2).getNodeValue(); 201 this.m_aChildren.add(sTemp.trim()); 202 } 203 } 204 } 205 } else if ( 206 element.getLocalName().equalsIgnoreCase("subgroups")) { 207 NodeList nl2 = element.getChildNodes(); 208 for (int j = 0; j < nl2.getLength(); j++) { 209 Node childNode = (Node ) nl2.item(j); 210 if (childNode.getNodeType() == Node.ELEMENT_NODE) { 211 Element childElement = (Element ) childNode; 212 Node node2 = childElement.getFirstChild(); 213 if (node2.getNodeType() == Node.TEXT_NODE) { 214 String sTemp = ((Text ) node2).getNodeValue(); 215 this.m_aSubGroups.add(sTemp.trim()); 216 } 217 } 218 } 219 } 220 } 221 } 222 } 223 } 224 | Popular Tags |