From cfc513043c5830b5a967733066068c7097b42e3c Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Wed, 15 Aug 2007 21:34:53 +0000
Subject: [PATCH] This commit is a step toward getting OpenDS internationalized. There are still issues to be resolved before we can declare that we are internationalized but this commit covers the bulk of changes needed at this time.

---
 opendj-sdk/opends/src/server/org/opends/server/config/ConfigAttribute.java |   84 +++++++++++++++++++-----------------------
 1 files changed, 38 insertions(+), 46 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/config/ConfigAttribute.java b/opendj-sdk/opends/src/server/org/opends/server/config/ConfigAttribute.java
index 2bf7dcd..e1f44d1 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/config/ConfigAttribute.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/config/ConfigAttribute.java
@@ -25,6 +25,7 @@
  *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  */
 package org.opends.server.config;
+import org.opends.messages.Message;
 
 
 
@@ -39,11 +40,7 @@
 import org.opends.server.types.Attribute;
 import org.opends.server.types.AttributeValue;
 
-import static org.opends.server.messages.ConfigMessages.*;
-import static org.opends.server.messages.MessageHandler.*;
-
-
-
+import static org.opends.messages.ConfigMessages.*;
 /**
  * This class defines a configuration attribute, which can hold zero or more
  * values associated with a configurable property within the Directory Server.
@@ -77,7 +74,7 @@
   private LinkedHashSet<AttributeValue> pendingValues;
 
   // The description for this configuration attribute.
-  private String description;
+  private Message description;
 
   // The name for this configuration attribute.
   private String name;
@@ -100,8 +97,9 @@
    *                              configuration attribute require administrative
    *                              action before they will take effect.
    */
