1 19 20 package jxl.read.biff; 21 22 import jxl.biff.Type; 23 import jxl.biff.RecordData; 24 import jxl.biff.StringHelper; 25 26 29 public class SortRecord extends RecordData 30 { 31 private int col1Size; 32 private int col2Size; 33 private int col3Size; 34 private String col1Name; 35 private String col2Name; 36 private String col3Name; 37 private byte optionFlags; 38 private boolean sortColumns = false; 39 private boolean sortKey1Desc = false; 40 private boolean sortKey2Desc = false; 41 private boolean sortKey3Desc = false; 42 private boolean sortCaseSensitive = false; 43 48 public SortRecord(Record r) 49 { 50 super(Type.SORT); 51 52 byte[] data = r.getData(); 53 54 optionFlags = data[0]; 55 56 sortColumns = ((optionFlags & 0x01) != 0); 57 sortKey1Desc = ((optionFlags & 0x02) != 0); 58 sortKey2Desc = ((optionFlags & 0x04) != 0); 59 sortKey3Desc = ((optionFlags & 0x08) != 0); 60 sortCaseSensitive = ((optionFlags & 0x10) != 0); 61 62 64 col1Size = data[2]; 65 col2Size = data[3]; 66 col3Size = data[4]; 67 int curPos = 5; 68 if (data[curPos++] == 0x00) 69 { 70 col1Name = new String (data, curPos, col1Size); 71 curPos += col1Size; 72 } 73 else 74 { 75 col1Name = StringHelper.getUnicodeString(data, col1Size, curPos); 76 curPos += col1Size * 2; 77 } 78 79 if (col2Size > 0) 80 { 81 if (data[curPos++] == 0x00) 82 { 83 col2Name = new String (data, curPos, col2Size); 84 curPos += col2Size; 85 } 86 else 87 { 88 col2Name = StringHelper.getUnicodeString(data, col2Size, curPos); 89 curPos += col2Size * 2; 90 } 91 } 92 else 93 { 94 col2Name = ""; 95 } 96 if (col3Size > 0) 97 { 98 if (data[curPos++] == 0x00) 99 { 100 col3Name = new String (data, curPos, col3Size); 101 curPos += col3Size; 102 } 103 else 104 { 105 col3Name = StringHelper.getUnicodeString(data, col3Size, curPos); 106 curPos += col3Size * 2; 107 } 108 } 109 else 110 { 111 col3Name = ""; 112 } 113 } 114 115 120 public String getSortCol1Name() { 121 return col1Name; 122 } 123 128 public String getSortCol2Name() { 129 return col2Name; 130 } 131 136 public String getSortCol3Name() { 137 return col3Name; 138 } 139 144 public boolean getSortColumns() { 145 return sortColumns; 146 } 147 152 public boolean getSortKey1Desc() { 153 return sortKey1Desc; 154 } 155 160 public boolean getSortKey2Desc() { 161 return sortKey2Desc; 162 } 163 168 public boolean getSortKey3Desc() { 169 return sortKey3Desc; 170 } 171 176 public boolean getSortCaseSensitive() { 177 return sortCaseSensitive; 178 } 179 } 180 | Popular Tags |