KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > server > sessionsystem > sessioncondition > StaticConditionHelper


1 package com.daffodilwoods.daffodildb.server.sessionsystem.sessioncondition;
2
3 import com.daffodilwoods.database.resource.DException;
4 import com.daffodilwoods.daffodildb.utils.comparator.CTbnfUzqfDpnqbsbups;
5 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
6 import com.daffodilwoods.daffodildb.utils.comparator.SuperComparator;
7
8 /**
9  *
10  * <p>Description: Helps sessioncondition classes for evaluating their conditions. </p>
11  * <p>Company: Daffodil Software Ltd. </p>
12  * @version 1.0
13  */

14 public class StaticConditionHelper extends Exception JavaDoc {
15
16     static SuperComparator comparator = new CTbnfUzqfDpnqbsbups();
17
18     /**
19      * Converts object[] to an 2D-array of bytes.
20      * @param con
21      * @return byte[][]
22      * @throws DException
23      */

24
25     /**
26      * Find matchValue in array and returns true if the value is found otherwise false.
27      * @param array
28      * @param matchValue
29      * @return boolean
30      * @throws DException
31      */

32     public static boolean solveInConditon(byte [][] array , byte[] matchValue) throws DException{
33         for(int i = 0 ; i < array.length ; i++)
34             if(comparator.compare(matchValue,array[i]) == 0)
35                return true;
36         return false;
37    }
38
39    public static boolean solveInConditon(Object JavaDoc[] array , FieldBase matchValue) throws DException{
40        for(int i = 0 ; i < array.length ; i++)
41            if(comparator.compare(matchValue,(FieldBase)array[i]) == 0)
42               return true;
43        return false;
44   }
45
46    /**
47     * compares two byte array and returns 0 if both are equal, -1 if value2 is greater than value1 otherwise 1.
48     * @param value1
49     * @param value2
50     * @return
51     * @throws DException
52     */

53    public static int compare( byte[] value1 , byte[] value2 ) throws DException{
54        return comparator.compare(value1 , value2 ) ;
55    }
56
57    public static int compare(Object JavaDoc value1 , Object JavaDoc value2 ) throws DException{
58        return comparator.compare(value1 , value2 ) ;
59    }
60
61 }
62
Popular Tags