View Javadoc
1   /*
2   Copyright (c) 2008 Health Market Science, Inc.
3   
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7   
8       http://www.apache.org/licenses/LICENSE-2.0
9   
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15  */
16  
17  package com.healthmarketscience.jackcess.impl;
18  
19  
20  /**
21   * Various constants used for creating index entries.
22   *
23   * @author James Ahlborn
24   */
25  public class IndexCodes {
26  
27    static final byte ASC_START_FLAG = (byte)0x7F;
28    static final byte ASC_NULL_FLAG = (byte)0x00;
29    static final byte DESC_START_FLAG = (byte)0x80;
30    static final byte DESC_NULL_FLAG = (byte)0xFF;
31  
32    static final byte ASC_BOOLEAN_TRUE = (byte)0x00;
33    static final byte ASC_BOOLEAN_FALSE = (byte)0xFF;
34    
35    static final byte DESC_BOOLEAN_TRUE = ASC_BOOLEAN_FALSE;
36    static final byte DESC_BOOLEAN_FALSE = ASC_BOOLEAN_TRUE;
37  
38  
39    static boolean isNullEntry(byte startEntryFlag) {
40      return((startEntryFlag == ASC_NULL_FLAG) ||
41             (startEntryFlag == DESC_NULL_FLAG));
42    }
43    
44    static byte getNullEntryFlag(boolean isAscending) {
45      return(isAscending ? ASC_NULL_FLAG : DESC_NULL_FLAG);
46    }
47    
48    static byte getStartEntryFlag(boolean isAscending) {
49      return(isAscending ? ASC_START_FLAG : DESC_START_FLAG);
50    }
51    
52  }