View Javadoc
1 package org.apache.turbine.services.intake.xmlmodel; 2 3 /* ==================================================================== 4 * The Apache Software License, Version 1.1 5 * 6 * Copyright (c) 2001 The Apache Software Foundation. All rights 7 * reserved. 8 * 9 * Redistribution and use in source and binary forms, with or without 10 * modification, are permitted provided that the following conditions 11 * are met: 12 * 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 16 * 2. Redistributions in binary form must reproduce the above copyright 17 * notice, this list of conditions and the following disclaimer in 18 * the documentation and/or other materials provided with the 19 * distribution. 20 * 21 * 3. The end-user documentation included with the redistribution, 22 * if any, must include the following acknowledgment: 23 * "This product includes software developed by the 24 * Apache Software Foundation (http://www.apache.org/)." 25 * Alternately, this acknowledgment may appear in the software itself, 26 * if and wherever such third-party acknowledgments normally appear. 27 * 28 * 4. The names "Apache" and "Apache Software Foundation" and 29 * "Apache Turbine" must not be used to endorse or promote products 30 * derived from this software without prior written permission. For 31 * written permission, please contact apache@apache.org. 32 * 33 * 5. Products derived from this software may not be called "Apache", 34 * "Apache Turbine", nor may "Apache" appear in their name, without 35 * prior written permission of the Apache Software Foundation. 36 * 37 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 38 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 39 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 40 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 41 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 42 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 43 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 44 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 45 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 46 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 47 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 48 * SUCH DAMAGE. 49 * ==================================================================== 50 * 51 * This software consists of voluntary contributions made by many 52 * individuals on behalf of the Apache Software Foundation. For more 53 * information on the Apache Software Foundation, please see 54 * <http://www.apache.org/>;. 55 */ 56 57 import java.util.ArrayList; 58 import java.util.Iterator; 59 import java.util.List; 60 import org.xml.sax.Attributes; 61 62 /*** 63 * A class for holding application data structures. 64 * 65 * @author <a href="mailto:jmcnally@collab.net>;John McNally</a> 66 * @version $Id: AppData.java,v 1.2 2001/10/09 14:14:30 henning Exp $ 67 */ 68 public class AppData 69 implements java.io.Serializable 70 { 71 72 private List inputs; 73 private String basePackage; 74 75 /*** 76 * Default Constructor 77 */ 78 public AppData() 79 { 80 inputs = new ArrayList(); 81 } 82 83 /*** 84 * Imports the top level element from an XML specification 85 */ 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 /*** 107 * Return a collection of input sections (<group>) 108 */ 109 public List getGroups() 110 { 111 return inputs; 112 } 113 114 /*** 115 * Get a XmlGroup with the given name. 116 * 117 * @param groupName a <code>String</code> value 118 * @return a <code>XmlGroup</code> value 119 */ 120 public XmlGroup getGroup(String groupName) 121 { 122 XmlGroup group = null; 123 Iterator iter = inputs.iterator(); 124 do 125 { 126 group = (XmlGroup)iter.next(); 127 128 } while (!group.getName().equals(groupName)); 129 130 return group; 131 } 132 133 /*** 134 * An utility method to add a new input group from 135 * an xml attribute. 136 */ 137 public XmlGroup addGroup(Attributes attrib) 138 { 139 XmlGroup input = new XmlGroup(); 140 input.loadFromXML(attrib); 141 addGroup(input); 142 return input; 143 } 144 145 /*** 146 * Add an input group to the vector and sets the 147 * AppData property to this AppData 148 */ 149 public void addGroup(XmlGroup input) 150 { 151 input.setAppData(this); 152 inputs.add(input); 153 } 154 155 156 /*** 157 * Get the base package String that will be appended to 158 * any mapToObjects 159 * 160 * @return value of basePackage. 161 */ 162 public String getBasePackage() 163 { 164 return basePackage; 165 } 166 167 /*** 168 * Get the base package String that will be appended to 169 * any mapToObjects 170 * 171 * @param v Value to assign to basePackage. 172 */ 173 public void setBasePackage(String v) 174 { 175 this.basePackage = v; 176 } 177 178 /*** 179 * Creats a string representation of this AppData. 180 * The representation is given in xml format. 181 */ 182 public String toString() 183 { 184 StringBuffer result = new StringBuffer(); 185 186 result.append ("<input-data>\n"); 187 for (Iterator iter = inputs.iterator() ; iter.hasNext() ;) 188 { 189 result.append (iter.next()); 190 } 191 result.append ("</input-data>"); 192 return result.toString(); 193 } 194 }

This page was automatically generated by Maven