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/protocols/asn1/ASN1OctetString.java |   50 +++++++++++++++++++++++++++++---------------------
 1 files changed, 29 insertions(+), 21 deletions(-)

diff --git a/opendj-sdk/opends/src/server/org/opends/server/protocols/asn1/ASN1OctetString.java b/opendj-sdk/opends/src/server/org/opends/server/protocols/asn1/ASN1OctetString.java
index 98e0572..27789f0 100644
--- a/opendj-sdk/opends/src/server/org/opends/server/protocols/asn1/ASN1OctetString.java
+++ b/opendj-sdk/opends/src/server/org/opends/server/protocols/asn1/ASN1OctetString.java
@@ -25,6 +25,7 @@
  *      Portions Copyright 2006-2007 Sun Microsystems, Inc.
  */
 package org.opends.server.protocols.asn1;
+import org.opends.messages.Message;
 
 
 
@@ -33,8 +34,7 @@
 
 import static org.opends.server.loggers.debug.DebugLogger.*;
 import org.opends.server.loggers.debug.DebugTracer;
-import static org.opends.server.messages.MessageHandler.*;
-import static org.opends.server.messages.ProtocolMessages.*;
+import static org.opends.messages.ProtocolMessages.*;
 import static org.opends.server.protocols.asn1.ASN1Constants.*;
 import static org.opends.server.util.ServerConstants.*;
 import static org.opends.server.util.StaticUtils.*;
@@ -127,6 +127,20 @@
    * Creates a new ASN.1 octet string element with the default type and the
    * provided value.
    *
+   * @param  messageValue  The value for this ASN.1 octet string element as a
+   *                      string.
+   */
+  public ASN1OctetString(Message messageValue)
+  {
+    this(messageValue != null ? messageValue.toString() : null);
+  }
+
+
+
+  /**
+   * Creates a new ASN.1 octet string element with the default type and the
+   * provided value.
+   *
    * @param  stringValue  The value for this ASN.1 octet string element as a
    *                      string.
    */
@@ -330,9 +344,8 @@
   {
     if (element == null)
     {
-      int    msgID   = MSGID_ASN1_OCTET_STRING_DECODE_ELEMENT_NULL;
-      String message = getMessage(msgID);
-      throw new ASN1Exception(msgID, message);
+      Message message = ERR_ASN1_OCTET_STRING_DECODE_ELEMENT_NULL.get();
+      throw new ASN1Exception(message);
     }
 
     return new ASN1OctetString(element.getType(), element.value());
@@ -358,16 +371,14 @@
     // a valid ASN.1 element.
     if (encodedElement == null)
     {
-      int    msgID   = MSGID_ASN1_OCTET_STRING_DECODE_ARRAY_NULL;
-      String message = getMessage(msgID);
-      throw new ASN1Exception(msgID, message);
+      Message message = ERR_ASN1_OCTET_STRING_DECODE_ARRAY_NULL.get();
+      throw new ASN1Exception(message);
     }
 
     if (encodedElement.length < 2)
     {
-      int    msgID   = MSGID_ASN1_SHORT_ELEMENT;
-      String message = getMessage(msgID, encodedElement.length);
-      throw new ASN1Exception(msgID, message);
+      Message message = ERR_ASN1_SHORT_ELEMENT.get(encodedElement.length);
+      throw new ASN1Exception(message);
     }
 
 
@@ -381,15 +392,13 @@
       int numLengthBytes = length;
       if (numLengthBytes > 4)
       {
-        int    msgID   = MSGID_ASN1_INVALID_NUM_LENGTH_BYTES;
-        String message = getMessage(msgID, numLengthBytes);
-        throw new ASN1Exception(msgID, message);
+        Message message = ERR_ASN1_INVALID_NUM_LENGTH_BYTES.get(numLengthBytes);
+        throw new ASN1Exception(message);
       }
       else if (encodedElement.length < (2 + numLengthBytes))
       {
-        int    msgID   = MSGID_ASN1_TRUNCATED_LENGTH;
-        String message = getMessage(msgID, numLengthBytes);
-        throw new ASN1Exception(msgID, message);
+        Message message = ERR_ASN1_TRUNCATED_LENGTH.get(numLengthBytes);
+        throw new ASN1Exception(message);
       }
 
       length = 0x00;
@@ -405,10 +414,9 @@
     // in the value.
     if ((encodedElement.length - valueStartPos) != length)
     {
-      int    msgID   = MSGID_ASN1_LENGTH_MISMATCH;
-      String message = getMessage(msgID, length,
-                                  (encodedElement.length - valueStartPos));
-      throw new ASN1Exception(msgID, message);
+      Message message = ERR_ASN1_LENGTH_MISMATCH.get(
+          length, (encodedElement.length - valueStartPos));
+      throw new ASN1Exception(message);
     }
 
 

--
Gitblit v1.10.0