You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by se...@apache.org on 2004/03/05 06:37:02 UTC

cvs commit: jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model FloatField.java DoubleField.java BooleanField.java LongField.java IntegerField.java ShortField.java

seade       2004/03/04 21:37:02

  Modified:    intake/src/java/org/apache/fulcrum/intake/model
                        FloatField.java DoubleField.java BooleanField.java
                        LongField.java IntegerField.java ShortField.java
  Log:
  Fix how Intake handles multiValued entries.
  Initial patch to IntegerField provided by Derek Gaasch.
  
  Revision  Changes    Path
  1.3       +8 -11     jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java
  
  Index: FloatField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/FloatField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FloatField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ FloatField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -61,19 +61,13 @@
   import org.apache.fulcrum.intake.xmlmodel.XmlField;
   
   /**
  - * Creates Float Field objects.
  + * Processor for float fields.
    *
  - * @author <a href="mailto:r.wekker@rubicon-bv.com>Ronald Wekker</a>
  - * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  - * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    * @version $Id$
    */
   public class FloatField
           extends Field
   {
  -
       /**
        * Constructor.
        *
  @@ -157,18 +151,21 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Float[] values = new Float[inputs.length];
  +            float[] values = new float[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? new Float(inputs[i]) : (Float) getEmptyValue();
  +                        ? new Float(inputs[i]).floatValue() 
  +                        : ((Float) getEmptyValue()).floatValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? new Float(val) : getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? new Float(val) : getEmptyValue());
           }
       }
  +    
   }
  
  
  
  1.3       +8 -7      jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java
  
  Index: DoubleField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/DoubleField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DoubleField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ DoubleField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -61,10 +61,8 @@
   import org.apache.fulcrum.intake.xmlmodel.XmlField;
   
   /**
  - * Creates Double Field objects.
  + * Processor for double fields.
    *
  - * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    * @version $Id$
    */
   public class DoubleField
  @@ -153,18 +151,21 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Double[] values = new Double[inputs.length];
  +            double[] values = new double[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? new Double(inputs[i]) : (Double) getEmptyValue();
  +                        ? new Double(inputs[i]).doubleValue() 
  +                        : ((Double) getEmptyValue()).doubleValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? new Double(val) : (Double) getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? new Double(val) : (Double) getEmptyValue());
           }
       }
  +    
   }
  
  
  
  1.3       +14 -8     jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/BooleanField.java
  
  Index: BooleanField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/BooleanField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- BooleanField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ BooleanField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -64,15 +64,18 @@
   /**
    * Processor for boolean fields.
    *
  - * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  - * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    * @version $Id$
    */
   public class BooleanField
           extends Field
   {
  +    /**
  +     * Constructor.
  +     *
  +     * @param field xml field definition object
  +     * @param group xml group definition object
  +     * @throws IntakeException thrown by superclass
  +     */
       public BooleanField(XmlField field, Group group)
               throws IntakeException
       {
  @@ -149,18 +152,20 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Boolean[] values = new Boolean[inputs.length];
  +            boolean[] values = new boolean[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? getBoolean(inputs[i]) : (Boolean) getEmptyValue();
  +                        ? getBoolean(inputs[i]).booleanValue() 
  +                        : ((Boolean) getEmptyValue()).booleanValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? getBoolean(val) : (Boolean) getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? getBoolean(val) : (Boolean) getEmptyValue());
           }
       }
   
  @@ -219,4 +224,5 @@
           }
           return result;
       }
  +    
   }
  
  
  
  1.3       +8 -8      jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/LongField.java
  
  Index: LongField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/LongField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LongField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ LongField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -61,11 +61,8 @@
   import org.apache.fulcrum.intake.xmlmodel.XmlField;
   
   /**
  - * Creates Short Field objects.
  + * Processor for long fields.
    *
  - * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    * @version $Id$
    */
   public class LongField
  @@ -155,18 +152,21 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Long[] values = new Long[inputs.length];
  +            long[] values = new long[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? new Long(inputs[i]) : (Long) getEmptyValue();
  +                        ? new Long(inputs[i]).longValue() 
  +                        : ((Long) getEmptyValue()).longValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? new Long(val) : (Long) getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? new Long(val) : (Long) getEmptyValue());
           }
       }
  +    
   }
  
  
  
  1.3       +9 -9      jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/IntegerField.java
  
  Index: IntegerField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/IntegerField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- IntegerField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ IntegerField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -61,16 +61,13 @@
   import org.apache.fulcrum.intake.xmlmodel.XmlField;
   
   /**
  - * @author <a href="mailto:jmcnally@collab.net">John McNally</a>
  - * @author <a href="mailto:hps@intermeta.de">Henning P. Schmiedehausen</a>
  - * @author <a href="mailto:quintonm@bellsouth.net">Quinton McCombs</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
  + * Processor for int fields.
  + *
    * @version $Id$
    */
   public class IntegerField
           extends Field
   {
  -
       /**
        * Constructor.
        *
  @@ -154,18 +151,21 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Integer[] values = new Integer[inputs.length];
  +            int[] values = new int[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? new Integer(inputs[i]) : (Integer) getEmptyValue();
  +                        ? new Integer(inputs[i]).intValue() 
  +                        : ((Integer) getEmptyValue()).intValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? new Integer(val) : (Integer) getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? new Integer(val) : (Integer) getEmptyValue());
           }
       }
  +    
   }
  
  
  
  1.3       +8 -9      jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/ShortField.java
  
  Index: ShortField.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-fulcrum/intake/src/java/org/apache/fulcrum/intake/model/ShortField.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- ShortField.java	10 Nov 2003 04:05:41 -0000	1.2
  +++ ShortField.java	5 Mar 2004 05:37:02 -0000	1.3
  @@ -61,17 +61,13 @@
   import org.apache.fulcrum.intake.xmlmodel.XmlField;
   
   /**
  - * Creates Short Field objects.
  + * Processor for short fields.
    *
  - * @author <a href="mailto:jmcnally@collab.net>John McNally</a>
  - * @author <a href="mailto:Colin.Chalmers@maxware.nl">Colin Chalmers</a>
  - * @author <a href="mailto:seade@backstagetech.com.au">Scott Eade</a>
    * @version $Id$
    */
   public class ShortField
           extends Field
   {
  -
       /**
        * Constructor.
        *
  @@ -156,18 +152,21 @@
           if (isMultiValued)
           {
               String[] inputs = parser.getStrings(getKey());
  -            Short[] values = new Short[inputs.length];
  +            short[] values = new short[inputs.length];
               for (int i = 0; i < inputs.length; i++)
               {
                   values[i] = StringUtils.isNotEmpty(inputs[i])
  -                        ? new Short(inputs[i]) : (Short) getEmptyValue();
  +                        ? new Short(inputs[i]).shortValue() 
  +                        : ((Short) getEmptyValue()).shortValue();
               }
               setTestValue(values);
           }
           else
           {
               String val = parser.getString(getKey());
  -            setTestValue(StringUtils.isNotEmpty(val) ? new Short(val) : (Short) getEmptyValue());
  +            setTestValue(StringUtils.isNotEmpty(val) 
  +                    ? new Short(val) : (Short) getEmptyValue());
           }
       }
  +    
   }
  
  
  

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