You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by dg...@apache.org on 2003/08/03 19:42:58 UTC

cvs commit: jakarta-commons/validator/src/test/org/apache/commons/validator validator-name-required.xml

dgraham     2003/08/03 10:42:58

  Modified:    validator/src/share/org/apache/commons/validator Arg.java
                        Msg.java
               validator/src/test/org/apache/commons/validator
                        validator-name-required.xml
  Log:
  Added bundle attribute to Arg and Msg to support alternate resource
  bundles for PR# 17543.
  
  Revision  Changes    Path
  1.11      +31 -6     jakarta-commons/validator/src/share/org/apache/commons/validator/Arg.java
  
  Index: Arg.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Arg.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- Arg.java	3 Aug 2003 17:13:55 -0000	1.10
  +++ Arg.java	3 Aug 2003 17:42:58 -0000	1.11
  @@ -85,6 +85,13 @@
   public class Arg implements Cloneable, Serializable {
   
       /**
  +     * The resource bundle name that this Arg's <code>key</code> should be
  +     * resolved in (optional). 
  +     * @since Validator 1.1
  +     */
  +    protected String bundle = null;
  +
  +    /**
        * The key or value of the argument.
        */
       protected String key = null;
  @@ -93,10 +100,11 @@
        * The name dependency that this argument goes with (optional).
        */
       protected String name = null;
  -    
  +
       /**
        * This argument's position in the message (ie. you would set postion=0 to 
        * make a replacement in this string "some msg {0}").
  +     * @since Validator 1.1
        */
       protected int position = 0;
   
  @@ -121,6 +129,14 @@
       }
   
       /**
  +     * Returns the resource bundle name.
  +     * @since Validator 1.1
  +     */
  +    public String getBundle() {
  +        return this.bundle;
  +    }
  +
  +    /**
        * Gets the key/value.
        * @return the key value.
        */
  @@ -151,13 +167,22 @@
       public boolean getResource() {
           return this.isResource();
       }
  -    
  +
       /**
        * Tests whether or not the key is a resource key or literal value.
        * @return <code>true</code> if key is a resource key.
        */
       public boolean isResource() {
           return this.resource;
  +    }
  +
  +    /**
  +     * Sets the resource bundle name.
  +     * @param bundle The new bundle name.
  +     * @since Validator 1.1
  +     */
  +    public void setBundle(String bundle) {
  +        this.bundle = bundle;
       }
   
       /**
  
  
  
  1.7       +52 -28    jakarta-commons/validator/src/share/org/apache/commons/validator/Msg.java
  
  Index: Msg.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Msg.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Msg.java	25 May 2003 18:18:31 -0000	1.6
  +++ Msg.java	3 Aug 2003 17:42:58 -0000	1.7
  @@ -75,11 +75,13 @@
    * @version $Revision$ $Date$
    */
   public class Msg implements Cloneable, Serializable {
  -    
  +
       /**
  -     * The name dependency that this argument goes with (optional).
  +     * The resource bundle name that this Msg's <code>key</code> should be
  +     * resolved in (optional). 
  +     * @since Validator 1.1
        */
  -    protected String name = null;
  +    protected String bundle = null;
   
       /**
        * The key or value of the argument.
  @@ -87,58 +89,80 @@
       protected String key = null;
   
       /**
  +     * The name dependency that this argument goes with (optional).
  +     */
  +    protected String name = null;
  +
  +    /**
  +     * Returns the resource bundle name.
  +     * @since Validator 1.1
  +     */
  +    public String getBundle() {
  +        return this.bundle;
  +    }
  +
  +    /**
  +     * Sets the resource bundle name.
  +     * @param bundle The new bundle name.
  +     * @since Validator 1.1
  +     */
  +    public void setBundle(String bundle) {
  +        this.bundle = bundle;
  +    }
  +
  +    /**
        * Gets the name of the dependency.
        */
       public String getName() {
  -       return name;	
  +        return name;
       }
   
       /**
        * Sets the name of the dependency.
        */
       public void setName(String name) {
  -       this.name = name;	
  +        this.name = name;
       }
  - 
  +
       /**
        * Gets the key/value.
        */
       public String getKey() {
  -       return key;	
  +        return key;
       }
   
       /**
        * Sets the key/value.
        */
       public void setKey(String key) {
  -       this.key = key;	
  +        this.key = key;
       }
   
       /**
        * Creates and returns a copy of this object.
        */
       public Object clone() {
  -       try {
  -           return super.clone();
  +        try {
  +            return super.clone();
   
  -       } catch (CloneNotSupportedException e) {
  -          throw new InternalError(e.toString());
  -       }
  -    }  
  +        } catch (CloneNotSupportedException e) {
  +            throw new InternalError(e.toString());
  +        }
  +    }
   
       /**
        * Returns a string representation of the object.
        */
       public String toString() {
  -       StringBuffer results = new StringBuffer();
  -       
  -       results.append("Msg: name=");
  -       results.append(name);
  -       results.append("  key=");
  -       results.append(key);
  -       results.append("\n");
  -       
  -       return results.toString();
  +        StringBuffer results = new StringBuffer();
  +
  +        results.append("Msg: name=");
  +        results.append(name);
  +        results.append("  key=");
  +        results.append(key);
  +        results.append("\n");
  +
  +        return results.toString();
       }
  -	
  +
   }
  
  
  
  1.4       +1 -1      jakarta-commons/validator/src/test/org/apache/commons/validator/validator-name-required.xml
  
  Index: validator-name-required.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/validator/src/test/org/apache/commons/validator/validator-name-required.xml,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- validator-name-required.xml	25 May 2003 18:00:23 -0000	1.3
  +++ validator-name-required.xml	3 Aug 2003 17:42:58 -0000	1.4
  @@ -9,7 +9,7 @@
         <form    name="nameForm">
            <field    property="firstName"
            	   depends="required">
  -         	     <arg key="nameForm.firstname.displayname" position="0"/>
  +         	     <arg key="nameForm.firstname.displayname" position="0" bundle="test"/>
            </field>    
            <field    property="lastName"
            	   depends="required">