-  protected ConfigAttribute(String name, String description, boolean isRequired,
-                            boolean isMultiValued, boolean requiresAdminAction)
+  protected ConfigAttribute(String name, Message description,
+                            boolean isRequired, boolean isMultiValued,
+                            boolean requiresAdminAction)
   {
     this.name                = name;
     this.description         = description;
@@ -132,8 +130,9 @@
    * @param  activeValues         The set of values for this attribute that are
    *                              currently active.
    */
-  protected ConfigAttribute(String name, String description, boolean isRequired,
-                            boolean isMultiValued, boolean requiresAdminAction,
+  protected ConfigAttribute(String name, Message description,
+                            boolean isRequired, boolean isMultiValued,
+                            boolean requiresAdminAction,
                             LinkedHashSet<AttributeValue> activeValues)
   {
     this.name                = name;
@@ -181,8 +180,9 @@
    *                              <CODE>null</CODE> if changes will take effect
    *                              immediately.
    */
-  protected ConfigAttribute(String name, String description, boolean isRequired,
-                            boolean isMultiValued, boolean requiresAdminAction,
+  protected ConfigAttribute(String name, Message description,
+                            boolean isRequired, boolean isMultiValued,
+                            boolean requiresAdminAction,
                             LinkedHashSet<AttributeValue> activeValues,
                             boolean hasPendingValues,
                             LinkedHashSet<AttributeValue> pendingValues)
@@ -240,7 +240,7 @@
    * @return  The description for this configuration attribute, or
    *          <CODE>null</CODE> if there is no description.
    */
-  public String getDescription()
+  public Message getDescription()
   {
     return description;
   }
@@ -401,9 +401,8 @@
     {
       if (isRequired)
       {
-        int    msgID   = MSGID_CONFIG_ATTR_IS_REQUIRED;
-        String message = getMessage(msgID, name);
-        throw new ConfigException(msgID, message);
+        Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(name);
+        throw new ConfigException(message);
       }
       else
       {
@@ -447,10 +446,9 @@
 
     if (! valueIsAcceptable(value, rejectReason))
     {
-      int    msgID   = MSGID_CONFIG_ATTR_REJECTED_VALUE;
-      String message = getMessage(msgID, value.getStringValue(), name,
-                                  rejectReason.toString());
-      throw new ConfigException(msgID, message);
+      Message message = ERR_CONFIG_ATTR_REJECTED_VALUE.get(
+          value.getStringValue(), name, rejectReason.toString());
+      throw new ConfigException(message);
     }
 
 
@@ -458,9 +456,8 @@
     // provided, then reject it.
     if ((! isMultiValued) && iterator.hasNext())
     {
-      int    msgID   = MSGID_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED;
-      String message = getMessage(msgID, name);
-      throw new ConfigException(msgID, message);
+      Message message = ERR_CONFIG_ATTR_SET_VALUES_IS_SINGLE_VALUED.get(name);
+      throw new ConfigException(message);
     }
 
 
@@ -470,10 +467,9 @@
       value = iterator.next();
       if (! valueIsAcceptable(value, rejectReason))
       {
-        int    msgID   = MSGID_CONFIG_ATTR_REJECTED_VALUE;
-        String message = getMessage(msgID, value.getStringValue(), name,
-                                    rejectReason.toString());
-        throw new ConfigException(msgID, message);
+        Message message = ERR_CONFIG_ATTR_REJECTED_VALUE.get(
+            value.getStringValue(), name, rejectReason.toString());
+        throw new ConfigException(message);
       }
     }
 
@@ -560,9 +556,8 @@
       if ((numValues > 1) || (hasPendingValues && (pendingValues.size() > 0)) ||
           ((! hasPendingValues) && (activeValues.size() > 0)))
       {
-        int    msgID   = MSGID_CONFIG_ATTR_ADD_VALUES_IS_SINGLE_VALUED;
-        String message = getMessage(msgID, name);
-        throw new ConfigException(msgID, message);
+        Message message = ERR_CONFIG_ATTR_ADD_VALUES_IS_SINGLE_VALUED.get(name);
+        throw new ConfigException(message);
       }
     }
 
@@ -591,17 +586,16 @@
     {
       if (tempValues.contains(value))
       {
-        int    msgID   = MSGID_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS;
-        String message = getMessage(msgID, name, value.getStringValue());
-        throw new ConfigException(msgID, message);
+        Message message = ERR_CONFIG_ATTR_ADD_VALUES_ALREADY_EXISTS.get(
+            name, value.getStringValue());
+        throw new ConfigException(message);
       }
 
       if (! valueIsAcceptable(value, rejectReason))
       {
-        int    msgID   = MSGID_CONFIG_ATTR_REJECTED_VALUE;
-        String message = getMessage(msgID, value.getStringValue(), name,
-                                    rejectReason.toString());
-        throw new ConfigException(msgID, message);
+        Message message = ERR_CONFIG_ATTR_REJECTED_VALUE.get(
+            value.getStringValue(), name, rejectReason.toString());
+        throw new ConfigException(message);
       }
     }
 
@@ -660,9 +654,9 @@
     {
       if (! tempValues.remove(value))
       {
-        int msgID = MSGID_CONFIG_ATTR_NO_SUCH_VALUE;
-        String message = getMessage(msgID, name, value.getStringValue());
-        throw new ConfigException(msgID, message);
+        Message message =
+            ERR_CONFIG_ATTR_NO_SUCH_VALUE.get(name, value.getStringValue());
+        throw new ConfigException(message);
       }
     }
 
@@ -671,9 +665,8 @@
     // least one value.
     if (isRequired && tempValues.isEmpty())
     {
-      int msgID = MSGID_CONFIG_ATTR_IS_REQUIRED;
-      String message = getMessage(msgID, name);
-      throw new ConfigException(msgID, message);
+      Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(name);
+      throw new ConfigException(message);
     }
 
 
@@ -705,9 +698,8 @@
   {
     if (isRequired)
     {
-      int    msgID   = MSGID_CONFIG_ATTR_IS_REQUIRED;
-      String message = getMessage(msgID, name);
-      throw new ConfigException(msgID, message);
+      Message message = ERR_CONFIG_ATTR_IS_REQUIRED.get(name);
+      throw new ConfigException(message);
     }
 
 

--
Gitblit v1.10.0