- java.lang.Object
-
- kala.compress.harmony.pack200.BandSet
-
- Direct Known Subclasses:
AttributeDefinitionBands,BcBands,ClassBands,CpBands,FileBands,IcBands,MetadataBandGroup,NewAttributeBands,SegmentHeader
public abstract class BandSet extends java.lang.ObjectAbstract superclass for a set of bands
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classBandSet.BandAnalysisResultsResults obtained by trying different Codecs to encode a bandclassBandSet.BandDataBandData represents information about a band, e.g.
-
Field Summary
Fields Modifier and Type Field Description private long[]canonicalLargestprivate long[]canonicalSmallest(package private) inteffortprivate static int[]effortThresholdsprivate static byte[]EMPTY_BYTE_ARRAYprotected SegmentHeadersegmentHeader
-
Constructor Summary
Constructors Constructor Description BandSet(int effort, SegmentHeader header)Constructs a new BandSet.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private BandSet.BandAnalysisResultsanalyseBand(java.lang.String name, int[] band, BHSDCodec defaultCodec)protected int[]cpEntryListToArray(java.util.List<? extends ConstantPoolEntry> list)Converts a list of ConstantPoolEntrys to an int[] array of their indicesprotected int[]cpEntryOrNullListToArray(java.util.List<? extends ConstantPoolEntry> list)Converts a list of ConstantPoolEntrys or nulls to an int[] array of their indices +1 (or 0 for nulls)byte[]encodeBandInt(java.lang.String name, int[] ints, BHSDCodec defaultCodec)Encode a band of integers.protected byte[]encodeFlags(java.lang.String name, long[][] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags)protected byte[]encodeFlags(java.lang.String name, long[] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags)Encode a band of longs (values are split into their high and low 32 bits and then encoded as two separate bandsbyte[]encodeScalar(int[] band, BHSDCodec codec)Encode a band without considering other Codecsbyte[]encodeScalar(int value, BHSDCodec codec)Encode a single value with the given Codecprivate voidencodeWithPopulationCodec(int[] band, BHSDCodec defaultCodec, BandSet.BandData bandData, BandSet.BandAnalysisResults results)private long[]flatten(long[][] flags)protected int[]integerListToArray(java.util.List<java.lang.Integer> integerList)Converts a list of Integers to an int[] array.protected long[]longListToArray(java.util.List<java.lang.Long> longList)Converts a list of Longs to an long[] array.abstract voidpack(java.io.OutputStream out)Write the packed set of bands to the given output streamprivate booleantimeToStop(BandSet.BandAnalysisResults results)private voidtryCodecs(int[] band, BHSDCodec defaultCodec, BandSet.BandData bandData, BandSet.BandAnalysisResults results, byte[] encoded, BHSDCodec[] potentialCodecs)
-
-
-
Field Detail
-
EMPTY_BYTE_ARRAY
private static final byte[] EMPTY_BYTE_ARRAY
-
effortThresholds
private static final int[] effortThresholds
-
segmentHeader
protected final SegmentHeader segmentHeader
-
effort
final int effort
-
canonicalLargest
private long[] canonicalLargest
-
canonicalSmallest
private long[] canonicalSmallest
-
-
Constructor Detail
-
BandSet
public BandSet(int effort, SegmentHeader header)Constructs a new BandSet.- Parameters:
effort- the packing effort to be used (must be 1-9)header- the segment header
-
-
Method Detail
-
analyseBand
private BandSet.BandAnalysisResults analyseBand(java.lang.String name, int[] band, BHSDCodec defaultCodec) throws Pack200Exception
- Throws:
Pack200Exception
-
cpEntryListToArray
protected int[] cpEntryListToArray(java.util.List<? extends ConstantPoolEntry> list)
Converts a list of ConstantPoolEntrys to an int[] array of their indices- Parameters:
list- conversion source.- Returns:
- conversion result.
-
cpEntryOrNullListToArray
protected int[] cpEntryOrNullListToArray(java.util.List<? extends ConstantPoolEntry> list)
Converts a list of ConstantPoolEntrys or nulls to an int[] array of their indices +1 (or 0 for nulls)- Parameters:
list- conversion source.- Returns:
- conversion result.
-
encodeBandInt
public byte[] encodeBandInt(java.lang.String name, int[] ints, BHSDCodec defaultCodec) throws Pack200ExceptionEncode a band of integers. The default codec may be used, but other Codecs are considered if effort is greater than 1.- Parameters:
name- name of the band (used for debugging)ints- the banddefaultCodec- the default Codec- Returns:
- the encoded band
- Throws:
Pack200Exception- TODO
-
encodeFlags
protected byte[] encodeFlags(java.lang.String name, long[] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags) throws Pack200ExceptionEncode a band of longs (values are split into their high and low 32 bits and then encoded as two separate bands- Parameters:
name- name of the band (for debugging purposes)flags- the bandloCodec- Codec for the low 32-bits bandhiCodec- Codec for the high 32-bits bandhaveHiFlags- ignores the high band if true as all values would be zero- Returns:
- the encoded band
- Throws:
Pack200Exception- TODO
-
encodeFlags
protected byte[] encodeFlags(java.lang.String name, long[][] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags) throws Pack200Exception- Throws:
Pack200Exception
-
encodeScalar
public byte[] encodeScalar(int value, BHSDCodec codec) throws Pack200ExceptionEncode a single value with the given Codec- Parameters:
value- the value to encodecodec- Codec to use- Returns:
- the encoded value
- Throws:
Pack200Exception- TODO
-
encodeScalar
public byte[] encodeScalar(int[] band, BHSDCodec codec) throws Pack200ExceptionEncode a band without considering other Codecs- Parameters:
band- the bandcodec- the Codec to use- Returns:
- the encoded band
- Throws:
Pack200Exception- TODO
-
encodeWithPopulationCodec
private void encodeWithPopulationCodec(int[] band, BHSDCodec defaultCodec, BandSet.BandData bandData, BandSet.BandAnalysisResults results) throws Pack200Exception- Throws:
Pack200Exception
-
flatten
private long[] flatten(long[][] flags)
-
integerListToArray
protected int[] integerListToArray(java.util.List<java.lang.Integer> integerList)
Converts a list of Integers to an int[] array.- Parameters:
integerList- conversion source.- Returns:
- conversion result.
-
longListToArray
protected long[] longListToArray(java.util.List<java.lang.Long> longList)
Converts a list of Longs to an long[] array.- Parameters:
longList- conversion source.- Returns:
- conversion result.
-
pack
public abstract void pack(java.io.OutputStream out) throws java.io.IOException, Pack200ExceptionWrite the packed set of bands to the given output stream- Parameters:
out- TODO- Throws:
java.io.IOException- If an I/O error occurs.Pack200Exception- TODO
-
timeToStop
private boolean timeToStop(BandSet.BandAnalysisResults results)
-
tryCodecs
private void tryCodecs(int[] band, BHSDCodec defaultCodec, BandSet.BandData bandData, BandSet.BandAnalysisResults results, byte[] encoded, BHSDCodec[] potentialCodecs) throws Pack200Exception- Throws:
Pack200Exception
-
-