User: user57 Date: 02/02/13 18:54:30 Modified: src/main/org/jboss/mq/selectors Operator.java Selector.java Added: src/main/org/jboss/mq/selectors SelectorParser.jj Removed: src/main/org/jboss/mq/selectors ASCII_CharStream.java ParseException.java SelectorParser.java SelectorParserConstants.java SelectorParserTokenManager.java Token.java TokenMgrError.java jms.jj Log: o Removing files generated by JavaCC. o Renamed jms.jj to SelectorParser.jj (it generates SelectorParser.java) o Made SelectorParser the deafult o Fixed build system to correctly build the parser Revision Changes Path 1.5 +4 -27 jbossmq/src/main/org/jboss/mq/selectors/Operator.java Index: Operator.java =================================================================== RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/Operator.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Operator.java 24 Aug 2001 17:27:08 -0000 1.4 +++ Operator.java 14 Feb 2002 02:54:29 -0000 1.5 @@ -9,15 +9,16 @@ import java.util.HashSet; /** - * An operator for the selector system + * An operator for the selector system. * * @author Norbert Lataille ([EMAIL PROTECTED]) * @author [EMAIL PROTECTED] * @author [EMAIL PROTECTED] * @created August 16, 2001 - * @version $Revision: 1.4 $ + * @version $Revision: 1.5 $ */ -public class Operator { +public class Operator +{ int operation; Object oper1; Object oper2; @@ -32,53 +33,29 @@ int class3; public final static int EQUAL = 0; - //Done public final static int NOT = 1; - //Done public final static int AND = 2; - //Done public final static int OR = 3; - //Done public final static int GT = 4; - //Done public final static int GE = 5; - //Done public final static int LT = 6; - //Done public final static int LE = 7; - //Done public final static int DIFFERENT = 8; - //Done public final static int ADD = 9; - //Done public final static int SUB = 10; - //Done public final static int NEG = 11; - //Done public final static int MUL = 12; - //Done public final static int DIV = 13; - //Done public final static int BETWEEN = 14; - //Done public final static int NOT_BETWEEN = 15; - //Done public final static int LIKE = 16; - //Done public final static int NOT_LIKE = 17; - //Done public final static int LIKE_ESCAPE = 18; - //Done public final static int NOT_LIKE_ESCAPE = 19; - //Done public final static int IS_NULL = 20; - //Done public final static int IS_NOT_NULL = 21; - //Done public final static int IN = 22; - //Done public final static int NOT_IN = 23; - //Done public final static int STRING = 0; public final static int DOUBLE = 1; 1.8 +32 -25 jbossmq/src/main/org/jboss/mq/selectors/Selector.java Index: Selector.java =================================================================== RCS file: /cvsroot/jboss/jbossmq/src/main/org/jboss/mq/selectors/Selector.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- Selector.java 13 Jan 2002 01:10:03 -0000 1.7 +++ Selector.java 14 Feb 2002 02:54:29 -0000 1.8 @@ -17,37 +17,44 @@ import org.jboss.mq.SpyMessage; /** - * This class implements a Message Selector. + * This class implements a Message Selector. * * @author Norbert Lataille ([EMAIL PROTECTED]) * @author Juha Lindfors ([EMAIL PROTECTED]) * @author <a href="mailto:[EMAIL PROTECTED]">Jason Dillon</a> * @author [EMAIL PROTECTED] * @created August 16, 2001 - * @version $Revision: 1.7 $ + * @version $Revision: 1.8 $ */ public class Selector { /** The logging interface */ static Logger cat = Logger.getLogger(Selector.class); + /** The ISelectorParser implementation class */ - private static Class parserClass = parser.class; + private static Class parserClass = SelectorParser.class; public HashMap identifiers; + public Object result; + private Class resultType; - /** Get the class that implements the ISelectorParser interface to be used by - Selector instances. + /** + * Get the class that implements the ISelectorParser interface to be used by + * Selector instances. */ public static Class getSelectorParserClass() { return Selector.parserClass; } - /** Set the class that implements the ISelectorParser interface to be used by - Selector instances. - @param parserClass, the ISelectorParser implementation. This must have a - public no-arg constructor. + + /** + * Set the class that implements the ISelectorParser interface to be used by + * Selector instances. + * + * @param parserClass the ISelectorParser implementation. This must have a + * public no-arg constructor. */ public static void setSelectorParserClass(Class parserClass) { @@ -72,9 +79,9 @@ throw exception; } - // if (cat.isDebugEnabled()) { - // cat.debug("result: " + resultType + " = " + result); - // } + // if (log.isDebugEnabled()) { + // log.debug("result: " + resultType + " = " + result); + // } } public boolean test(SpyMessage.Header mes) throws JMSException @@ -88,11 +95,11 @@ { Identifier id = (Identifier)i.next(); Object find = mes.jmsProperties.get(id.name); - // if (cat.isDebugEnabled()) { - // cat.debug("Identifier: " + id); - // cat.debug("Property: " + find); + // if (log.isDebugEnabled()) { + // log.debug("Identifier: " + id); + // log.debug("Property: " + find); // if (find != null) { - // cat.debug("Property type: " + find.getClass()); + // log.debug("Property type: " + find.getClass()); // } // } @@ -103,9 +110,9 @@ if (find == null) { - //if (cat.isDebugEnabled()) + //if (log.isDebugEnabled()) //{ - // cat.debug("Warning : missing property " + id.name); + // log.debug("Warning : missing property " + id.name); //} id.value = null; } @@ -128,8 +135,8 @@ throw new Exception("Bad property type: " + type); } - // if (cat.isDebugEnabled()) { - // cat.debug("SEL:" + id.name + " =>" + id.value); + // if (log.isDebugEnabled()) { + // log.debug("SEL:" + id.name + " =>" + id.value); // } } } @@ -150,10 +157,10 @@ res = result; } - // if (cat.isDebugEnabled()) { - // cat.debug("res: " + res); + // if (log.isDebugEnabled()) { + // log.debug("res: " + res); // if (result != null) { - // cat.debug("res type: " + res.getClass()); + // log.debug("res type: " + res.getClass()); // } // } @@ -167,8 +174,8 @@ throw new Exception("Bad object type: " + res); } - // if (cat.isDebugEnabled()) { - // cat.debug("Selectors =>" + res); + // if (log.isDebugEnabled()) { + // log.debug("Selectors =>" + res); // } return ((Boolean )res).booleanValue(); 1.1 jbossmq/src/main/org/jboss/mq/selectors/SelectorParser.jj Index: SelectorParser.jj =================================================================== // A JavaCC 2.0 grammar for the JMS 1.0.2 message selectors. options { LOOKAHEAD=1; } PARSER_BEGIN(SelectorParser) package org.jboss.mq.selectors; import java.io.StringReader; import java.util.HashSet; import java.util.HashMap; /** * A JavaCC 2.0 grammar for the JMS 1.0.2 message selectors. * * @see http://www.webgain.com/products/metamata/java_doc.html * @author [EMAIL PROTECTED] * @version $Revision: 1.1 $ */ public class SelectorParser implements ISelectorParser { private HashMap identifierMap; public static Object doParse(String selector, HashMap identifierMap) throws ParseException { return doParse(selector, identifierMap, false); } public static Object doParse(String selector, HashMap identifierMap, boolean trace) throws ParseException { SelectorParser parser = new SelectorParser(); return parser.parse(selector, identifierMap, trace); } public Object parse(String selector, HashMap identifierMap) throws ParseException { return parse(selector, identifierMap, false); } public Object parse(String selector, HashMap identifierMap, boolean trace) throws ParseException { StringReader sr = new StringReader(selector); ReInit(sr); if( trace ) this.enable_tracing(); else this.disable_tracing(); this.identifierMap = identifierMap; return this.expression(); } public SelectorParser() { } } PARSER_END(SelectorParser) SKIP : { " " | "\r" | "\t" | "\n" } /* RESERVED WORDS AND LITERALS */ TOKEN : { < TRUE: "TRUE" | "true" > | < FALSE: "FALSE" | "false" > | < BOOLEAN: <TRUE> | <FALSE> > | < NULL: "NULL" | "null" > | < AND: "AND" | "and" > | < NOT: "NOT" > | < OR: "OR" | "or" > | < BETWEEN: "BETWEEN" | "between" > | < LIKE: "LIKE" | "like" > | < IN: "IN" | "in" > | < IS: "IS" | "is" > | < ESCAPE: "ESCAPE" | "escape" > | < LPAREN: "(" > | < RPAREN: ")" > | < SEMICOLON: ";" > | < COMMA: "," > } TOKEN : /* OPERATORS */ { < MULT: "*" > | < DIV: "/" > | < MINUS: "-" > | < PLUS: "+" > | < GT: ">" > | < GE: ">=" > | < LT: "<" > | < LE: "<=" > | < NE: "<>" > | < EQ: "=" > } TOKEN : /* Literals */ { < LONG: ( ["0" - "9"] )+ > | < DOUBLE: <FLOAT> | <FLOAT> ( ["e","E"] ([ "-","+"])? <LONG> )? > | < #FLOAT: <LONG> ( "." <LONG> )? | "." <LONG> > | < STRING: "'" ( (~["'","\n","\r"]) | ("''") )* "'" > } TOKEN : /* Function names */ { < IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)* > | < #LETTER: [ "_","$", "a"-"z", "A"-"Z" ] > | < #DIGIT: ["0" - "9"] > } /** Start of the grammar */ Object expression() : { Object exp1 = null; } { exp1 = logicExpression() { return exp1; } } Object logicExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=notExpression() ( <AND> exp2=notExpression() { exp1 = new Operator(Operator.AND, exp1, exp2); } | <OR> notExpression() { exp1 = new Operator(Operator.OR, exp1, exp2); } )* { return exp1; } } Object notExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=relationalExpression() { return exp1; } | <NOT> exp1=relationalExpression() { exp1 = new Operator(Operator.NOT, exp1); } { return exp1; } } Object relationalExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=orEqualExpression() ( <LT> exp2=orEqualExpression() { exp1 = new Operator(Operator.LT, exp1, exp2); } | <GT> orEqualExpression() { exp1 = new Operator(Operator.GT, exp1, exp2); } )* { return exp1; } } Object orEqualExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=equalExpression() ( ( <LE> exp2=equalExpression() { exp1 = new Operator(Operator.LE, exp1, exp2); } ) | ( <GE> equalExpression() { exp1 = new Operator(Operator.GE, exp1, exp2); } ) )* { return exp1; } } Object equalExpression() : { Object exp1 = null; Object exp2 = null; Object exp3 = null; HashSet set = null; } { exp1=additiveExpression() ( <NE> exp2=additiveExpression() { exp1 = new Operator(Operator.DIFFERENT, exp1, exp2); } | <EQ> exp2=additiveExpression() { exp1 = new Operator(Operator.EQUAL, exp1, exp2); } | <IS> exp1=nullExp(exp1) | <BETWEEN> exp2=additiveExpression() <AND> exp3=additiveExpression() { exp1 = new Operator(Operator.BETWEEN, exp1, exp2, exp3); } | <LIKE> exp1=likeExp(exp1) | <IN> <LPAREN> { set = new HashSet(); } strings(set) <RPAREN> { exp1 = new Operator(Operator.IN, exp1, set); } )* { return exp1; } } Object additiveExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=multiplicativeExpression() ( ( <PLUS> exp2=multiplicativeExpression() { exp1 = new Operator(Operator.ADD, exp1, exp2); } ) | ( <MINUS> exp2=multiplicativeExpression() { exp1 = new Operator(Operator.SUB, exp1, exp2); } ) )* { return exp1; } } Object multiplicativeExpression() : { Object exp1 = null; Object exp2 = null; } { exp1=unaryExpression() ( ( <MULT> exp2=unaryExpression() { exp1 = new Operator(Operator.MUL, exp1, exp2); } ) | ( <DIV> exp2=unaryExpression() { exp1 = new Operator(Operator.DIV, exp1, exp2); } ) )* { return exp1; } } Object unaryExpression() : { Object exp1 = null; } { <PLUS> exp1=unaryExpression() { return exp1; } | <MINUS> exp1=unaryExpression() { return new Operator(Operator.NEG, exp1); } | exp1=unaryExpressionNotPlusMinus() { return exp1; } } Object unaryExpressionNotPlusMinus() : { Token t = null; Object exp = null; } { t=<IDENTIFIER> { Identifier id = new Identifier(t.image); identifierMap.put(t.image, id); return id; } | t=<STRING> { return t.image; } | t=<DOUBLE> { return Double.valueOf(t.image); } | t=<LONG> { return Long.valueOf(t.image); } | t=<BOOLEAN> { return Boolean.valueOf(t.image); } | <LPAREN> exp=expression() <RPAREN> { return exp; } } Operator nullExp(Object exp1) : { Token not = null; } { [ not=<NOT> ] <NULL> { int opCode = not == null ? Operator.IS_NULL : Operator.IS_NOT_NULL; return new Operator(opCode, exp1); } } Operator likeExp(Object exp1) : { Object exp2 = null; Object exp3 = null; Token esc = null; } { exp2=additiveExpression() [ esc=<ESCAPE> exp3=additiveExpression() ] { Operator op = null; if( esc == null ) op = new Operator(Operator.LIKE, exp1, exp2); else op = new Operator(Operator.LIKE_ESCAPE, exp1, exp2, exp3); return op; } } void strings(HashSet set) : { Token tk = null; } { <COMMA> strings(set) | [ tk=<STRING> ] { if( tk != null ) set.add(tk.image); } }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development