View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2003 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.sql;
20  
21  import net.sf.jameleon.ParamTag;
22  
23  import org.apache.commons.jelly.MissingAttributeException;
24  import org.apache.commons.jelly.JellyTagException;
25  
26  /***
27   * Used to set binding parameter to the parent sql-update tag.
28   * 
29   * An example might be:
30   * <pre><source>
31   * &lt;sql-update 
32   *   functionId="Insert a row into test table via a prepared statement with multiple param values"
33   *     sqlUpdateSql="insert into test(test_str, test_str2) values(?,?)"/&gt;
34   *       &lt;sql-param&gt;
35   *         &lt;sql-param-value&gt;text2&gt;/sql-param-value&gt;
36   *         &lt;sql-param-value&gt;text3&gt;/sql-param-value&gt;
37   *       &lt;/sql-param&gt;
38   * &lt;/sql-update&gt;
39   * </source></pre>
40   * 
41   * @jameleon.function name="sql-param"
42   */
43  public class SqlParamTag extends ParamTag {
44                 
45      /***
46       * Used to validate everything is set up correctly.
47       * @throws MissingAttributeException - When a required attribute isn't set.
48       * @throws JellyTagException - When this tag is used out of context.
49       */
50      protected void validate()throws MissingAttributeException, JellyTagException{
51          if (values == null || values.size() < 1){
52              throw new MissingAttributeException("sql-param-value is a required tag!");
53          }
54      }
55  
56  }