1 19 package org.openharmonise.vfs.metadata.range; 20 21 import java.util.ArrayList ; 22 import java.util.Iterator ; 23 import java.util.List ; 24 25 import org.openharmonise.vfs.metadata.*; 26 import org.w3c.dom.Element ; 27 import org.w3c.dom.Node ; 28 import org.w3c.dom.NodeList ; 29 import org.w3c.dom.Text ; 30 31 32 39 public class ValueGroup { 40 41 44 private String m_sHREF; 45 46 49 private String m_sName; 50 51 54 private String m_sDisplayName; 55 56 59 private ArrayList m_aChildren = new ArrayList (); 60 61 64 private ArrayList m_aSubGroups = new ArrayList (); 65 66 69 public ValueGroup() { 70 super(); 71 } 72 73 79 public ValueGroup(String sName, String sHREF) { 80 super(); 81 this.m_sName = sName; 82 this.m_sHREF = sHREF; 83 } 84 85 90 public String getDisplayName() { 91 return this.m_sDisplayName; 92 } 93 94 99 public void setDisplayName(String sDisplayName) { 100 this.m_sDisplayName = sDisplayName; 101 } 102 103 108 public void setName(String sName) { 109 this.m_sName = sName; 110 } 111 112 117 public String getName() { 118 return this.m_sName; 119 } 120 121 126 public String getHREF() { 127 return this.m_sHREF; 128 } 129 130 135 public void addChild(String sHREF) { 136 this.m_aChildren.add(sHREF); 137 } 138 139 144 public void addSubGroup(String sHREF) { 145 this.m_aSubGroups.add(sHREF); 146 } 147 148 153 public List getChildren() { 154 ArrayList vals = new ArrayList (); 155 Iterator itor = m_aChildren.iterator(); 156 while(itor.hasNext()) { 157 String sHREF = (String )itor.next(); 158 vals.add(ValueCache.getInstance().getValue(sHREF)); 159 } 160 161 return vals; 162 } 163 164 170 public List getSubGroups() { 171 ArrayList vals = new ArrayList (); 172 Iterator itor = m_aSubGroups.iterator(); 173 while(itor.hasNext()) { 174 String sHREF = (String )itor.next(); 175 vals.add(ValueCache.getInstance().getValueGroup(sHREF)); 176 } 177 178 return vals; 179 } 180 181 public void instantiate(Element elValue) { 182 this.m_sName = 183 elValue.getAttributeNS( 184 "http://www.simulacramedia.com/harmoniseclient/propdefs", 185 "name"); 186 NodeList nl = elValue.getChildNodes(); 187 for (int i = 0; i < nl.getLength(); i++) { 188 Node node = nl.item(i); 189 if (node.getNodeType() == Node.ELEMENT_NODE) { 190 Element element = (Element ) node; 191 if (element.getLocalName().equalsIgnoreCase("displayname")) { 192 Node node2 = element.getFirstChild(); 193 if (node2.getNodeType() == Node.TEXT_NODE) { 194 this.m_sDisplayName = ((Text ) node2).getNodeValue(); 195 } 196 } else if (element.getLocalName().equalsIgnoreCase("href")) { 197 Node node2 = element.getFirstChild(); 198 if (node2.getNodeType() == Node.TEXT_NODE) { 199 this.m_sHREF = ((Text ) node2).getNodeValue(); 200 } 201 } else if (element.getLocalName().equalsIgnoreCase("children")) { 202 NodeList nl2 = element.getChildNodes(); 203 for(int j=0; j<nl2.getLength(); j++) { 204 Node childNode = (Node )nl2.item(j); 205 if(childNode.getNodeType()==Node.ELEMENT_NODE) { 206 Element childElement = (Element )childNode; 207 Node node2 = childElement.getFirstChild(); 208 if (node2.getNodeType() == Node.TEXT_NODE) { 209 String sTemp = ((Text ) node2).getNodeValue(); 210 this.m_aChildren.add(sTemp.trim()); 211 } 212 } 213 } 214 } else if (element.getLocalName().equalsIgnoreCase("subgroups")) { 215 NodeList nl2 = element.getChildNodes(); 216 for(int j=0; j<nl2.getLength(); j++) { 217 Node childNode = (Node )nl2.item(j); 218 if(childNode.getNodeType()==Node.ELEMENT_NODE) { 219 Element childElement = (Element )childNode; 220 Node node2 = childElement.getFirstChild(); 221 if (node2.getNodeType() == Node.TEXT_NODE) { 222 String sTemp = ((Text ) node2).getNodeValue(); 223 this.m_aSubGroups.add(sTemp.trim()); 224 } 225 } 226 } 227 } 228 } 229 } 230 } 231 232 public String toString() { 233 StringBuffer sBuff = new StringBuffer (); 234 235 sBuff.append("ValueGroup: [").append(this.m_sName).append("]\n") 236 .append("DisplayName: ").append(this.m_sDisplayName).append("\n") 237 .append("Path: ").append(this.m_sHREF).append("\n"); 238 239 Iterator itor = this.m_aSubGroups.iterator(); 240 while(itor.hasNext()) { 241 String sHREF = (String )itor.next(); 242 sBuff.append(sHREF); 243 } 244 245 itor = this.m_aChildren.iterator(); 246 while(itor.hasNext()) { 247 String sHREF = (String )itor.next(); 248 sBuff.append(sHREF); 249 } 250 251 return sBuff.toString(); 252 } 253 254 } 255 | Popular Tags |