| 1 | |
package org.paneris.bibliomania.fti; |
| 2 | |
|
| 3 | |
import java.io.IOException; |
| 4 | |
import java.io.OutputStream; |
| 5 | |
|
| 6 | |
|
| 7 | |
|
| 8 | |
|
| 9 | |
|
| 10 | |
|
| 11 | |
|
| 12 | |
public abstract class Packer { |
| 13 | |
|
| 14 | |
|
| 15 | |
public static int uint(byte b) { |
| 16 | 949 | return b >= 0 ? b : 256 + b; |
| 17 | |
} |
| 18 | |
|
| 19 | |
private int numberLength; |
| 20 | |
private int numberMax; |
| 21 | |
|
| 22 | |
|
| 23 | |
|
| 24 | |
|
| 25 | |
|
| 26 | |
|
| 27 | 4 | protected Packer(int numberLength, int numberMax) { |
| 28 | 4 | this.numberLength = numberLength; |
| 29 | 4 | this.numberMax = numberMax; |
| 30 | 4 | } |
| 31 | |
|
| 32 | |
public final int numberLength() { |
| 33 | 0 | return numberLength; |
| 34 | |
} |
| 35 | |
|
| 36 | |
public final int numberMax() { |
| 37 | 684 | return numberMax; |
| 38 | |
} |
| 39 | |
|
| 40 | |
public abstract int number(byte[] bytes, int off); |
| 41 | |
|
| 42 | |
public abstract Packer bigger(); |
| 43 | |
|
| 44 | |
public abstract void write(OutputStream os, int number) throws IOException; |
| 45 | |
} |