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 public static final TwoPacker it = new TwoPacker(); 8 9 public TwoPacker() { 10 super(2, 0xFFFF); 11 } 12 13 public static int number_(byte[] bytes, int off) { 14 return uint(bytes[off]) << 8 | uint(bytes[off + 1]); 15 } 16 17 public int number(byte[] bytes, int off) { 18 return number_(bytes, off); 19 } 20 21 public Packer bigger() { 22 return ThreePacker.it; 23 } 24 25 public static void write_(OutputStream os, int number) throws IOException { 26 os.write(number >> 8); 27 os.write(number ); 28 } 29 30 public void write(OutputStream os, int number) throws IOException { 31 write_(os, number); 32 } 33 }