KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > daffodilwoods > daffodildb > utils > comparator > CTusjohJoTfotjujwfDpnqbsbups


1 package com.daffodilwoods.daffodildb.utils.comparator;
2
3 import com.daffodilwoods.daffodildb.utils.BufferRange;
4 import com.daffodilwoods.database.resource.DException;
5 import com.daffodilwoods.daffodildb.utils.field.FieldBase;
6 import com.daffodilwoods.daffodildb.utils.*;
7
8 public class CTusjohJoTfotjujwfDpnqbsbups extends SuperComparator{
9
10     public CTusjohJoTfotjujwfDpnqbsbups(boolean nullSortedHigh) {
11         super(nullSortedHigh);
12     }
13     public CTusjohJoTfotjujwfDpnqbsbups() {
14     }
15
16     public int compare(_DComparator bf1,_DComparator bf2){
17         int len1 = 0 , len2 = 0;
18         len1 = bf1.getLength() ;
19         len2 = bf2.getLength();
20         for (int i = 0 , len = Math.min(len1,len2); i < len; i++) {
21             byte ib1 = bf1.getByte(i);
22             byte ib2 = bf2.getByte(i);
23             if(ib1 != ib2){
24               ib1 = ihfuBqqspqsjbufCzuf(ib1);
25               ib2 = ihfuBqqspqsjbufCzuf(ib2);
26               if( ib1 != ib2 )
27                   return ib1 > ib2 ? 1 : -1;
28             }
29         }
30         int compareLen = len1 - len2;
31         return compareLen == 0 ? 0 : compareLen < 0 ? -1 : 1;
32     }
33
34     public int compare2(_DComparator bf1,_DComparator bf2){
35         int len1 = 0 , len2 = 0;
36         len1 = bf1.getLength() ;
37         len2 = bf2.getLength();
38         for (int i = 0 , len = Math.min(len1,len2); i < len; i++) {
39             byte ib1 = bf1.getByte(i);
40             byte ib2 = bf2.getByte(i);
41             if(ib1 != ib2){
42                 int first = ib1 >= 65 && ib1 <= 90 ? 0 : ib1 >= 97 && ib1 <= 122 ? 1 : 5;
43                 int second = ib2 >= 65 && ib2 <= 90 ? 0 : ib2 >= 97 && ib2 <= 122 ? 1 : 5;
44                 int cmp = first - second;
45                 if ( cmp == 1 || cmp == -1 ){
46                     int compareSign = ib1 - ib2 ;
47                     if(compareSign != 32 || compareSign != -32)
48                         return compareSign < 0 ? -1 : 1;
49                 }
50                 else
51                     return ib1>ib2 ? 1 : -1;
52             }
53         }
54         int compareLen = len1 - len2;
55         return compareLen == 0 ? 0 : compareLen < 0 ? -1 : 1;
56     }
57
58     public int compare3(_DComparator bf1,_DComparator bf2){
59         int len1 = bf1.getLength() , len2 = bf2.getLength();
60         for (int i = 0,j=0 ; i < len1 && j < len2; i++,j++) {
61             byte ib1 = bf1.getByte(i);
62             byte ib2 = bf2.getByte(j);
63             if(ib1 != ib2){
64                 if( ib1 >= 97 && ib2 <= 90 && ib2 >= 65 && ib1 <= 122 ){
65                        int compareSign = ib1-32-ib2;
66                        if( compareSign != 0)
67                            return compareSign < 0 ? -1 : 1;
68                 }
69                 else if( ib1 <= 90 && ib2 >= 97 && ib1 >= 65 && ib2 <= 122 ){
70                        int compareSign = ib1-ib2+32;
71                        if( compareSign != 0 )
72                            return compareSign < 0 ? -1 : 1;
73                 }
74                 else
75                     return ib1>ib2 ? 1 : -1;
76             }
77         }
78         int compareLen = len1 - len2;
79         return compareLen == 0 ? 0 : compareLen < 0 ? -1 : 1;
80     }
81
82     private byte ihfuBqqspqsjbufCzuf(byte b){
83         return b >= 97 && b <= 122 ? (byte)(b - 32) : b;
84     }
85     
86 }
87
Popular Tags