| 1 | |
package org.paneris.bibliomania.fti; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import java.io.OutputStream; |
| 5 | |
|
| 6 | |
public class ThreePacker extends Packer { |
| 7 | 1 | public static final ThreePacker it = new ThreePacker(); |
| 8 | |
|
| 9 | |
public ThreePacker() { |
| 10 | 1 | super(3, 0xFFFFFF); |
| 11 | 1 | } |
| 12 | |
|
| 13 | |
public static int number_(byte[] bytes, int off) { |
| 14 | 311 | return uint(bytes[off + 0]) << 16 | uint(bytes[off + 1]) << 8 | |
| 15 | |
uint(bytes[off + 2]); |
| 16 | |
} |
| 17 | |
|
| 18 | |
public int number(byte[] bytes, int off) { |
| 19 | 0 | return number_(bytes, off); |
| 20 | |
} |
| 21 | |
|
| 22 | |
public Packer bigger() { |
| 23 | 0 | return FourPacker.it; |
| 24 | |
} |
| 25 | |
|
| 26 | |
public static void write_(OutputStream os, int number) throws IOException { |
| 27 | 0 | os.write(number >> 16); |
| 28 | 0 | os.write(number >> 8); |
| 29 | 0 | os.write(number ); |
| 30 | 0 | } |
| 31 | |
|
| 32 | |
public void write(OutputStream os, int number) throws IOException { |
| 33 | 0 | write_(os, number); |
| 34 | 0 | } |
| 35 | |
|
| 36 | |
public static void set_(byte[] bytes, int offset, int number) { |
| 37 | 579 | bytes[offset ] = (byte)(number >> 16); |
| 38 | 579 | bytes[offset + 1] = (byte)(number >> 8); |
| 39 | 579 | bytes[offset + 2] = (byte) number ; |
| 40 | 579 | } |
| 41 | |
|
| 42 | |
public void set(byte[] bytes, int offset, int number) { |
| 43 | 0 | set_(bytes, offset, number); |
| 44 | 0 | } |
| 45 | |
} |