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 ce...@apache.org on 2005/02/01 11:41:46 UTC
cvs commit: logging-log4j/src/java/org/apache/log4j/lbel Token.java Parser.java TokenStream.java EventEvaluator.java
ceki 2005/02/01 02:41:46
Modified: src/java/org/apache/log4j/lbel Token.java Parser.java
TokenStream.java EventEvaluator.java
Log:
Added NULL support + associated test cases
Revision Changes Path
1.5 +13 -11 logging-log4j/src/java/org/apache/log4j/lbel/Token.java
Index: Token.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/lbel/Token.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Token.java 31 Jan 2005 20:48:06 -0000 1.4
+++ Token.java 1 Feb 2005 10:41:46 -0000 1.5
@@ -7,26 +7,28 @@
private Object value;
public static final int TRUE = 1;
public static final int FALSE = 2;
- public static final int OR = 10;
- public static final int AND = 11;
- public static final int NOT = 12;
+ public static final int OR = 10;
+ public static final int AND = 11;
+ public static final int NOT = 12;
public static final int LITERAL = 20;
- public static final int NUMBER = 21;
+ public static final int NUMBER = 21;
public static final int OPERATOR = 30;
public static final int LP = 40;
public static final int RP = 41;
- public static final int LOGGER = 100;
+
+ public static final int LOGGER = 100;
public static final int MESSAGE = 110;
- public static final int LEVEL = 120;
+ public static final int LEVEL = 120;
public static final int TIMESTAMP = 130;
- public static final int THREAD = 140;
+ public static final int THREAD = 140;
public static final int PROPERTY = 150;
- public static final int DATE = 160;
+ public static final int DATE = 160;
- public static final int CLASS = 170;
+ public static final int CLASS = 170;
public static final int METHOD = 180;
-
- public static final int EOF = 1000;
+ public static final int NULL = 190;
+
+ public static final int EOF = 1000;
public Token(int type) {
this(type, null);
1.9 +4 -1 logging-log4j/src/java/org/apache/log4j/lbel/Parser.java
Index: Parser.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/lbel/Parser.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- Parser.java 31 Jan 2005 20:48:06 -0000 1.8
+++ Parser.java 1 Feb 2005 10:41:46 -0000 1.9
@@ -148,6 +148,7 @@
Token token = ts.getCurrent();
Operator operator;
String literal;
+
switch(token.getType()) {
case Token.TRUE:
ts.next();
@@ -246,8 +247,10 @@
Token token = ts.getCurrent();
if(token.getType() == Token.LITERAL) {
return (String) token.getValue();
+ } else if(token.getType() == Token.NULL) {
+ return null;
} else {
- throw new ScanError("Expected LITERAL but got "+token);
+ throw new ScanError("Expected LITERAL or NULL but got "+token);
}
}
1.7 +1 -0 logging-log4j/src/java/org/apache/log4j/lbel/TokenStream.java
Index: TokenStream.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/lbel/TokenStream.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- TokenStream.java 31 Jan 2005 20:48:06 -0000 1.6
+++ TokenStream.java 1 Feb 2005 10:41:46 -0000 1.7
@@ -45,6 +45,7 @@
keywordMap.put("class", new Token(Token.CLASS, "class"));
keywordMap.put("thread", new Token(Token.THREAD, "thread"));
keywordMap.put("date", new Token(Token.DATE, "date"));
+ keywordMap.put("null", new Token(Token.NULL, "null"));
}
StreamTokenizer tokenizer;
1.2 +5 -3 logging-log4j/src/java/org/apache/log4j/lbel/EventEvaluator.java
Index: EventEvaluator.java
===================================================================
RCS file: /home/cvs/logging-log4j/src/java/org/apache/log4j/lbel/EventEvaluator.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- EventEvaluator.java 27 Jan 2005 14:40:12 -0000 1.1
+++ EventEvaluator.java 1 Feb 2005 10:41:46 -0000 1.2
@@ -31,16 +31,18 @@
public interface EventEvaluator {
+
/**
* Evaluates whether the event passed as parameter matches this evaluator's
- * matching criteria?
+ * matching criteria.
*
* <p>The <code>Evaluator</code> instance is free to evaluate the event as
* it pleases. In particular, the evaluation results <em>may</em> depend on
* previous events.
*
* @param event The event to evaluate
- * @return true if there is a match, false otherwise.
+ * @return true if there is a match, false otherwise.
+ * @throws NullPointerException thrown if lefthand side is null
*/
- boolean evaluate(LoggingEvent event);
+ boolean evaluate(LoggingEvent event) throws NullPointerException;
}
---------------------------------------------------------------------
To unsubscribe, e-mail: log4j-dev-unsubscribe@logging.apache.org
For additional commands, e-mail: log4j-dev-help@logging.apache.org