ceki 01/07/20 09:02:27
Modified: src/java/org/apache/log4j/helpers OptionConverter.java
Log:
toPriority(String value, Priority defaultValue) method now takes the
string "NULL" to mean a null object. This is useful in some configurators.
Revision Changes Path
1.21 +20 -8
jakarta-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java
Index: OptionConverter.java
===================================================================
RCS file:
/home/cvs/jakarta-log4j/src/java/org/apache/log4j/helpers/OptionConverter.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- OptionConverter.java 2001/07/13 07:53:53 1.20
+++ OptionConverter.java 2001/07/20 16:02:27 1.21
@@ -162,15 +162,18 @@
character is present, then the default {@link org.apache.log4j.Priority}
class is used to process the priority value.
+ <p>As a special case, if the <code>value</code> parameter is
+ equal to the string "NULL", then the value <code>null</code> will
+ be returned.
+
<p> If any error occurs while converting the value to a priority,
- the dflt value (which may be null) is returned.
+ the <code>defaultValue</code> parameter, which may be
+ <code>null</code>, is returned.
- <p> Case of
- value is unimportant for the priority level, but is significant
- for any class name part present.
+ <p> Case of <code>value</code> is insignificant for the priority level, but is
+ significant for the class name part, if present.
- @since 1.1
- */
+ @since 1.1 */
public
static
Priority toPriority(String value, Priority defaultValue) {
@@ -179,14 +182,23 @@
int hashIndex = value.indexOf('#');
if (hashIndex == -1) {
- // no class name specified : use standard Priority class
- return Priority.toPriority(value, defaultValue);
+ if("NULL".equalsIgnoreCase(value)) {
+ return null;
+ } else {
+ // no class name specified : use standard Priority class
+ return Priority.toPriority(value, defaultValue);
+ }
}
Priority result = defaultValue;
String clazz = value.substring(hashIndex+1);
String priorityName = value.substring(0, hashIndex);
+
+ // This is degenerate case but you never know.
+ if("NULL".equalsIgnoreCase(priorityName)) {
+ return null;
+ }
LogLog.debug("toPriority" + ":class=[" + clazz + "]"
+ ":pri=[" + priorityName + "]");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]