1 /*
2 Copyright 2007 Ramon Servadei
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 package fulmine.protocol.specification;
17
18 /**
19 * Holds a range of constants and byte masks.
20 *
21 * @author Ramon Servadei
22 */
23 public final class ByteConstants
24 {
25 /** The string encoding, UTF8 */
26 public static final String ENCODING = "UTF8";
27
28 /**
29 * Bit shifts to access the byte ordinal that the index represents. E.g.
30 * bitShiftForByteOrdinal[2] has a value of 8 which is the number of bits to
31 * right shift an integral to access the 2nd byte.
32 */
33 public static final long[] bitShiftForByteOrdinal = new long[9];
34 static
35 {
36 int i = 0;
37 // 0 doesn't count
38 bitShiftForByteOrdinal[i] = 0;
39 bitShiftForByteOrdinal[++i] = 8 * (i - 1); // 0
40 bitShiftForByteOrdinal[++i] = 8 * (i - 1); // 8
41 bitShiftForByteOrdinal[++i] = 8 * (i - 1); // 16
42 bitShiftForByteOrdinal[++i] = 8 * (i - 1);
43 bitShiftForByteOrdinal[++i] = 8 * (i - 1);
44 bitShiftForByteOrdinal[++i] = 8 * (i - 1);
45 bitShiftForByteOrdinal[++i] = 8 * (i - 1);
46 bitShiftForByteOrdinal[++i] = 8 * (i - 1);
47 }
48 }