KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mr > api > jms > selector > syntax > ExpressionFactory


1 /*
2  * Copyright 2002 by
3  * <a HREF="http://www.coridan.com">Coridan</a>
4  * <a HREF="mailto: support@coridan.com ">support@coridan.com</a>
5  *
6  * The contents of this file are subject to the Mozilla Public License Version
7  * 1.1 (the "License"); you may not use this file except in compliance with the
8  * License. You may obtain a copy of the License at
9  * http://www.mozilla.org/MPL/
10  *
11  * Software distributed under the License is distributed on an "AS IS" basis,
12  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13  * for the specific language governing rights and limitations under the
14  * License.
15  *
16  * The Original Code is "MantaRay" (TM).
17  *
18  * The Initial Developer of the Original Code is Coridan.
19  * Portions created by the Initial Developer are Copyright (C) 2006
20  * Coridan Inc. All Rights Reserved.
21  *
22  * Contributor(s): all the names of the contributors are added in the source
23  * code where applicable.
24  *
25  * Alternatively, the contents of this file may be used under the terms of the
26  * LGPL license (the "GNU LESSER GENERAL PUBLIC LICENSE"), in which case the
27  * provisions of LGPL are applicable instead of those above. If you wish to
28  * allow use of your version of this file only under the terms of the LGPL
29  * License and not to allow others to use your version of this file under
30  * the MPL, indicate your decision by deleting the provisions above and
31  * replace them with the notice and other provisions required by the LGPL.
32  * If you do not delete the provisions above, a recipient may use your version
33  * of this file under either the MPL or the GNU LESSER GENERAL PUBLIC LICENSE.
34  
35  *
36  * This library is free software; you can redistribute it and/or modify it
37  * under the terms of the MPL as stated above or under the terms of the GNU
38  * Lesser General Public License as published by the Free Software Foundation;
39  * either version 2.1 of the License, or any later version.
40  *
41  * This library is distributed in the hope that it will be useful, but WITHOUT
42  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
43  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
44  * License for more details.
45  */

46 package org.mr.api.jms.selector.syntax;
47
48 import java.util.HashSet JavaDoc;
49
50
51 /**
52  * This interface specifies the methods needed to create all of the
53  * expressions supported by the message selector. It exists solely to
54  * decouple the expression evaluation classes from the parser.
55  *
56  */

57 public interface ExpressionFactory {
58
59     /**
60      * Create a binary operator expression
61      *
62      * @param operator the operator token type from SelectorTokenTypes
63      * @param left the left-hand side of the binary expression
64      * @param right the right-hand side of the binary expression
65      * @return a new binary expression
66      * @throws SelectorException if the operator is not a valid binary operator
67      */

68     Expression binaryOperator(int operator, Expression left, Expression right) throws SelectorException;
69
70     /**
71      * Create an unary operator expression
72      *
73      * @param operator the operator token type from SelectorTokenTypes
74      * @param operand the expression to apply the operator to
75      * @return a new unary expression
76      * @throws SelectorException if the operator is not a valid unary operator
77      */

78     Expression unaryOperator(int operator, Expression operand) throws SelectorException;
79
80     /**
81      * Create an identifier expression
82      *
83      * @param name the name of the identifier
84      * @return a new identifier expression
85      * @throws SelectorException is name is not a valid identifier
86      */

87     Expression identifier(String JavaDoc name) throws SelectorException;
88
89     /**
90      * Create an 'is null' expression
91      *
92      * @param identifier the identifer expression to apply the 'is null' test
93      * @return an 'is null' expression
94      * @throws SelectorException for any error
95      */

96     Expression isNull(Expression identifier) throws SelectorException;
97
98     /**
99      * Create a 'like' expression
100      *
101      * @param identifier the identifer to apply the 'like' test to
102      * @param pattern the search pattern
103      * @param escape the escape character. This may be null
104      * @return a new 'like' expression
105      * @throws SelectorException if the pattern or escape is invalid
106      */

107     Expression like(Expression identifier, String JavaDoc pattern, String JavaDoc escape) throws SelectorException;
108
109     /**
110      * Create a 'between' expression that returns the result of:<br/>
111      * num1 >= num2 and num1 <= num3
112      * when evaluated
113      *
114      * @param num1 an arithmethic expression
115      * @param num2 an arithmethic expression
116      * @param num3 an arithmethic expression
117      * @return a new 'between' expression
118      * @throws SelectorException for any error
119      */

120     Expression between(Expression num1, Expression num2, Expression num3) throws SelectorException;
121
122     /**
123      * Create an 'in' expression
124      *
125      * @param identifier string identifer to apply the 'in' test to
126      * @param set the set of string values to compare against
127      * @return a new 'in' expression
128      * @throws SelectorException for any error
129      */

130     Expression in(Expression identifier, HashSet JavaDoc set) throws SelectorException;
131
132     /**
133      * Create a literal expression
134      *
135      * @param type the operator token type from SelectorTokenTypes
136      * @param text the literal text
137      * @return a new literal expression
138      * @throws SelectorException if type is not a valid literal type
139      */

140     Expression literal(int type, String JavaDoc text) throws SelectorException;
141
142 }//ExpressionFactory
143
Popular Tags