1 package com.flexiblewebsolutions.xdriveunit; 2 3 import com.flexiblewebsolutions.xml.util.XMLStringParser; 4 5 /*** 6 * Loads the configuration information and retrieves and returns requested 7 * information. 8 * 9 * @author Donavon Buss 10 * 11 */ 12 class TestConfigurationLoader { 13 private StringBuffer _ConfigXML = new StringBuffer(); 14 15 /*** 16 * Constructor 17 * 18 * @param pConfigXML Xml configuration data for test. 19 */ 20 public TestConfigurationLoader(StringBuffer pConfigXML) { 21 _ConfigXML = pConfigXML; 22 } 23 24 /*** 25 * Retrieve entire XML entry where class name value of the entry is equal to 26 * passed in value. 27 * 28 * @param pClassName - 29 * Entry will be returned if stored value matches this value 30 * @return XML String containing configuration information. 31 */ 32 public String parseConfigurationForClass(String pClassName) { 33 String returnXML = null; 34 StringBuffer xmlString = new StringBuffer(_ConfigXML.toString()); 35 boolean classFound = false; 36 xmlString = new StringBuffer(XMLStringParser.getValueForTag(xmlString, 37 "classes")); 38 String classTag = "class"; 39 String startTag = "<" + classTag + ">"; 40 String endTag = "</" + classTag + ">"; 41 42 String[] classDefs = XMLStringParser.getMatchingNestedTags(xmlString 43 .toString(), classTag); 44 for (int i = 0; i < classDefs.length && (!classFound); i++) { 45 StringBuffer thisEntry = new StringBuffer(classDefs[i]); 46 47 String classname = XMLStringParser.getValueForTag(thisEntry, 48 "classname"); 49 50 if (classname.equals(pClassName)) { 51 classFound = true; 52 returnXML = thisEntry.toString(); 53 } 54 55 thisEntry = null; 56 classname = null; 57 } 58 59 xmlString = null; 60 classTag = null; 61 startTag = null; 62 endTag = null; 63 64 return (returnXML); 65 } 66 }