User: norbert
Date: 00/12/29 14:24:43
Modified: src/java/org/spydermq/selectors Operator.java Selector.java
Log:
A new release of the Operator class after an intensive test...
Revision Changes Path
1.5 +56 -40 spyderMQ/src/java/org/spydermq/selectors/Operator.java
Index: Operator.java
===================================================================
RCS file:
/products/cvs/ejboss/spyderMQ/src/java/org/spydermq/selectors/Operator.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Operator.java 2000/12/29 19:32:45 1.4
+++ Operator.java 2000/12/29 22:24:42 1.5
@@ -7,6 +7,7 @@
package org.spydermq.selectors;
import java.util.HashSet;
+import org.spydermq.Log;
/**
* An operator for the selector system
@@ -14,7 +15,7 @@
* @author Norbert Lataille ([EMAIL PROTECTED])
* @author [EMAIL PROTECTED]
*
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class Operator
{
@@ -41,24 +42,24 @@
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;
- public final static int NOT_LIKE = 17;
- public final static int LIKE_ESCAPE = 18;
- public final static int NOT_LIKE_ESCAPE = 19;
- 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 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;
- public final static int LONG = 2;
+ public final static int DOUBLE = 1; //DOUBLE FLOAT
+ public final static int LONG = 2; //LONG BYTE SHORT INTEGER
public final static int BOOLEAN = 3;
public Operator(int operation, Object oper1, Object oper2, Object oper3)
@@ -93,7 +94,7 @@
if (arg1==null) return Boolean.FALSE;
switch (class1) {
- case STRING:
+ case STRING:
case LONG:
case DOUBLE:
computeArgument2();
@@ -182,7 +183,7 @@
if (class2!=DOUBLE) throw new Exception("GT: Bad object type");
return new Boolean(((Double)arg1).doubleValue() >
((Double)arg2).doubleValue());
}
-
+
throw new Exception("GT: Bad object type");
}
@@ -362,9 +363,10 @@
//Operator 13
Object div() throws Exception
{//Can throw Divide by zero exception...
+
computeArgument1();
computeArgument2();
-
+
if (arg1==null||arg2==null) return null;
switch (class1) {
case DOUBLE:
@@ -373,7 +375,7 @@
case LONG: return new
Double(((Double)arg1).doubleValue()/((Long)arg2).doubleValue());
default: throw new Exception("DIV: Bad object type");
}
- case LONG:
+ case LONG:
switch (class2) {
case DOUBLE: return new
Double(((Long)arg1).doubleValue()/((Double)arg2).doubleValue());
case LONG: return new
Long(((Long)arg1).longValue()/((Long)arg2).longValue());
@@ -387,34 +389,29 @@
//Operator 14
Object between() throws Exception
{
- computeArgument1();
- computeArgument2();
- computeArgument3();
-
Object res=ge();
if (res==null) return null;
- if ((Boolean)res==Boolean.FALSE) return res;
+ if (!((Boolean)res).booleanValue()) return res;
- arg2=arg3;
- class2=class3;
- return le();
+ Object oper4=oper2;
+ oper2=oper3;
+ res=le();
+ oper2=oper4;
+ return res;
}
-
//Operator 15
Object not_between() throws Exception
{
- computeArgument1();
- computeArgument2();
- computeArgument3();
-
Object res=lt();
if (res==null) return null;
- if ((Boolean)res==Boolean.TRUE) return res;
+ if (((Boolean)res).booleanValue()) return res;
- arg2=arg3;
- class2=class3;
- return gt();
+ Object oper4=oper2;
+ oper2=oper3;
+ res=gt();
+ oper2=oper4;
+ return res;
}
//Operation 16,17,18,19
@@ -544,7 +541,7 @@
computeArgument1();
if (arg1==null) return null;
- if (((HashSet)arg2).contains(arg1)) return Boolean.TRUE;
+ if (((HashSet)oper2).contains(arg1)) return Boolean.TRUE;
else return Boolean.FALSE;
}
@@ -553,7 +550,8 @@
{
computeArgument1();
- if (((HashSet)arg2).contains(arg1)) return Boolean.FALSE;
+ if (arg1==null) return null;
+ if (((HashSet)oper2).contains(arg1)) return Boolean.FALSE;
else return Boolean.TRUE;
}
@@ -581,6 +579,12 @@
else if (className==Integer.class) {
class1=LONG;
arg1=new Long(((Integer)arg1).longValue());
+ } else if (className==Short.class) {
+ class1=LONG;
+ arg1=new Long(((Short)arg1).longValue());
+ } else if (className==Byte.class) {
+ class1=LONG;
+ arg1=new Long(((Byte)arg1).longValue());
} else if (className==Float.class) {
class1=DOUBLE;
arg1=new Double(((Float)arg1).doubleValue());
@@ -611,6 +615,12 @@
else if (className==Integer.class) {
class2=LONG;
arg2=new Long(((Integer)arg2).longValue());
+ } else if (className==Short.class) {
+ class2=LONG;
+ arg2=new Long(((Short)arg2).longValue());
+ } else if (className==Byte.class) {
+ class2=LONG;
+ arg2=new Long(((Byte)arg2).longValue());
} else if (className==Float.class) {
class2=DOUBLE;
arg2=new Double(((Float)arg2).doubleValue());
@@ -641,6 +651,12 @@
else if (className==Integer.class) {
class3=LONG;
arg3=new Long(((Integer)arg3).longValue());
+ } else if (className==Short.class) {
+ class3=LONG;
+ arg3=new Long(((Short)arg3).longValue());
+ } else if (className==Byte.class) {
+ class3=LONG;
+ arg3=new Long(((Byte)arg3).longValue());
} else if (className==Float.class) {
class3=DOUBLE;
arg3=new Double(((Float)arg3).doubleValue());
1.3 +9 -4 spyderMQ/src/java/org/spydermq/selectors/Selector.java
Index: Selector.java
===================================================================
RCS file:
/products/cvs/ejboss/spyderMQ/src/java/org/spydermq/selectors/Selector.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Selector.java 2000/12/29 19:32:45 1.2
+++ Selector.java 2000/12/29 22:24:42 1.3
@@ -17,7 +17,7 @@
*
* @author Norbert Lataille ([EMAIL PROTECTED])
*
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class Selector
{
@@ -38,7 +38,7 @@
throw exception;
}
- Log.notice(result.toString());
+ //Log.notice(result.toString());
}
public boolean test(SpyMessage mes) throws JMSException
@@ -59,9 +59,12 @@
} else {
Class type=find.getClass();
if (type.equals(Boolean.class) ||
type.equals(String.class)
- || type.equals(Double.class) ||
type.equals(Integer.class))
+ || type.equals(Double.class) ||
type.equals(Float.class)
+ || type.equals(Integer.class) ||
type.equals(Long.class)
+ || type.equals(Short.class) ||
type.equals(Byte.class))
id.value=find;
else throw new Exception("Bad property type
!");
+ //Log.notice("SEL:"+id.name+" =>"+id.value);
}
}
@@ -77,7 +80,9 @@
if (res==null) return false;
if (!(res.getClass().equals(Boolean.class)))
throw new Exception("Bad object type");
-
+
+ //Log.notice("Selectors =>"+res);
+
return ((Boolean)res).booleanValue();
} catch (Exception e) {