commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nia...@apache.org
Subject svn commit: r348369 - in /jakarta/commons/proper/resources/trunk/src: java/org/apache/commons/resources/ java/org/apache/commons/resources/impl/ test/org/apache/commons/resources/
Date Wed, 23 Nov 2005 04:51:16 GMT
Author: niallp
Date: Tue Nov 22 20:51:04 2005
New Revision: 348369

URL: http://svn.apache.org/viewcvs?rev=348369&view=rev
Log:
Remove remaining private variables

Modified:
    jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
    jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/BasicMessage.java
    jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/DatabaseBasicMessage.java
    jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java

Modified: jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
(original)
+++ jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/Messages.java
Tue Nov 22 20:51:04 2005
@@ -192,11 +192,20 @@
      * <p>The {@link org.apache.commons.resources.ResourcesFactory} that will be used
by the
      * <code>getMessages()</code> method.</p>
      */
-    protected static ResourcesFactory factory = null;
+    private static ResourcesFactory factory = null;
 
 
     // --------------------------------------------------------- Static Methods
 
+    /**
+     * <p>Set the {@link org.apache.commons.resources.ResourcesFactory} that
+     *  will be used by the <code>getMessages()</code> method.</p>
+     *
+     * @param factory ResourcesFactory instance to set.
+     */
+    public static void setFactory(ResourcesFactory factory) {
+        Messages.factory = factory;
+    }
 
     /**
      * <p>Return a text message for the specified key, for the default

Modified: jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/BasicMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/BasicMessage.java?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/BasicMessage.java
(original)
+++ jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/BasicMessage.java
Tue Nov 22 20:51:04 2005
@@ -37,12 +37,12 @@
     /**
      * The message key for this message.
      */
-    protected String key = null;
+    private String key = null;
 
     /**
      * The replacement values for this mesasge.
      */
-    protected Object[] values = null;
+    private Object[] values = null;
 
     /**
      * Default Constructor.
@@ -139,12 +139,28 @@
     public String getKey() {
         return (this.key);
     }
+    
+    /**
+     * Set the key for the message.
+     *
+     * @param key The key to set.
+     */
+    public void setKey(String key) {
+        this.key = key;
+    }
 
     /**
      * @return Get the replacement values for this message.
      */
     public Object[] getValues() {
         return (this.values);
+    }
+
+    /**
+     * @param values The replacement values for this message.
+     */
+    public void setValues(Object[] values) {
+        this.values = this.values;
     }
 
     /**

Modified: jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/DatabaseBasicMessage.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/DatabaseBasicMessage.java?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/DatabaseBasicMessage.java
(original)
+++ jakarta/commons/proper/resources/trunk/src/java/org/apache/commons/resources/impl/DatabaseBasicMessage.java
Tue Nov 22 20:51:04 2005
@@ -76,15 +76,6 @@
     public void setLocale(String locale) {
         this.locale = locale;
     }
-    
-    /**
-     * Set the key for the message.
-     *
-     * @param key The key to set.
-     */
-    public void setKey(String key) {
-        this.key = key;
-    }
 
     /**
      * Set a replacement value for the message.
@@ -92,7 +83,7 @@
      * @param value The replacement value.
      */
     public void setValue(String value) {
-        this.values = new String[]{value};
+        setValues(new String[]{value});
     }
 
     /**
@@ -101,14 +92,15 @@
      * @return The replacement value.
      */
     public String getValue() {
+        Object[] values = getValues();
         if (values == null || values.length < 1) {
             throw new IllegalStateException("The retrived value for msg " + 
-                    this.key + "was null");
+                    getKey() + "was null");
         }
         if (values.length > 1) {
             throw new IllegalStateException("There were more than one values " +
                     "retrived value for msg " + 
-                    this.key);
+                    getKey());
         }
         return (String)getValues()[0];
     }
@@ -121,7 +113,7 @@
      */
     public boolean equals(Object obj) {
         if (obj instanceof DatabaseBasicMessage){
-            if (((DatabaseBasicMessage)obj).getKey().equals(this.key) && 
+            if (((DatabaseBasicMessage)obj).getKey().equals(getKey()) && 
                     ((DatabaseBasicMessage)obj).getLocale().equals(this.locale)){
                 return true;
             }

Modified: jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java?rev=348369&r1=348368&r2=348369&view=diff
==============================================================================
--- jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java
(original)
+++ jakarta/commons/proper/resources/trunk/src/test/org/apache/commons/resources/MessagesTestCase.java
Tue Nov 22 20:51:04 2005
@@ -242,7 +242,7 @@
 
 		public MyMessages(Resources resources) {
 			super(resources);
-			MyMessages.factory = new ResourcesFactory(){
+			ResourcesFactory factory = new ResourcesFactory(){
 			    public Resources getResources(String name)
 	        	throws ResourcesException{
 				 throw new ResourcesException("Bad Implementation");
@@ -262,6 +262,7 @@
 				
 			}
 		};
+                Messages.setFactory(factory);
 		}
 		
 	}



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


Mime
View raw message