Package org.apache.commons.compress.harmony.pack200

# Class BandSet

java.lang.Object
org.apache.commons.compress.harmony.pack200.BandSet

Direct Known Subclasses:
  `AttributeDefinitionBands`, `BcBands`, `ClassBands`, `CpBands`, `FileBands`, `IcBands`, `MetadataBandGroup`, `NewAttributeBands`, `SegmentHeader`

public abstract class BandSet extends Object
Abstract superclass for a set of bands

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `class`
  `BandSet.BandAnalysisResults`
  Results obtained by trying different Codecs to encode a band
  `class`
  `BandSet.BandData`
  BandData represents information about a band, for example largest value etc and is used in the heuristics that calculate whether an alternative Codec could make the encoded band smaller.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected final SegmentHeader`
  `segmentHeader`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BandSet(int effort, SegmentHeader header)`
  Constructs a new BandSet.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `protected int[]`
  `cpEntryListToArray(List<? extends ConstantPoolEntry> list)`
  Converts a list of ConstantPoolEntrys to an int[] array of their indices
  `protected int[]`
  `cpEntryOrNullListToArray(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(String name, int[] ints, BHSDCodec defaultCodec)`
  Encode a band of integers.
  `protected byte[]`
  `encodeFlags(String name, long[][] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags)`
  `protected byte[]`
  `encodeFlags(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 bands
  `byte[]`
  `encodeScalar(int[] band, BHSDCodec codec)`
  Encode a band without considering other Codecs.
  `byte[]`
  `encodeScalar(int value, BHSDCodec codec)`
  Encodes a single value with the given Codec.
  `protected int[]`
  `integerListToArray(List<Integer> integerList)`
  Converts a list of Integers to an int[] array.
  `protected long[]`
  `longListToArray(List<Long> longList)`
  Converts a list of Longs to an long[] array.
  `abstract void`
  `pack(OutputStream out)`
  Writes the packed set of bands to the given output stream.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### segmentHeader

    protected final SegmentHeader segmentHeader

- ## Constructor Details

  - ### 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 Details

  - ### cpEntryListToArray

    protected int[] cpEntryListToArray(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(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(String name, int[] ints, BHSDCodec defaultCodec) throws Pack200Exception
    Encode 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 band
      `defaultCodec` - the default Codec
    Returns:
      the encoded band
    Throws:
      `Pack200Exception` - If a Pack200 semantic error occurs.

  - ### encodeFlags

    protected byte[] encodeFlags(String name, long[] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags) throws Pack200Exception
    Encode 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 band
      `loCodec` - Codec for the low 32-bits band
      `hiCodec` - Codec for the high 32-bits band
      `haveHiFlags` - ignores the high band if true as all values would be zero
    Returns:
      the encoded band
    Throws:
      `Pack200Exception` - If a Pack200 semantic error occurs.

  - ### encodeFlags

    protected byte[] encodeFlags(String name, long[][] flags, BHSDCodec loCodec, BHSDCodec hiCodec, boolean haveHiFlags) throws Pack200Exception
    Throws:
      `Pack200Exception`

  - ### encodeScalar

    public byte[] encodeScalar(int value, BHSDCodec codec) throws Pack200Exception
    Encodes a single value with the given Codec.
    Parameters:
      `value` - the value to encode.
      `codec` - Codec to use.
    Returns:
      the encoded value.
    Throws:
      `Pack200Exception` - If a Pack200 semantic error occurs.

  - ### encodeScalar

    public byte[] encodeScalar(int[] band, BHSDCodec codec) throws Pack200Exception
    Encode a band without considering other Codecs.
    Parameters:
      `band` - the band.
      `codec` - the Codec to use.
    Returns:
      the encoded band.
    Throws:
      `Pack200Exception` - If a Pack200 semantic error occurs.

  - ### integerListToArray

    protected int[] integerListToArray(List<Integer> integerList)
    Converts a list of Integers to an int[] array.
    Parameters:
      `integerList` - conversion source.
    Returns:
      conversion result.

  - ### longListToArray

    protected long[] longListToArray(List<Long> longList)
    Converts a list of Longs to an long[] array.
    Parameters:
      `longList` - conversion source.
    Returns:
      conversion result.

  - ### pack

    public abstract void pack(OutputStream out) throws IOException, Pack200Exception
    Writes the packed set of bands to the given output stream.
    Parameters:
      `out` - TODO
    Throws:
      `IOException` - If an I/O error occurs.
      `Pack200Exception` - If a Pack200 semantic error occurs.