1 package org.apache.fulcrum.intake.xmlmodel; 2 3 56 57 import java.util.ArrayList ; 58 import java.util.Iterator ; 59 import java.util.List ; 60 import org.xml.sax.Attributes ; 61 62 68 public class AppData 69 implements java.io.Serializable 70 { 71 72 private List inputs; 73 private String basePackage; 74 75 78 public AppData() 79 { 80 inputs = new ArrayList (); 81 } 82 83 86 public void loadFromXML (Attributes attrib) 87 { 88 String basePkg = attrib.getValue("basePackage"); 89 if ( basePkg == null ) 90 { 91 setBasePackage(""); 92 } 93 else 94 { 95 if ( basePkg.charAt(basePkg.length()-1) != '.' ) 96 { 97 setBasePackage(basePkg + '.'); 98 } 99 else 100 { 101 setBasePackage(basePkg); 102 } 103 } 104 } 105 106 109 public List getGroups() 110 { 111 return inputs; 112 } 113 114 120 public XmlGroup getGroup(String groupName) 121 throws Exception 122 { 123 if (groupName == null) 124 { 125 throw new Exception ( 126 "Intake AppData.getGroup(groupName) is null"); 127 } 128 XmlGroup group = null; 129 Iterator iter = inputs.iterator(); 130 do 131 { 132 group = (XmlGroup)iter.next(); 133 134 } while (!group.getName().equals(groupName)); 135 136 return group; 137 } 138 139 143 public XmlGroup addGroup(Attributes attrib) 144 { 145 XmlGroup input = new XmlGroup(); 146 input.loadFromXML(attrib); 147 addGroup(input); 148 return input; 149 } 150 151 155 public void addGroup(XmlGroup input) 156 { 157 input.setAppData(this); 158 inputs.add(input); 159 } 160 161 162 168 public String getBasePackage() 169 { 170 return basePackage; 171 } 172 173 179 public void setBasePackage(String v) 180 { 181 this.basePackage = v; 182 } 183 184 188 public String toString() 189 { 190 StringBuffer result = new StringBuffer (); 191 192 result.append ("<input-data>\n"); 193 for (Iterator iter = inputs.iterator() ; iter.hasNext() ;) 194 { 195 result.append (iter.next()); 196 } 197 result.append ("</input-data>"); 198 return result.toString(); 199 } 200 } 201 202 | Popular Tags |