1 | |
package org.paneris.bibliomania.fti; |
2 | |
|
3 | |
import java.io.IOException; |
4 | |
import java.io.OutputStream; |
5 | |
|
6 | |
public class TwoPacker extends Packer { |
7 | 1 | public static final TwoPacker it = new TwoPacker(); |
8 | |
|
9 | |
public TwoPacker() { |
10 | 1 | super(2, 0xFFFF); |
11 | 1 | } |
12 | |
|
13 | |
public static int number_(byte[] bytes, int off) { |
14 | 0 | return uint(bytes[off]) << 8 | uint(bytes[off + 1]); |
15 | |
} |
16 | |
|
17 | |
public int number(byte[] bytes, int off) { |
18 | 0 | return number_(bytes, off); |
19 | |
} |
20 | |
|
21 | |
public Packer bigger() { |
22 | 0 | return ThreePacker.it; |
23 | |
} |
24 | |
|
25 | |
public static void write_(OutputStream os, int number) throws IOException { |
26 | 179 | os.write(number >> 8); |
27 | 179 | os.write(number ); |
28 | 179 | } |
29 | |
|
30 | |
public void write(OutputStream os, int number) throws IOException { |
31 | 179 | write_(os, number); |
32 | 179 | } |
33 | |
} |