You are viewing a plain text version of this content. The canonical link for it is here.
Posted to log4j-dev@logging.apache.org by sd...@apache.org on 2010/11/12 08:09:36 UTC

svn commit: r1034281 - in /logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule: ExpressionRule.java InFixToPostFix.java

Author: sdeboy
Date: Fri Nov 12 07:09:35 2010
New Revision: 1034281

URL: http://svn.apache.org/viewvc?rev=1034281&view=rev
Log:
Added per-tab preference to not use a search match color in the primary table
Added ability to use single or double quotes to surround multi-word strings in expressions

Modified:
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java
    logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InFixToPostFix.java

Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java?rev=1034281&r1=1034280&r2=1034281&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/ExpressionRule.java Fri Nov 12 07:09:35 2010
@@ -133,9 +133,10 @@ public class ExpressionRule extends Abst
           while (tokenizer.hasMoreTokens()) {
             //examine each token
             String token = tokenizer.nextToken();
-              if (token.startsWith("'")) {
+              if (token.startsWith("'") || token.startsWith("\"")) {
+                String quoteChar = token.substring(0, 1);
                 token = token.substring(1);
-                while (!token.endsWith("'") && tokenizer.hasMoreTokens()) {
+                while (!token.endsWith(quoteChar) && tokenizer.hasMoreTokens()) {
                   token = token + " " + tokenizer.nextToken();
                 }
                 if (token.length() > 0) {

Modified: logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InFixToPostFix.java
URL: http://svn.apache.org/viewvc/logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InFixToPostFix.java?rev=1034281&r1=1034280&r2=1034281&view=diff
==============================================================================
--- logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InFixToPostFix.java (original)
+++ logging/log4j/companions/extras/trunk/src/main/java/org/apache/log4j/rule/InFixToPostFix.java Fri Nov 12 07:09:35 2010
@@ -32,10 +32,7 @@ import org.apache.log4j.spi.LoggingEvent
  * Currently grouping is supported, as well as all of the
  * Rules supported by <code>RuleFactory</code>
  *
- * NOTE: parsing is supported through the use of <code>StringTokenizer</code>,
- * which means all tokens in the expression must be separated by spaces.
- *
- * Supports grouping via parens, mult-word operands using single quotes,
+ * Supports grouping via parens, mult-word operands using single or double quotes,
  * and these operators:
  *
  * !        NOT operator
@@ -155,11 +152,12 @@ public class InFixToPostFix {
     while (tokenizer.hasMoreTokens()) {
       String token = tokenizer.nextToken();
 
-      boolean inText = (token.startsWith("'") && (!token.endsWith("'")));
+      boolean inText = (token.startsWith("'") && (!token.endsWith("'"))) || (token.startsWith("\"") && (!token.endsWith("\"")));
+      String quoteChar = token.substring(0, 1);
       if (inText) {
           while (inText && tokenizer.hasMoreTokens()) {
             token = token + " " + tokenizer.nextToken();
-            inText = !(token.endsWith("'"));
+            inText = !(token.endsWith(quoteChar));
         }
       }
 
@@ -251,7 +249,7 @@ public class InFixToPostFix {
       keywords.remove("PROP.");
       int pos = 0;
       while (pos < input.length()) {
-        if (nextValueIs(input, pos, "'")) {
+        if (nextValueIs(input, pos, "'") || nextValueIs(input, pos, "\"")) {
           pos = handleQuotedString(input, pos, linkedList);
         }
         if (nextValueIs(input, pos, "PROP.")) {
@@ -298,7 +296,8 @@ public class InFixToPostFix {
     }
 
     private int handleQuotedString(String input, int pos, LinkedList linkedList) {
-      int nextSingleQuotePos = input.indexOf("'", pos + 1);
+      String quoteChar = input.substring(pos, pos + 1);
+      int nextSingleQuotePos = input.indexOf(quoteChar, pos + 1);
       if (nextSingleQuotePos < 0) {
         throw new IllegalArgumentException("Missing an end quote");
       }



---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org