}
}
public void encodeSubstring(int offset, int length, Object context) {
try {
HuffmanEncoder encoder = (HuffmanEncoder)context;
if (length < 1 || length > 255) {
throw new IllegalArgumentException("Length " + length + " out of range [1,255]");
}
encoder.encodeSymbol(256 + length);
offset = -offset;
if (offset < 1 || offset > (2<<15)-1) {
throw new IllegalArgumentException("Offset " + offset + " out of range [1, 65535]");
}
encoder.encodeSymbol(offset & 0xf);
encoder.encodeSymbol((offset >> 4) & 0xf);
encoder.encodeSymbol((offset >> 8) & 0xf);
encoder.encodeSymbol((offset >> 12) & 0xf);
} catch (IOException e) {
throw new RuntimeException(e);
}
}