You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by qu...@apache.org on 2003/04/03 02:35:31 UTC

cvs commit: jakarta-turbine-2/src/java/org/apache/turbine/util ValueParser.java

quintonm    2003/04/02 16:35:31

  Modified:    src/java/org/apache/turbine/util ValueParser.java
  Log:
  Made the naming scheme uniform for accessing all data types.  There is now a method for accessing
  the primative and object type of each one.  Like methods have also been added (where missing)
  for the arrays of the primative and object types.
  
  The naming scheme:
    get<datatype> - primative
    get<datatype>Object - object
    get<datatype>s - array of primative
    get<datatype>Objects - array of objects
  
  The get<datatype> and get<datatype>Object methods are overloaded to accept a default value.
  
  I did not create a getBooleanObjects or getBooleans because it did not seems to make sense for
  boolean types.
  
  I did not create a getByteObjects because getBytes was not consistent with the other methods
  returning arrays of primarives.  This method returns an array of bytes from a string.
  
  The getBool, getInteger, and getIntegers methods have been deprecated in favor of new methods
  with the consistent naming scheme.
  
  Revision  Changes    Path
  1.11      +176 -1    jakarta-turbine-2/src/java/org/apache/turbine/util/ValueParser.java
  
  Index: ValueParser.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-2/src/java/org/apache/turbine/util/ValueParser.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- ValueParser.java	19 Mar 2003 16:54:47 -0000	1.10
  +++ ValueParser.java	3 Apr 2003 00:35:31 -0000	1.11
  @@ -279,6 +279,7 @@
        * @param name A String with the name.
        * @param defaultValue The default value.
        * @return A Boolean.
  +     * @deprecated use {@link #getBooleanObject} instead
        */
       Boolean getBool(String name, boolean defaultValue);
   
  @@ -288,10 +289,40 @@
        *
        * @param name A String with the name.
        * @return A Boolean.
  +     * @deprecated use {@link #getBooleanObject} instead
        */
       Boolean getBool(String name);
   
       /**
  +     * Returns a Boolean object for the given name.  If the parameter
  +     * does not exist or can not be parsed as a boolean, null is returned.
  +     * <p>
  +     * Valid values for true: true, on, 1, yes<br>
  +     * Valid values for false: false, off, 0, no<br>
  +     * <p>
  +     * The string is compared without reguard to case.
  +     *
  +     * @param name A String with the name.
  +     * @return A Boolean.
  +     */
  +    Boolean getBooleanObject(String name);
  +
  +    /**
  +     * Returns a Boolean object for the given name.  If the parameter
  +     * does not exist or can not be parsed as a boolean, the defaultValue
  +     * is returned.
  +     * <p>
  +     * Valid values for true: true, on, 1, yes<br>
  +     * Valid values for false: false, off, 0, no<br>
  +     * <p>
  +     * The string is compared without reguard to case.
  +     *
  +     * @param name A String with the name.
  +     * @return A Boolean.
  +     */
  +    Boolean getBooleanObject(String name, Boolean defaultValue);
  +
  +    /**
        * Return a double for the given name.  If the name does not
        * exist, return defaultValue.
        *
  @@ -311,6 +342,43 @@
       double getDouble(String name);
   
       /**
  +     * Return an array of doubles for the given name.  If the name does
  +     * not exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A double[].
  +     */
  +    double[] getDoubles(String name);
  +
  +    /**
  +     * Return a Double for the given name.  If the name does not
  +     * exist, return defaultValue.
  +     *
  +     * @param name A String with the name.
  +     * @param defaultValue The default value.
  +     * @return A double.
  +     */
  +    Double getDoubleObject(String name, Double defaultValue);
  +
  +    /**
  +     * Return a Double for the given name.  If the name does not
  +     * exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A double.
  +     */
  +    Double getDoubleObject(String name);
  +
  +    /**
  +     * Return an array of doubles for the given name.  If the name does
  +     * not exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A double[].
  +     */
  +    Double[] getDoubleObjects(String name);
  +
  +    /**
        * Return a float for the given name.  If the name does not
        * exist, return defaultValue.
        *
  @@ -330,6 +398,43 @@
       float getFloat(String name);
   
       /**
  +     * Return an array of floats for the given name.  If the name does
  +     * not exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A float[].
  +     */
  +    float[] getFloats(String name);
  +
  +    /**
  +     * Return a Float for the given name.  If the name does not
  +     * exist, return defaultValue.
  +     *
  +     * @param name A String with the name.
  +     * @param defaultValue The default value.
  +     * @return A Float.
  +     */
  +    Float getFloatObject(String name, Float defaultValue);
  +
  +    /**
  +     * Return a float for the given name.  If the name does not
  +     * exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A Float.
  +     */
  +    Float getFloatObject(String name);
  +
  +    /**
  +     * Return an array of floats for the given name.  If the name does
  +     * not exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A float[].
  +     */
  +    Float[] getFloatObjects(String name);
  +
  +    /**
        * Return a BigDecimal for the given name.  If the name does not
        * exist, return 0.0.
        *
  @@ -377,12 +482,32 @@
       int getInt(String name);
   
       /**
  +     * Return an Integer for the given name.  If the name does not exist,
  +     * return defaultValue.
  +     *
  +     * @param name A String with the name.
  +     * @param defaultValue The default value.
  +     * @return An Integer.
  +     */
  +    Integer getIntObject(String name, Integer defaultValue);
  +
  +    /**
  +     * Return an Integer for the given name.  If the name does not exist,
  +     * return null.
  +     *
  +     * @param name A String with the name.
  +     * @return An Integer.
  +     */
  +    Integer getIntObject(String name);
  +
  +    /**
        * Return an Integer for the given name.  If the name does not
        * exist, return defaultValue.
        *
        * @param name A String with the name.
        * @param defaultValue The default value.
        * @return An Integer.
  +     * @deprecated use {@link #getIntObject} instead
        */
       Integer getInteger(String name, int defaultValue);
   
  @@ -394,6 +519,7 @@
        * @param name A String with the name.
        * @param defaultValue The default value.
        * @return An Integer.
  +     * @deprecated use {@link #getIntObject} instead
        */
       Integer getInteger(String name, Integer defaultValue);
   
  @@ -403,6 +529,7 @@
        *
        * @param name A String with the name.
        * @return An Integer.
  +     * @deprecated use {@link #getIntObject} instead
        */
       Integer getInteger(String name);
   
  @@ -421,10 +548,20 @@
        *
        * @param name A String with the name.
        * @return An Integer[].
  +     * @deprecated use {@link #getIntObjects} instead
        */
       Integer[] getIntegers(String name);
   
       /**
  +     * Return an array of Integers for the given name.  If the name
  +     * does not exist, return null.
  +     *
  +     * @param name A String with the name.
  +     * @return An Integer[].
  +     */
  +    Integer[] getIntObjects(String name);
  +
  +    /**
        * Return a long for the given name.  If the name does not exist,
        * return defaultValue.
        *
  @@ -444,6 +581,25 @@
       long getLong(String name);
   
       /**
  +     * Return a Long for the given name.  If the name does not exist,
  +     * return defaultValue.
  +     *
  +     * @param name A String with the name.
  +     * @param defaultValue The default value.
  +     * @return A Long.
  +     */
  +    Long getLongObject(String name, Long defaultValue);
  +
  +    /**
  +     * Return a Long for the given name.  If the name does not exist,
  +     * return null.
  +     *
  +     * @param name A String with the name.
  +     * @return A Long.
  +     */
  +    Long getLongObject(String name);
  +
  +    /**
        * Return an array of longs for the given name.  If the name does
        * not exist, return null.
        *
  @@ -490,6 +646,25 @@
        * @exception UnsupportedEncodingException
        */
       byte[] getBytes(String name) throws UnsupportedEncodingException;
  +
  +    /**
  +     * Return a byte for the given name.  If the name does not exist,
  +     * return defaultValue.
  +     *
  +     * @param name A String with the name.
  +     * @param defaultValue The default value.
  +     * @return A byte.
  +     */
  +    Byte getByteObject(String name, Byte defaultValue);
  +
  +    /**
  +     * Return a byte for the given name.  If the name does not exist,
  +     * return 0.
  +     *
  +     * @param name A String with the name.
  +     * @return A byte.
  +     */
  +    Byte getByteObject(String name);
   
       /**
        * Return a String for the given name.  If the name does not
  
  
  

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