From 084d35831b733458204eb7043a8b77beba2a75e6 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 12 Oct 2007 22:17:41 +0000
Subject: [PATCH] issue 2142: fixes MessageBuilder.toMessage to that the resulting message maintains the ability to be rendered in locales different that the local locale.

---
 opendj-sdk/opends/src/messages/src/org/opends/messages/MessageBuilder.java |   34 ++++++++++++++--------------------
 1 files changed, 14 insertions(+), 20 deletions(-)

diff --git a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageBuilder.java b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageBuilder.java
index 418576f..e412c2f 100644
--- a/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageBuilder.java
+++ b/opendj-sdk/opends/src/messages/src/org/opends/messages/MessageBuilder.java
@@ -158,13 +158,17 @@
   /**
    * Append a string to this builder.
    *
-   * @param rawString to append
+   * @param cs to append
    * @return reference to this builder
    */
-  public MessageBuilder append(CharSequence rawString) {
-    if (rawString != null) {
-      sb.append(rawString);
-      messages.add(Message.raw(rawString));
+  public MessageBuilder append(CharSequence cs) {
+    if (cs != null) {
+      sb.append(cs);
+      if (cs instanceof Message) {
+        messages.add((Message)cs);
+      } else {
+        messages.add(Message.raw(cs));
+      }
     }
     return this;
   }
@@ -254,21 +258,11 @@
    * @return Message raw message representing builder content
    */
   public Message toMessage() {
-    return Message.raw(sb.toString());
-  }
-
-  /**
-   * Returns a raw message representation of the appended
-   * content in a specific locale.  Only <code>Message</code>s
-   * appended to this builder are rendered in the requested
-   * locale.  Raw strings appended to this buffer are not
-   * translated to different locale.
-   *
-   * @param locale requested
-   * @return Message raw message representing builder content
-   */
-  public Message toMessage(Locale locale) {
-    return Message.raw(toString(locale));
+    StringBuffer fmtString = new StringBuffer();
+    for (int i = 0; i < messages.size(); i++) {
+      fmtString.append("%s");
+    }
+    return Message.raw(fmtString, messages.toArray());
   }
 
   /**

--
Gitblit v1.10.0