cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread niallp
niallp  2004/11/11 04:17:32

  Modified:validator/src/share/org/apache/commons/validator Tag:
VALIDATOR_1_1_2_BRANCH Field.java Msg.java
  Log:
  Bug 29452 Enable Field/Msg to support all DTD attributes, based on patch 
submitted by Rich Wertz
  
  Changed Field to add getMsgObject(key) and getMsgs() methods
  Changed Msg to add resource property and getter/setter
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.31.2.2  +24 -10
jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
  
  Index: Field.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v
  retrieving revision 1.31.2.1
  retrieving revision 1.31.2.2
  diff -u -r1.31.2.1 -r1.31.2.2
  --- Field.java22 Jun 2004 02:24:38 -  1.31.2.1
  +++ Field.java11 Nov 2004 12:17:32 -  1.31.2.2
  @@ -239,14 +239,30 @@
* Add a codeMsg/code to the codeField/code.
*/
   public void addMsg(Msg msg) {
  -hMsgs.put(msg.getName(), msg.getKey());
  +hMsgs.put(msg.getName(), msg);
   }
   
   /**
* Retrieve a message value.
*/
   public String getMsg(String key) {
  -return (String) hMsgs.get(key);
  +Msg msg = getMsgObject(key);
  +return (msg == null) ? null : msg.getKey();
  +}
  +
  +/**
  + * Retrieve a message object.
  + */
  +public Msg getMsgObject(String key) {
  +return (Msg)hMsgs.get(key);
  +}
  +
  +/**
  + * The codeField/code's messages are returned as an
  + * unmodifiable codeMap/code.
  + */
  +public Map getMsgs() {
  +return Collections.unmodifiableMap(hMsgs);
   }
   
   /**
  @@ -627,11 +643,9 @@
   String varKey = TOKEN_START + TOKEN_VAR;
   // Process Messages
   if (key != null  !key.startsWith(varKey)) {
  -for (Iterator i = hMsgs.keySet().iterator(); i.hasNext();) {
  -String msgKey = (String) i.next();
  -String value = this.getMsg(msgKey);
  -
  -hMsgs.put(msgKey, ValidatorUtils.replace(value, key, 
replaceValue));
  +for (Iterator i = hMsgs.values().iterator(); i.hasNext();) {
  +Msg msg = (Msg) i.next();
  +msg.setKey(ValidatorUtils.replace(msg.getKey(), key, 
replaceValue));
   }
   }
   
  
  
  
  1.12.2.1  +30 -3 
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.12
  retrieving revision 1.12.2.1
  diff -u -r1.12 -r1.12.2.1
  --- Msg.java  21 Feb 2004 17:10:29 -  1.12
  +++ Msg.java  11 Nov 2004 12:17:32 -  1.12.2.1
  @@ -49,6 +49,13 @@
   protected String name = null;
   
   /**
  + * Whether or not the key is a message resource (optional).  Defaults to
  + * true.  If it is 'true', the value will try to be resolved as a message
  + * resource.
  + */
  +protected boolean resource = true;
  +
  +/**
* Returns the resource bundle name.
* @since Validator 1.1
*/
  @@ -94,6 +101,22 @@
   }
   
   /**
  + * Tests whether or not the key is a resource key or literal value.
  + * @return codetrue/code if key is a resource key.
  + */
  +public boolean isResource() {
  +return this.resource;
  +}
  +
  +/**
  + * Sets whether or not the key is a resource.
  + * @param resource If true indicates the key is a resource.
  + */
  +public void setResource(boolean resource) {
  +this.resource = resource;
  +}
  +
  +/**
* Creates and returns a copy of this object.
*/
   public Object clone() {
  @@ -115,6 +138,10 @@
   results.append(name);
   results.append(  key=);
   results.append(key);
  +results.append(  resource=);
  +results.append(resource);
  +results.append(  bundle=);
  +results.append(bundle);
   results.append(\n);
   
   return results.toString();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread niallp
niallp  2004/11/11 04:18:25

  Modified:validator/src/share/org/apache/commons/validator Field.java
Msg.java
  Log:
  Bug 29452 Enable Field/Msg to support all DTD attributes, based on patch 
submitted by Rich Wertz
  
  Changed Field to add getMsgObject(key) and getMsgs() methods
  Changed Msg to add resource property and getter/setter
  
  Revision  ChangesPath
  1.34  +24 -10
jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
  
  Index: Field.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- Field.java8 Jun 2004 17:17:44 -   1.33
  +++ Field.java11 Nov 2004 12:18:25 -  1.34
  @@ -207,14 +207,30 @@
* Add a codeMsg/code to the codeField/code.
*/
   public void addMsg(Msg msg) {
  -hMsgs.put(msg.getName(), msg.getKey());
  +hMsgs.put(msg.getName(), msg);
   }
   
   /**
* Retrieve a message value.
*/
   public String getMsg(String key) {
  -return (String) hMsgs.get(key);
  +Msg msg = getMsgObject(key);
  +return (msg == null) ? null : msg.getKey();
  +}
  +
  +/**
  + * Retrieve a message object.
  + */
  +public Msg getMsgObject(String key) {
  +return (Msg)hMsgs.get(key);
  +}
  +
  +/**
  + * The codeField/code's messages are returned as an
  + * unmodifiable codeMap/code.
  + */
  +public Map getMsgs() {
  +return Collections.unmodifiableMap(hMsgs);
   }
   
   /**
  @@ -469,11 +485,9 @@
   String varKey = TOKEN_START + TOKEN_VAR;
   // Process Messages
   if (key != null  !key.startsWith(varKey)) {
  -for (Iterator i = hMsgs.keySet().iterator(); i.hasNext();) {
  -String msgKey = (String) i.next();
  -String value = this.getMsg(msgKey);
  -
  -hMsgs.put(msgKey, ValidatorUtils.replace(value, key, 
replaceValue));
  +for (Iterator i = hMsgs.values().iterator(); i.hasNext();) {
  +Msg msg = (Msg) i.next();
  +msg.setKey(ValidatorUtils.replace(msg.getKey(), key, 
replaceValue));
   }
   }
   
  
  
  
  1.13  +30 -3 
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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- Msg.java  21 Feb 2004 17:10:29 -  1.12
  +++ Msg.java  11 Nov 2004 12:18:25 -  1.13
  @@ -49,6 +49,13 @@
   protected String name = null;
   
   /**
  + * Whether or not the key is a message resource (optional).  Defaults to
  + * true.  If it is 'true', the value will try to be resolved as a message
  + * resource.
  + */
  +protected boolean resource = true;
  +
  +/**
* Returns the resource bundle name.
* @since Validator 1.1
*/
  @@ -94,6 +101,22 @@
   }
   
   /**
  + * Tests whether or not the key is a resource key or literal value.
  + * @return codetrue/code if key is a resource key.
  + */
  +public boolean isResource() {
  +return this.resource;
  +}
  +
  +/**
  + * Sets whether or not the key is a resource.
  + * @param resource If true indicates the key is a resource.
  + */
  +public void setResource(boolean resource) {
  +this.resource = resource;
  +}
  +
  +/**
* Creates and returns a copy of this object.
*/
   public Object clone() {
  @@ -115,6 +138,10 @@
   results.append(name);
   results.append(  key=);
   results.append(key);
  +results.append(  resource=);
  +results.append(resource);
  +results.append(  bundle=);
  +results.append(bundle);
   results.append(\n);
   
   return results.toString();
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread David Graham
Can we change getMessageObject() to getMessage() ?  Most everything in
Java is an object so it's redundant.  Also, getMsgs() doesn't read very
well; what about getMessages() ?  It would be good to add @since javadoc
tags so people don't assume this functionality was there from the
beginning.

David

--- [EMAIL PROTECTED] wrote:

 niallp  2004/11/11 04:18:25
 
   Modified:validator/src/share/org/apache/commons/validator
 Field.java
 Msg.java
   Log:
   Bug 29452 Enable Field/Msg to support all DTD attributes, based on
 patch submitted by Rich Wertz
   
   Changed Field to add getMsgObject(key) and getMsgs() methods
   Changed Msg to add resource property and getter/setter
   
   Revision  ChangesPath
   1.34  +24 -10   

jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
   
   Index: Field.java
   ===
   RCS file:

/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v
   retrieving revision 1.33
   retrieving revision 1.34
   diff -u -r1.33 -r1.34
   --- Field.java  8 Jun 2004 17:17:44 -   1.33
   +++ Field.java  11 Nov 2004 12:18:25 -  1.34
   @@ -207,14 +207,30 @@
 * Add a codeMsg/code to the codeField/code.
 */
public void addMsg(Msg msg) {
   -hMsgs.put(msg.getName(), msg.getKey());
   +hMsgs.put(msg.getName(), msg);
}

/**
 * Retrieve a message value.
 */
public String getMsg(String key) {
   -return (String) hMsgs.get(key);
   +Msg msg = getMsgObject(key);
   +return (msg == null) ? null : msg.getKey();
   +}
   +
   +/**
   + * Retrieve a message object.
   + */
   +public Msg getMsgObject(String key) {
   +return (Msg)hMsgs.get(key);
   +}
   +
   +/**
   + * The codeField/code's messages are returned as an
   + * unmodifiable codeMap/code.
   + */
   +public Map getMsgs() {
   +return Collections.unmodifiableMap(hMsgs);
}

/**
   @@ -469,11 +485,9 @@
String varKey = TOKEN_START + TOKEN_VAR;
// Process Messages
if (key != null  !key.startsWith(varKey)) {
   -for (Iterator i = hMsgs.keySet().iterator();
 i.hasNext();) {
   -String msgKey = (String) i.next();
   -String value = this.getMsg(msgKey);
   -
   -hMsgs.put(msgKey, ValidatorUtils.replace(value, key,
 replaceValue));
   +for (Iterator i = hMsgs.values().iterator();
 i.hasNext();) {
   +Msg msg = (Msg) i.next();
   +msg.setKey(ValidatorUtils.replace(msg.getKey(), key,
 replaceValue));
}
}

   
   
   
   1.13  +30 -3

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.12
   retrieving revision 1.13
   diff -u -r1.12 -r1.13
   --- Msg.java21 Feb 2004 17:10:29 -  1.12
   +++ Msg.java11 Nov 2004 12:18:25 -  1.13
   @@ -49,6 +49,13 @@
protected String name = null;

/**
   + * Whether or not the key is a message resource (optional). 
 Defaults to
   + * true.  If it is 'true', the value will try to be resolved as a
 message
   + * resource.
   + */
   +protected boolean resource = true;
   +
   +/**
 * Returns the resource bundle name.
 * @since Validator 1.1
 */
   @@ -94,6 +101,22 @@
}

