From 3e8f6ef36b4d8bacc1470bfebcacda7b6e2fc351 Mon Sep 17 00:00:00 2001
From: kenneth_suter <kenneth_suter@localhost>
Date: Fri, 17 Aug 2007 14:35:22 +0000
Subject: [PATCH] Fixed some minor issues that were pointed out in review of the messages commit. This biggest issues here is the reversion of the Validator class to use String based messages instead of the message framework as the class is only used internally.
---
opends/src/server/org/opends/server/util/Validator.java | 59 ++++++++++++++++++++++++++++-------------------------------
1 files changed, 28 insertions(+), 31 deletions(-)
diff --git a/opends/src/server/org/opends/server/util/Validator.java b/opends/src/server/org/opends/server/util/Validator.java
index 35c6a40..ec24463 100644
--- a/opends/src/server/org/opends/server/util/Validator.java
+++ b/opends/src/server/org/opends/server/util/Validator.java
@@ -31,9 +31,6 @@
import org.opends.server.loggers.debug.DebugTracer;
import org.opends.server.loggers.ErrorLogger;
-
-import org.opends.messages.MessageBuilder;
-
/**
* This utility class provides static methods that make parameter checking
* easier (e.g. in constructors and setters).
@@ -154,7 +151,7 @@
public static boolean ensureNotNull(Object param)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param == null) throwNull(Message.EMPTY);
+ if (param == null) throwNull("");
}
return true;
}
@@ -186,8 +183,8 @@
public static boolean ensureNotNull(Object param1, Object param2)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
}
return true;
}
@@ -221,9 +218,9 @@
Object param3)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
- if (param3 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[3]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
+ if (param3 == null) throwNull(PARAM_DESCRIPTIONS[3]);
}
return true;
}
@@ -258,10 +255,10 @@
Object param3, Object param4)
throws AssertionError {
if (ENABLE_CHECKS) {
- if (param1 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[1]));
- if (param2 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[2]));
- if (param3 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[3]));
- if (param4 == null) throwNull(Message.raw(PARAM_DESCRIPTIONS[4]));
+ if (param1 == null) throwNull(PARAM_DESCRIPTIONS[1]);
+ if (param2 == null) throwNull(PARAM_DESCRIPTIONS[2]);
+ if (param3 == null) throwNull(PARAM_DESCRIPTIONS[3]);
+ if (param4 == null) throwNull(PARAM_DESCRIPTIONS[4]);
}
return true;
}
@@ -289,7 +286,7 @@
throws AssertionError {
if (ENABLE_CHECKS) {
if (!condition) {
- ensureTrue(condition, Message.EMPTY);
+ ensureTrue(condition, "");
}
}
return true;
@@ -317,18 +314,18 @@
*
* @throws AssertionError if condition is false
*/
- public static boolean ensureTrue(boolean condition, Message message)
+ public static boolean ensureTrue(boolean condition, String message)
throws AssertionError {
if (ENABLE_CHECKS) {
if (!condition) {
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append("The specified condition must be true. ");
mb.append(message);
- Message fullMessage = generateLineSpecificErrorMessage(mb.toMessage());
+ String fullString = generateLineSpecificErrorString(mb.toString());
- logError(fullMessage);
+ logError(fullString);
- throw new AssertionError(fullMessage);
+ throw new AssertionError(fullString);
}
}
return true;
@@ -377,37 +374,37 @@
////////////////////////////////////////////////////////////////////////////
- private static Message generateLineSpecificErrorMessage(Message message) {
- MessageBuilder mb = new MessageBuilder();
+ private static String generateLineSpecificErrorString(String message) {
+ StringBuilder mb = new StringBuilder();
mb.append(message);
mb.append(" The error occurred at ");
mb.append(getOriginalCallerLineInfo());
- return mb.toMessage();
+ return mb.toString();
}
- private static void throwNull(Message message)
+ private static void throwNull(String message)
throws AssertionError {
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append("The specified parameter must not be null. ");
mb.append(message);
- Message fullMessage = generateLineSpecificErrorMessage(mb.toMessage());
+ String fullString = generateLineSpecificErrorString(mb.toString());
- logError(fullMessage);
+ logError(fullString);
- throw new AssertionError(fullMessage);
+ throw new AssertionError(fullString);
}
- private static void logError(Message message) {
+ private static void logError(String message) {
incrementErrorCount();
- MessageBuilder mb = new MessageBuilder();
+ StringBuilder mb = new StringBuilder();
mb.append(message);
mb.append(ServerConstants.EOL);
mb.append(getCallingStack());
- Message messageWithStack = mb.toMessage();
+ String messageWithStack = mb.toString();
// Log to the debug log.
if (debugEnabled())
@@ -416,7 +413,7 @@
}
// Log to the error log.
- ErrorLogger.logError(messageWithStack);
+ ErrorLogger.logError(Message.raw(messageWithStack));
}
--
Gitblit v1.10.0