logging-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1566245 - /logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
Date Sun, 09 Feb 2014 06:56:01 GMT
Author: ggregory
Date: Sun Feb  9 06:56:01 2014
New Revision: 1566245

URL: http://svn.apache.org/r1566245
Log:
Refactor magic string.

Modified:
    logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java

Modified: logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
URL: http://svn.apache.org/viewvc/logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java?rev=1566245&r1=1566244&r2=1566245&view=diff
==============================================================================
--- logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
(original)
+++ logging/log4j/log4j2/trunk/log4j-api/src/main/java/org/apache/logging/log4j/message/StructuredDataId.java
Sun Feb  9 06:56:01 2014
@@ -23,6 +23,8 @@ import java.io.Serializable;
  */
 public class StructuredDataId implements Serializable {
 
+    private static final String AT = "@";
+
     /**
      * RFC 5424 Time Quality.
      */
@@ -62,7 +64,7 @@ public class StructuredDataId implements
                 throw new IllegalArgumentException(String.format("Length of id %s exceeds
maximum of %d characters",
                         name, MAX_LENGTH));
             }
-            index = name.indexOf("@");
+            index = name.indexOf(AT);
         }
 
         if (index > 0) {
@@ -89,15 +91,15 @@ public class StructuredDataId implements
         if (name == null) {
             throw new IllegalArgumentException("No structured id name was supplied");
         }
-        if (name.contains("@")) {
-            throw new IllegalArgumentException("Structured id name cannot contain an '@");
+        if (name.contains(AT)) {
+            throw new IllegalArgumentException("Structured id name cannot contain an '" +
AT + "'");
         }
         if (enterpriseNumber <= 0) {
             throw new IllegalArgumentException("No enterprise number was supplied");
         }
         this.name = name;
         this.enterpriseNumber = enterpriseNumber;
-        final String id = enterpriseNumber < 0 ? name : name + "@" + enterpriseNumber;
+        final String id = enterpriseNumber < 0 ? name : name + AT + enterpriseNumber;
         if (id.length() > MAX_LENGTH) {
             throw new IllegalArgumentException("Length of id exceeds maximum of 32 characters:
" + id);
         }
@@ -185,6 +187,6 @@ public class StructuredDataId implements
 
     @Override
     public String toString() {
-        return isReserved() ? name : name + "@" + enterpriseNumber;
+        return isReserved() ? name : name + AT + enterpriseNumber;
     }
 }



Mime
View raw message