/**
   + * Tests whether or not the key is a resource key or literal
 value.
   + * @return codetrue/code if key is a resource key.
   + */
   +public boolean isResource() {
   +return this.resource;
   +}
   +
   +/**
   + * Sets whether or not the key is a resource.
   + * @param resource If true indicates the key is a resource.
   + */
   +public void setResource(boolean resource) {
   +this.resource = resource;
   +}
   +
   +/**
 * Creates and returns a copy of this object.
 */
public Object clone() {
   @@ -115,6 +138,10 @@
results.append(name);
results.append(  key=);
results.append(key);
   +results.append(  resource=);
   +results.append(resource);
   +results.append(  bundle=);
   +results.append(bundle);
results.append(\n);

return results.toString();
   
   
   
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



Re: cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread Niall Pemberton
OK I'll do that.

Niall

- Original Message - 
From: David Graham [EMAIL PROTECTED]
To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
Sent: Thursday, November 11, 2004 2:37 PM
Subject: Re: cvs commit:
jakarta-commons/validator/src/share/org/apache/commons/validator Field.java
Msg.java


 Can we change getMessageObject() to getMessage() ?  Most everything in
 Java is an object so it's redundant.  Also, getMsgs() doesn't read very
 well; what about getMessages() ?  It would be good to add @since javadoc
 tags so people don't assume this functionality was there from the
 beginning.

 David

 --- [EMAIL PROTECTED] wrote:

  niallp  2004/11/11 04:18:25
 
Modified:validator/src/share/org/apache/commons/validator
  Field.java
  Msg.java
Log:
Bug 29452 Enable Field/Msg to support all DTD attributes, based on
  patch submitted by Rich Wertz
 
Changed Field to add getMsgObject(key) and getMsgs() methods
Changed Msg to add resource property and getter/setter
 
Revision  ChangesPath
1.34  +24 -10
 

jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
 
Index: Field.java
===
RCS file:
 

/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/F
ield.java,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- Field.java 8 Jun 2004 17:17:44 - 1.33
+++ Field.java 11 Nov 2004 12:18:25 - 1.34
@@ -207,14 +207,30 @@
  * Add a codeMsg/code to the codeField/code.
  */
 public void addMsg(Msg msg) {
-hMsgs.put(msg.getName(), msg.getKey());
+hMsgs.put(msg.getName(), msg);
 }
 
 /**
  * Retrieve a message value.
  */
 public String getMsg(String key) {
-return (String) hMsgs.get(key);
+Msg msg = getMsgObject(key);
+return (msg == null) ? null : msg.getKey();
+}
+
+/**
+ * Retrieve a message object.
+ */
+public Msg getMsgObject(String key) {
+return (Msg)hMsgs.get(key);
+}
+
+/**
+ * The codeField/code's messages are returned as an
+ * unmodifiable codeMap/code.
+ */
+public Map getMsgs() {
+return Collections.unmodifiableMap(hMsgs);
 }
 
 /**
@@ -469,11 +485,9 @@
 String varKey = TOKEN_START + TOKEN_VAR;
 // Process Messages
 if (key != null  !key.startsWith(varKey)) {
-for (Iterator i = hMsgs.keySet().iterator();
  i.hasNext();) {
-String msgKey = (String) i.next();
-String value = this.getMsg(msgKey);
-
-hMsgs.put(msgKey, ValidatorUtils.replace(value, key,
  replaceValue));
+for (Iterator i = hMsgs.values().iterator();
  i.hasNext();) {
+Msg msg = (Msg) i.next();
+msg.setKey(ValidatorUtils.replace(msg.getKey(), key,
  replaceValue));
 }
 }
 
 
 
 
1.13  +30 -3
 
 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/M
sg.java,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- Msg.java 21 Feb 2004 17:10:29 - 1.12
+++ Msg.java 11 Nov 2004 12:18:25 - 1.13
@@ -49,6 +49,13 @@
 protected String name = null;
 
 /**
+ * Whether or not the key is a message resource (optional).
  Defaults to
+ * true.  If it is 'true', the value will try to be resolved as a
  message
+ * resource.
+ */
+protected boolean resource = true;
+
+/**
  * Returns the resource bundle name.
  * @since Validator 1.1
  */
@@ -94,6 +101,22 @@
 }
 
 /**
+ * Tests whether or not the key is a resource key or literal
  value.
+ * @return codetrue/code if key is a resource key.
+ */
+public boolean isResource() {
+return this.resource;
+}
+
+/**
+ * Sets whether or not the key is a resource.
+ * @param resource If true indicates the key is a resource.
+ */
+public void setResource(boolean resource) {
+this.resource = resource;
+}
+
+/**
  * Creates and returns a copy of this object.
  */
 public Object clone() {
@@ -115,6 +138,10 @@
 results.append(name);
 results.append(  key=);
 results.append(key);
+results.append(  resource=);
+results.append(resource);
+results.append

cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread niallp
niallp  2004/11/11 07:32:03

  Modified:validator/src/share/org/apache/commons/validator Tag:
VALIDATOR_1_1_2_BRANCH Field.java Msg.java
  Log:
  Re-name getMsgObject() and getMsgs() methods
  
  Revision  ChangesPath
  No   revision
  No   revision
  1.31.2.3  +8 -6  
jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
  
  Index: Field.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v
  retrieving revision 1.31.2.2
  retrieving revision 1.31.2.3
  diff -u -r1.31.2.2 -r1.31.2.3
  --- Field.java11 Nov 2004 12:17:32 -  1.31.2.2
  +++ Field.java11 Nov 2004 15:32:03 -  1.31.2.3
  @@ -246,22 +246,24 @@
* Retrieve a message value.
*/
   public String getMsg(String key) {
  -Msg msg = getMsgObject(key);
  +Msg msg = getMessage(key);
   return (msg == null) ? null : msg.getKey();
   }
   
   /**
* Retrieve a message object.
  + * @since Validator 1.1.4
*/
  -public Msg getMsgObject(String key) {
  +public Msg getMessage(String key) {
   return (Msg)hMsgs.get(key);
   }
   
   /**
* The codeField/code's messages are returned as an
* unmodifiable codeMap/code.
  + * @since Validator 1.1.4
*/
  -public Map getMsgs() {
  +public Map getMessages() {
   return Collections.unmodifiableMap(hMsgs);
   }
   
  
  
  
  1.12.2.2  +6 -3  
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.12.2.1
  retrieving revision 1.12.2.2
  diff -u -r1.12.2.1 -r1.12.2.2
  --- Msg.java  11 Nov 2004 12:17:32 -  1.12.2.1
  +++ Msg.java  11 Nov 2004 15:32:03 -  1.12.2.2
  @@ -52,6 +52,7 @@
* Whether or not the key is a message resource (optional).  Defaults to
* true.  If it is 'true', the value will try to be resolved as a message
* resource.
  + * @since Validator 1.1.4
*/
   protected boolean resource = true;
   
  @@ -103,6 +104,7 @@
   /**
* Tests whether or not the key is a resource key or literal value.
* @return codetrue/code if key is a resource key.
  + * @since Validator 1.1.4
*/
   public boolean isResource() {
   return this.resource;
  @@ -111,6 +113,7 @@
   /**
* Sets whether or not the key is a resource.
* @param resource If true indicates the key is a resource.
  + * @since Validator 1.1.4
*/
   public void setResource(boolean resource) {
   this.resource = resource;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread niallp
niallp  2004/11/11 07:32:49

  Modified:validator/src/share/org/apache/commons/validator Field.java
Msg.java
  Log:
  Re-name getMsgObject() and getMsgs() methods
  
  Revision  ChangesPath
  1.35  +8 -6  
jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
  
  Index: Field.java
  ===
  RCS file: 
/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- Field.java11 Nov 2004 12:18:25 -  1.34
  +++ Field.java11 Nov 2004 15:32:49 -  1.35
  @@ -214,22 +214,24 @@
* Retrieve a message value.
*/
   public String getMsg(String key) {
  -Msg msg = getMsgObject(key);
  +Msg msg = getMessage(key);
   return (msg == null) ? null : msg.getKey();
   }
   
   /**
* Retrieve a message object.
  + * @since Validator 1.1.4
*/
  -public Msg getMsgObject(String key) {
  +public Msg getMessage(String key) {
   return (Msg)hMsgs.get(key);
   }
   
   /**
* The codeField/code's messages are returned as an
* unmodifiable codeMap/code.
  + * @since Validator 1.1.4
*/
  -public Map getMsgs() {
  +public Map getMessages() {
   return Collections.unmodifiableMap(hMsgs);
   }
   
  
  
  
  1.14  +6 -3  
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.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- Msg.java  11 Nov 2004 12:18:25 -  1.13
  +++ Msg.java  11 Nov 2004 15:32:49 -  1.14
  @@ -52,6 +52,7 @@
* Whether or not the key is a message resource (optional).  Defaults to
* true.  If it is 'true', the value will try to be resolved as a message
* resource.
  + * @since Validator 1.1.4
*/
   protected boolean resource = true;
   
  @@ -103,6 +104,7 @@
   /**
* Tests whether or not the key is a resource key or literal value.
* @return codetrue/code if key is a resource key.
  + * @since Validator 1.1.4
*/
   public boolean isResource() {
   return this.resource;
  @@ -111,6 +113,7 @@
   /**
* Sets whether or not the key is a resource.
* @param resource If true indicates the key is a resource.
  + * @since Validator 1.1.4
*/
   public void setResource(boolean resource) {
   this.resource = resource;
  
  
  

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: cvs commit: jakarta-commons/validator/src/share/org/apache/commons/validator Field.java Msg.java

2004-11-11 Thread David Graham
Thanks Niall!

David


--- Niall Pemberton [EMAIL PROTECTED] wrote:

 OK I'll do that.
 
 Niall
 
 - Original Message - 
 From: David Graham [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Sent: Thursday, November 11, 2004 2:37 PM
 Subject: Re: cvs commit:
 jakarta-commons/validator/src/share/org/apache/commons/validator
 Field.java
 Msg.java
 
 
  Can we change getMessageObject() to getMessage() ?  Most everything in
  Java is an object so it's redundant.  Also, getMsgs() doesn't read
 very
  well; what about getMessages() ?  It would be good to add @since
 javadoc
  tags so people don't assume this functionality was there from the
  beginning.
 
  David
 
  --- [EMAIL PROTECTED] wrote:
 
   niallp  2004/11/11 04:18:25
  
 Modified:validator/src/share/org/apache/commons/validator
   Field.java
   Msg.java
 Log:
 Bug 29452 Enable Field/Msg to support all DTD attributes, based on
   patch submitted by Rich Wertz
  
 Changed Field to add getMsgObject(key) and getMsgs() methods
 Changed Msg to add resource property and getter/setter
  
 Revision  ChangesPath
 1.34  +24 -10
  
 

jakarta-commons/validator/src/share/org/apache/commons/validator/Field.java
  
 Index: Field.java

 ===
 RCS file:
  
 

/home/cvs/jakarta-commons/validator/src/share/org/apache/commons/validator/F
 ield.java,v
 retrieving revision 1.33
 retrieving revision 1.34
 diff -u -r1.33 -r1.34
 --- Field.java 8 Jun 2004 17:17:44 - 1.33
 +++ Field.java 11 Nov 2004 12:18:25 - 1.34
 @@ -207,14 +207,30 @@
   * Add a codeMsg/code to the codeField/code.
   */
  public void addMsg(Msg msg) {
 -hMsgs.put(msg.getName(), msg.getKey());
 +hMsgs.put(msg.getName(), msg);
  }
  
  /**
   * Retrieve a message value.
   */
  public String getMsg(String key) {
 -return (String) hMsgs.get(key);
 +Msg msg = getMsgObject(key);
 +return (msg == null) ? null : msg.getKey();
 +}
 +
 +/**
 + * Retrieve a message object.
 + */
 +public Msg getMsgObject(String key) {
 +return (Msg)hMsgs.get(key);
 +}
 +
 +/**
 + * The codeField/code's messages are returned as an
 + * unmodifiable codeMap/code.
 + */
 +public Map getMsgs() {
 +return Collections.unmodifiableMap(hMsgs);
  }
  
  /**
 @@ -469,11 +485,9 @@
  String varKey = TOKEN_START + TOKEN_VAR;
  // Process Messages
  if (key != null  !key.startsWith(varKey)) {
 -for (Iterator i = hMsgs.keySet().iterator();
   i.hasNext();) {
 -String msgKey = (String) i.next();
 -String value = this.getMsg(msgKey);
 -
 -hMsgs.put(msgKey, ValidatorUtils.replace(value,
 key,
   replaceValue));
 +for (Iterator i = hMsgs.values().iterator();
   i.hasNext();) {
 +Msg msg = (Msg) i.next();
 +msg.setKey(ValidatorUtils.replace(msg.getKey(),
 key,
   replaceValue));
  }
  }
  
  
  
  
 1.13  +30 -3
  
 

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/M
 sg.java,v
 retrieving revision 1.12
 retrieving revision 1.13
 diff -u -r1.12 -r1.13
 --- Msg.java 21 Feb 2004 17:10:29 - 1.12
 +++ Msg.java 11 Nov 2004 12:18:25 - 1.13
 @@ -49,6 +49,13 @@
  protected String name = null;
  
  /**
 + * Whether or not the key is a message resource (optional).
   Defaults to
 + * true.  If it is 'true', the value will try to be resolved
 as a
   message
 + * resource.
 + */
 +protected boolean resource = true;
 +
 +/**
   * Returns the resource bundle name.
   * @since Validator 1.1
   */
 @@ -94,6 +101,22 @@
  }
  
  /**
 + * Tests whether or not the key is a resource key or literal
   value.
 + * @return codetrue/code if key is a resource key.
 + */
 +public boolean isResource() {
 +return this.resource;
 +}
 +
 +/**
 + * Sets whether or not the key is a resource.
 + * @param resource If true indicates the key is a resource.
 + */
 +public void setResource(boolean resource) {
 +this.resource = resource;
 +}
 +
 +/**
   * Creates and returns a copy of this object.
   */
  public Object clone