1 28 29 package com.caucho.db.sql; 30 31 import java.sql.SQLException ; 32 33 36 class StringOrder extends Order { 37 private int _column; 38 39 StringOrder(int column) 40 { 41 _column = column; 42 } 43 44 public int compare(SelectResult result, int indexA, int indexB) 45 throws SQLException 46 { 47 result.setRow(indexA); 48 49 String valueA = result.getString(_column); 50 51 result.setRow(indexB); 52 String valueB = result.getString(_column); 53 54 int sign = isAscending() ? 1 : -1; 55 56 if (valueA == valueB) 57 return _next == null ? 0 : _next.compare(result, indexA, indexB); 58 else if (valueA == null) 59 return sign; 60 else if (valueB == null) 61 return -sign; 62 63 int cmp = valueA.compareTo(valueB); 64 if (cmp == 0) 65 return _next == null ? 0 : _next.compare(result, indexA, indexB); 66 else 67 return cmp; 68 } 69 } 70 | Popular Tags |