| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
package org.tukaani.xz; |
| 6 |
|
| 7 |
class BCJEncoder extends BCJCoder implements FilterEncoder { |
| 8 |
private final BCJOptions options; |
| 9 |
private final long filterID; |
| 10 |
private final byte[] props; |
| 11 |
|
| 12 |
BCJEncoder(BCJOptions options, long filterID) { |
| 13 |
assert isBCJFilterID(filterID); |
| 14 |
int startOffset = options.getStartOffset(); |
| 15 |
|
| 16 |
if (startOffset == 0) { |
| 17 |
props = new byte[0]; |
| 18 |
} else { |
| 19 |
props = new byte[4]; |
| 20 |
for (int i = 0; i < 4; ++i) |
| 21 |
props[i] = (byte)(startOffset >>> (i * 8)); |
| 22 |
} |
| 23 |
|
| 24 |
this.filterID = filterID; |
| 25 |
this.options = (BCJOptions)options.clone(); |
| 26 |
} |
| 27 |
|
| 28 |
@Override |
| 29 |
public long getFilterID() { |
| 30 |
return filterID; |
| 31 |
} |
| 32 |
|
| 33 |
@Override |
| 34 |
public byte[] getFilterProps() { |
| 35 |
return props; |
| 36 |
} |
| 37 |
|
| 38 |
@Override |
| 39 |
public boolean supportsFlushing() { |
| 40 |
return false; |
| 41 |
} |
| 42 |
|
| 43 |
@Override |
| 44 |
public FinishableOutputStream getOutputStream(FinishableOutputStream out, |
| 45 |
ArrayCache arrayCache) { |
| 46 |
return options.getOutputStream(out, arrayCache); |
| 47 |
} |
| 48 |
} |