You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by jm...@apache.org on 2001/03/09 12:54:27 UTC

cvs commit: jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/transform XmlToAppData.java

jmcnally    01/03/09 03:54:27

  Modified:    conf/torque/templates/intake Field.vm
               src/java/org/apache/turbine/torque/engine/intake/model
                        AppData.java InputGroup.java Rule.java
               src/java/org/apache/turbine/torque/engine/intake/transform
                        XmlToAppData.java
  Added:       src/java/org/apache/turbine/services/intake/transform
                        constraints.dtd
               src/java/org/apache/turbine/torque/engine/intake/model
                        XmlField.java
  Removed:     src/java/org/apache/turbine/torque/engine/intake/model
                        Field.java
  Log:
  added the intake dtd
  
  miscellaneous changes to the old intake files.  Most of these are irrelevant
  with the new service, but I am checking them in just to be careful not to
  break the build.  The generated files will likely be an optimization to be
  worked on later.
  
  Revision  Changes    Path
  1.2       +19 -306   jakarta-turbine/conf/torque/templates/intake/Field.vm
  
  Index: Field.vm
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/conf/torque/templates/intake/Field.vm,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Field.vm	2001/02/28 04:29:46	1.1
  +++ Field.vm	2001/03/09 11:54:17	1.2
  @@ -10,7 +10,7 @@
   import org.apache.turbine.util.ParameterParser;
   import org.apache.turbine.util.Log;
   import org.apache.turbine.util.TurbineException;
  -import org.apache.turbine.intake.base.*;
  +import org.apache.turbine.services.intake.base.*;
   
   import org.apache.regexp.RE;
   import org.apache.regexp.RESyntaxException;
  @@ -18,319 +18,27 @@
   
   /** This class was autogenerated by Intake on: $now */
   public class $classname 
  -     extends #if($field.BaseClass) $field.BaseClass #else Field #end
  +     extends $field.BaseClass
   {
  -    private static final String KEY = "$field.Key";
   
  -#if ($field.OnError)
  -    private static final $field.Type ONERROR = $field.OnError;
  -#end
  -#set ( $i = 0 )
  -#foreach ( $rule in $field.Rules )
  -## this assumes one type of rule per field (except requires).  
  -## This should be adequate 
  -
  -    #if ( $rule.Mask )
  -    private static final RE REGEXP = initREGEXP();
  -
  -    private static RE initREGEXP()
  +    public Field(org.apache.turbine.torque.engine.intake.model.Field field)
  +        throws RESyntaxException
       {
  -        RE re = null;
  -        try 
  -        {
  -            re = new RE("$rule.Mask");
  -        }
  -        catch (RESyntaxException e)
  -        {
  -            Log.error(e);
  -        }
  -        return re;
  +        super(field);
  +        setExtended(true);
       }
  -        #if ( $rule.Message )
  -    private static final String REGEXP_MESSAGE =
  -        "$rule.Message";
  -        #end
  -    #end
  -
  -    #if ( $rule.MinLength )
  -    private static final int MINLENGTH = $rule.MinLength;
  -        #if ( $rule.Message )
  -    private static final String MINLENGTH_MESSAGE =
  -        "$rule.Message";
  -        #end
  -    #end
  -
  -    #if ( $rule.MaxLength )
  -    private static final int MAXLENGTH = $rule.MaxLength;
  -        #if ( $rule.Message )
  -    private static final String MAXLENGTH_MESSAGE =
  -        "$rule.Message";
  -        #end
  -    #end
   
  -        #if ( $rule.MinValue )
  -    private static final $field.Type MINVALUE = $rule.MinValue;
  -            #if ( $rule.Message )
  -    private static final String MINVALUE_MESSAGE =
  -        "$rule.Message";
  -            #end
  -        #end
   
  -    #if ( $rule.MaxValue )
  -    private static final $field.Type MAXVALUE = $rule.MaxValue;
  -        #if ( $rule.Message )
  -    private static final String MAXVALUE_MESSAGE =
  -        "$rule.Message";
  -        #end
  -    #end
  -
  -    #if ( $group && $rule.Requires )
  -        #set ( $i = $i + 1 )
  -    private static final String REQUIRES_$i = 
  -        $rule.Requires.toUpperCase();
  -        #if ( $rule.Message )
  -    private static final String REQUIRES_${i}_MESSAGE =
  -        "$rule.Message";
  -        #end
  -    #end
  -
  -#end
  -
  -    private $field.Type value; 
  - 
  -#if ($group)
  -    #if($suffix)
  -        #set ($groupClassname = $strings.concat([$group.ClassName, $suffix]))
  -    #else
  -        #set ( $groupClassname = $group.ClassName )
  -    #end
  -
  -    private $groupClassname $group.Variable; 
  -    public ${classname}($groupClassname g, ParameterParser pp)
  -    {
  -        this(pp);
  -        $group.Variable = g;
  -    }
  -#*
  -    public ${classname}($groupClassname g)
  -    {
  -        $group.Variable = g;
  -        valid_flag = true;
  -    }
  -#else
  -    public ${classname}()
  -    {
  -        valid_flag = true;
  -    }
  -*#
  -#end
  -
  -#if ($group) 
  -    #set ($gscope="private") 
  -#else 
  -    #set ($gscope="public") 
  -#end
  -    $gscope ${classname}(ParameterParser pp)
  -    {
  -        valid_flag = true;
  -        String key = getKey();
  -        
  -        if (pp.containsKey(key))
  -        {
  -            set_flag = true;
  -    #if ($field.isMultiValued())
  -            String[] stringValue = pp.getStrings(key);
  -            for (int i=0; i<stringValue.size(); i++)
  -            {
  -        #if ( $field.Type == "String" )
  -                this.value[i] = stringValue[i];
  -        #elseif ( $field.PPMethod )
  -                try
  -                {
  -                    this.value[i] = $field.ArrayConvert;
  -                }
  -                catch (NumberFormatException nfe)
  -                {
  -                    this.value[i] = ONERROR;
  -                }
  -        #else
  -                this.value = new ${field.Type}(stringValue[i]);
  -        #end
  -                if (valid_flag)
  -                {
  -                    validate(stringValue[i], pp);
  -                }
  -            }
  -    #else
  -            String stringValue = pp.getString(key);
  -        #if ( $field.Type == "String" )
  -            this.value = stringValue;
  -        #elseif ( $field.PPMethod )
  -            this.value = pp.${field.PPMethod}(key, ONERROR);
  -        #else
  -            this.value = new ${field.Type}(stringValue);
  -        #end
  -            validate(stringValue, pp);
  -    #end
  -        }
  -#* might not be appropriate here, still thinking
   #if ($field.MapToProperty)
  -        // load value with the object's state
  -        else
  -        {
  -            $appData.BasePackage$field.MapToObject obj = null;
  -    #if ($group)            
  -            setValue(obj.get${field.MapToProperty}();
  -    #else
  -            obj = IntakeFactory.create
  -    #end
  -        }
  -#end
  -*#
  -    }
  -
  -    /**
  -     * Get the key used to identify the $field.Name property.
  -     * @return the query data key.
  -     */
  -    public String getKey()
  -    {
  -#if ($group)
  -        return ${group.Variable}.getObjectKey() + KEY;
  -#else
  -        return KEY;
  -#end
  -    }
  -    
  -    /**
  -     * Get the value of $field.Name.
  -     * @return value of $field.Name
  -     */
  -    public $field.Type getValue() 
  -    {
  -        return value;
  -    }
  -    
  -    /**
  -     * Compares request data with constraints and sets the valid flag.
  -     * This function takes the value as a String parameter as well as
  -     * using the property for value comparisons (saves conversions).
  -     */
  -    protected boolean validate(String val, ParameterParser pp)
  +    public void getProperty(Object obj) 
  +        throws TurbineException
       {
  -        super.validate(val, pp);
  -        boolean isvalid = isValid();
  -  #set ( $boolean = "boolean " )
  -  #set ( $i = 0 )
  -  #foreach ( $rule in $field.Rules )
  -
  -    #if ( $rule.Mask )
  -        $boolean b = REGEXP.match(val);
  -        isvalid &= b;
  -        #if ($rule.Message)
  -        if (!b)
  -        {
  -            this.message = REGEXP_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -
  -    #if ( $rule.MinLength )
  -        $boolean b = val.length() < MINLENGTH; 
  -        isvalid &= !b;
  -        #if ($rule.Message)
  -        if (b)
  -        {
  -            this.message = MINLENGTH_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -
  -    #if ( $rule.MaxLength )
  -        $boolean b = val.length() > MAXLENGTH; 
  -        #if ( $rule.Action == "force" )
  -        if (b)
  -        {
  -            val = val.substring(0, $rule.MinLength);
  -            #if ( $field.Type == "String" )
  -            this.value = val;
  -            #elseif ( $field.PPMethod )
  -            this.value = ONERROR;
  -            #else
  -            this.value = new ${field.Type}(val);
  -            #end
  -        }
  -        #else
  -        isvalid &= !b;
  -        #end
  -        #if ($rule.Message)
  -        if (b)
  -        {
  -            this.message = MAXLENGTH_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -
  -    #if ( $rule.MinValue )
  -        $boolean b = this.value < MINVALUE;
  -        #if ( $rule.Action == "force" )
  -        if (b)
  -        {
  -            this.value = $rule.MinValue;
  -        }
  -        #else
  -        isvalid &= !b;
  -        #end
  -        #if ($rule.Message)
  -        if (b)
  -        {
  -            this.message = MINVALUE_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -
  -    #if ( $rule.MaxValue )
  -        $boolean b = this.value > MAXVALUE;
  -        #if ( $rule.Action == "force" )
  -        if (b)
  -        {
  -            this.value = $rule.MaxValue;
  -        }
  -        #else
  -        isvalid &= !b;
  -        #end
  -        #if ($rule.Message)
  -        if (b)
  -        {
  -            this.message = MAXVALUE_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -
  -    #if ( $group && $rule.Requires )
  -        #set ( $i = $i + 1 )
  -        #set ( $reqField = $group.getField($rule.Requires) )
  -        $boolean b = pp.containsKey(${group.Variable}.get${reqField.Name}().getKey());
  -        isvalid &= b;
  -        #if ($rule.Message)
  -        if (!b)
  -        {
  -            this.message = REQUIRES_${i}_MESSAGE;
  -        } 
  -        #end
  -        #set ( $boolean = "" )
  -    #end
  -  #end
  -        valid_flag = isvalid;
  -        return valid_flag;
  +        getValue().setValidValue( $field.ObjectifyStart
  +            ($appData.BasePackage$field.MapToObject)obj)
  +                .get${field.MapToProperty}() 
  +            $field.ObjectifyEnd );
       }
   
  -#if ($field.MapToProperty)
       /**
        * Calls a setter method on obj, if this field has been set.  Does not
        * check validity as it is assumed this will have been checked prior
  @@ -338,7 +46,7 @@
        * @exception throws a TurbineException if called and the input
        * was not valid.
        */
  -    public void setProperty($appData.BasePackage$field.MapToObject obj) 
  +    public void setProperty(Object obj) 
           throws TurbineException
       {
           if (!isValid()) 
  @@ -350,7 +58,12 @@
           {
               try
               {
  -                obj.set${field.MapToProperty}(getValue());
  +                (($appData.BasePackage$field.MapToObject)obj)
  +                    .set${field.MapToProperty}(
  +                    $field.convertOrCastStart
  +                    getValue().getTestValue()
  +                    $field.convertOrCastEnd
  +                    );
               }
               catch ( Exception e)
               {
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/services/intake/transform/constraints.dtd
  
  Index: constraints.dtd
  ===================================================================
  <!-- 
      Intake XML input constraints DTD 
      $Id: constraints.dtd,v 1.1 2001/03/09 11:54:19 jmcnally Exp $
  -->
  
  <!ELEMENT input-data (group+)>
  <!ATTLIST input-data 
    basePackage CDATA #IMPLIED
  >
  
  <!ELEMENT group (field+)>
  <!ATTLIST group 
    key CDATA #REQUIRED
    class CDATA #REQUIRED
    mapToObject CDATA #IMPLIED
  >
  
  <!ELEMENT field (rule*)>
  <!ATTLIST field 
    key CDATA #REQUIRED
    name CDATA #REQUIRED
    type ( boolean | BigDecimal | short | int  | long   | float 
         | double  | BigInteger | byte  | char | String | Date  
         | SimpleKey | ComboKey ) "String"      
    onError CDATA #IMPLIED
    multiValued ( true | false ) "false"
    mapToObject CDATA #IMPLIED
    mapToProperty CDATA #IMPLIED
  >
  
                    
  <!ELEMENT rule (#PCDATA)>
  <!ATTLIST rule 
    mask CDATA #IMPLIED
    minLength CDATA #IMPLIED
    maxLength CDATA #IMPLIED
    minValue CDATA #IMPLIED
    maxValue CDATA #IMPLIED
    action ( invalidate | force ) "invalidate"
  >
    
  
  
  
  
  1.3       +2 -2      jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/AppData.java
  
  Index: AppData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/AppData.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AppData.java	2001/03/06 06:13:17	1.2
  +++ AppData.java	2001/03/09 11:54:21	1.3
  @@ -65,7 +65,7 @@
    * A class for holding application data structures.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: AppData.java,v 1.2 2001/03/06 06:13:17 chrise Exp $
  + * @version $Id: AppData.java,v 1.3 2001/03/09 11:54:21 jmcnally Exp $
    */
   public class AppData
   {
  @@ -99,7 +99,7 @@
       }
   
       /**
  -     * Return a collection of input sections (<inputs>)
  +     * Return a collection of input sections (<input-group>)
        */
       public Vector getInputGroups()
       {
  
  
  
  1.3       +8 -8      jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/InputGroup.java
  
  Index: InputGroup.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/InputGroup.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InputGroup.java	2001/03/06 06:13:17	1.2
  +++ InputGroup.java	2001/03/09 11:54:22	1.3
  @@ -66,7 +66,7 @@
    * A Class for holding data about a grouping of inputs used in an Application.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: InputGroup.java,v 1.2 2001/03/06 06:13:17 chrise Exp $
  + * @version $Id: InputGroup.java,v 1.3 2001/03/09 11:54:22 jmcnally Exp $
    */
   public class InputGroup
   {
  @@ -138,9 +138,9 @@
        * A utility function to create a new field
        * from attrib and add it to this input group.
        */
  -    public Field addField(Attributes attrib)
  +    public XmlField addField(Attributes attrib)
       {
  -        Field field = new Field();
  +        XmlField field = new XmlField();
           field.loadFromXML(attrib);
           addField(field);
   
  @@ -151,7 +151,7 @@
        * Adds a new field to the fields vector and set the
        * parent group of the field to the current group
        */
  -    public void addField(Field field)
  +    public void addField(XmlField field)
       {
           field.setInputGroup (this);
   
  @@ -202,15 +202,15 @@
   
       /**
        * Returns a Specified field.
  -     * @return Return a Field object or null if it does not exist.
  +     * @return Return a XmlField object or null if it does not exist.
        */
  -    public Field getField(String name)
  +    public XmlField getField(String name)
       {
           String curName;
   
           for (Enumeration e = fields.elements() ; e.hasMoreElements() ;)
           {
  -            Field field = (Field) e.nextElement();
  +            XmlField field = (XmlField) e.nextElement();
               curName = field.getRawName();
               if (curName.equals(name))
               {
  @@ -223,7 +223,7 @@
       /**
        * Returns true if the input group contains a spesified field
        */
  -    public boolean containsField(Field field)
  +    public boolean containsField(XmlField field)
       {
           return fields.contains (field);
       }
  
  
  
  1.3       +4 -4      jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/Rule.java
  
  Index: Rule.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/Rule.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Rule.java	2001/03/06 06:13:18	1.2
  +++ Rule.java	2001/03/09 11:54:23	1.3
  @@ -68,7 +68,7 @@
    * A Class for holding data about a constraint on a property.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: Rule.java,v 1.2 2001/03/06 06:13:18 chrise Exp $
  + * @version $Id: Rule.java,v 1.3 2001/03/09 11:54:23 jmcnally Exp $
    */
   public class Rule
   {
  @@ -80,7 +80,7 @@
       private String requireProp;
       private String message;
       private String action;
  -    private Field parent;
  +    private XmlField parent;
   
       /**
        * Default Constructor
  @@ -233,7 +233,7 @@
       /**
        * Set the parent Field of the rule
        */
  -    public void setField(Field parent)
  +    public void setField(XmlField parent)
       {
           this.parent = parent;
       }
  @@ -241,7 +241,7 @@
       /**
        * Get the parent Field of the rule
        */
  -    public Field getField()
  +    public XmlField getField()
       {
           return parent;
       }
  
  
  
  1.1                  jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/model/XmlField.java
  
  Index: XmlField.java
  ===================================================================
  package org.apache.turbine.torque.engine.intake.model;
  
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2001 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and 
   *    "Apache Turbine" must not be used to endorse or promote products 
   *    derived from this software without prior written permission. For 
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Turbine", nor may "Apache" appear in their name, without 
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  
  // JDK
  import java.io.*;
  import java.util.*;
  
  // Xerces
  import org.xml.sax.*;
  import org.xml.sax.helpers.*;
  
  import org.apache.turbine.util.StringUtils;
  
  /**
   * A Class for holding data about a property used in an Application.
   *
   * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
   * @version $Id: XmlField.java,v 1.1 2001/03/09 11:54:23 jmcnally Exp $
   */
  public class XmlField
  {
      private String baseClass;
      private String name;
      private String key;
      private String type;
      private String onError;
      private String multiValued;
      private InputGroup parent;
      private Vector rules;
      private String mapToObject;
      private String mapToProperty;
  
      private static HashMap defaultOnErrors = new HashMap(15);
      private static HashMap convertHash = new HashMap(15);
      private static HashMap convertArrayHash = new HashMap(15);
      // static
      {
          defaultOnErrors.put("boolean", "false");
          defaultOnErrors.put("byte", "-1");
          defaultOnErrors.put("short", "-1");
          defaultOnErrors.put("int", "-1");
          defaultOnErrors.put("long", "-1");
          defaultOnErrors.put("float", "-1.0f");
          defaultOnErrors.put("double", "-1.0");
          defaultOnErrors.put("BigDecimal", "new BigDecimal(\"-1.0\")");
          // defaultOnErrors.put("BigInteger", "new BigInteger(\"-1\")");
  
          convertHash.put("boolean", "getBoolean");
          convertHash.put("byte", "getByte");
          convertHash.put("short", "getShort");
          convertHash.put("int", "getInt");
          convertHash.put("long", "getLong");
          convertHash.put("float", "getFloat");
          convertHash.put("double", "getDouble");
          convertHash.put("Date", "getDate");
          convertHash.put("BigDecimal", "getBigDecimal");
          // convertHash.put("BigInteger", "getBigInteger");
  
          convertHash.put("boolean[]", 
                          "Boolean.valueOf(stringValue[i]).booleanValue()");
          convertArrayHash.put("byte[]", 
                               "Byte.valueOf(stringValue[i]).byteValue()");
          convertArrayHash.put("short[]", 
                               "Short.valueOf(stringValue[i]).shortValue()");
          convertArrayHash.put("int[]", "Integer.parseInt(stringValue[i])");
          convertArrayHash.put("long[]", "Long.parseLong(stringValue[i])");
          convertArrayHash.put("float[]", 
                               "Float.valueOf(stringValue[i]).floatValue()");
          convertArrayHash.put("double[]", 
                               "Double.valueOf(stringValue[i]).doubleValue()");
          convertArrayHash.put("Date[]", "FIXME!!");
          convertArrayHash.put("BigDecimal[]", "new BigDecimal(stringValue[i])");
          // convertHash.put("BigInteger", "new BigInteger(stringValue)");
      }    
      /**
       * Default Constructor
       */
      public XmlField()
      {
          rules = new Vector();
      }
  
  
      /**
       * Creates a new column and set the name
       */
      public XmlField(String name)
      {
          this.name = name;
          rules = new Vector();
      }
  
      /**
       * Imports a column from an XML specification
       */
      public void loadFromXML (Attributes attrib)
      {
          setBaseClass(attrib.getValue("baseClass"));
          setName(attrib.getValue("name"));
          key = attrib.getValue("key");
          type = attrib.getValue("type");
          setOnError(attrib.getValue("onError"));
          setMultiValued(attrib.getValue("multiValued"));
  
          String mapObj = attrib.getValue("mapToObject");
          if ( mapObj != null ) 
          {
              setMapToObject(mapObj);            
          }
  
          String mapProp = attrib.getValue("mapToProperty");
          if ( mapProp != null ) 
          {
              setMapToProperty(mapProp);            
          }
      }
  
  
      /**
       * Get the name of the property
       */
      public String getRawName()
      {
          return name;
      }
  
      /**
       * Get the name of the property
       */
      public String getName()
      {
          return StringUtils.removeUnderScores(name);
      }
  
      /**
       * Set the name of the property
       */
      public void setName(String newName)
      {
          name = newName;
      }
  
      /**
       * Set the parameter key of the property
       */
      public void setKey(String newKey)
      {
          key = newKey;
      }
      /**
       * Get the parameter key of the property
       */
      public String getKey()
      {
          return key;
      }
  
      /**
       * Set the type of the property
       */
      public void setType(String newType)
      {
          type = newType;
      }
  
      /**
       * Get the type of the property
       */
      public String getType()
      {
          if ( isMultiValued() ) 
          {
              return type + "[]";    
          }   
          return type;
      }
  
      /**
       * Set the base class of the field
       */
      public void setBaseClass(String newBaseClass)
      {
          baseClass = newBaseClass;
      }
  
      /**
       * Get the base class of the field
       */
      public String getBaseClass()
      {
          return baseClass;
      }
  
      /**
       * Set the value of the property, if a conversion error occurs.
       */
      public void setOnError(String newOnError)
      {
          onError = newOnError;
      }
  
      /**
       * Get the value of the property, if a conversion error occurs.
       */
      public String getOnError()
      {
          if ( onError == null && defaultOnErrors.containsKey(getType()) ) 
          {
              onError = (String)defaultOnErrors.get(getType());
          }
          return onError;
      }
  
      /**
       * Set whether this class can have multiple values
       */
      public void setMultiValued(String newMultiValued)
      {
          multiValued = newMultiValued;
      }
  
      /**
       * can this field have several values?
       */
      public boolean isMultiValued()
      {
          if ( multiValued != null && multiValued.equals("true") )
          {
              return true;
          }
          return false;
      }
  
      /**
       * Set the name of the object that takes this input
       */
      public void setMapToObject(String obj)
      {
          mapToObject = obj;
      }
  
      /**
       * Get the name of the object that takes this input
       */
      public String getMapToObject()
      {
          return mapToObject;
      }
  
      /**
       * Set the property method that takes this input
       */
      public void setMapToProperty(String prop)
      {
          mapToProperty = prop;
      }
  
      /**
       * Get the property method that takes this input
       */
      public String getMapToProperty()
      {
          return mapToProperty;
      }
      
      public String getVariable()
      {
          String firstChar = getName().substring(0,1).toLowerCase();
          return firstChar + getName().substring(1);
      }
  
      public String getPPMethod()
      {
          String result = null;
          if ( convertHash.containsKey(getType())) 
          {
              result = (String)convertHash.get(getType());    
          }
          return result;
      }        
  
      public String getArrayConvert()
      {
          String result = null;
          if ( convertArrayHash.containsKey(getType())) 
          {
              result = (String)convertArrayHash.get(getType());    
          }
          return result;
      }        
  
      /**
       * Set the parent InputGroup of the property
       */
      public void setInputGroup(InputGroup parent)
      {
          this.parent = parent;
      }
  
      /**
       * Get the parent InputGroup of the property
       */
      public InputGroup getInputGroup()
      {
          return parent;
      }
  
  
      /**
       * A utility function to create a new rule
       * from attrib and add it to this property.
       */
      public Rule addRule(Attributes attrib)
      {
          Rule rule = new Rule();
          rule.loadFromXML(attrib);
          addRule(rule);
  
          return rule;
      }
  
      /**
       * Adds a new rule to the rules vector and set the
       * parent property of the rule to this property
       */
      public void addRule(Rule rule)
      {
          rule.setField(this);
          rules.addElement(rule);
      }
  
      public Vector getRules()
      {
          return rules;
      }
  
      /**
       * String representation of the column. This
       * is an xml representation.
       */
      public String toString()
      {
          StringBuffer result = new StringBuffer();
          result.append(" <field name=\""+name+"\"");
          result.append(" key=\""+key+"\"");
          result.append(" type=\""+type+"\"");
  
          if (onError != null)
          {
              result.append(" onError=\""+onError+"\"");
          }
          if (mapToObject != null)
          {
              result.append(" mapToObject=\""+mapToObject+"\"");
          }
          if (mapToProperty != null)
          {
              result.append(" mapToProperty=\""+mapToProperty+"\"");
          }
  
          result.append(">\n");
  
          if (rules != null)
          {
              for (Enumeration e = rules.elements() ; e.hasMoreElements() ;)
              {
                  result.append(e.nextElement());
              }
          }        
  
          result.append("</field>\n");
          return result.toString();
      }
  
  }
  
  
  
  
  
  
  1.3       +2 -2      jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/transform/XmlToAppData.java
  
  Index: XmlToAppData.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine/src/java/org/apache/turbine/torque/engine/intake/transform/XmlToAppData.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XmlToAppData.java	2001/03/06 06:13:19	1.2
  +++ XmlToAppData.java	2001/03/09 11:54:26	1.3
  @@ -73,13 +73,13 @@
    * It uses apache Xerces to do the xml parsing.
    *
    * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @version $Id: XmlToAppData.java,v 1.2 2001/03/06 06:13:19 chrise Exp $
  + * @version $Id: XmlToAppData.java,v 1.3 2001/03/09 11:54:26 jmcnally Exp $
    */
   public class XmlToAppData extends DefaultHandler
   {
       private AppData app;
       private InputGroup currIG;
  -    private Field currField;
  +    private XmlField currField;
       private Rule currRule;
       private String currElement;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-dev-help@jakarta.apache.org