java.lang.Object
org.apache.commons.compress.harmony.unpack200.BandSet
Direct Known Subclasses:
AttrDefinitionBands, BcBands, ClassBands, CpBands, FileBands, IcBands, NewAttributeBands

public abstract class BandSet extends Object
Abstract superclass for a set of bands.
  • Field Details

  • Constructor Details

    • BandSet

      public BandSet(Segment segment)
      Constructs a new instance for the given segment.
      Parameters:
      segment - The segment.
  • Method Details

    • decodeBandInt

      public int[] decodeBandInt(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Decodes a band and return an array of int values.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the InputStream to decode.
      codec - the default Codec for this band.
      count - the number of elements to read.
      Returns:
      an array of decoded int values.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • decodeBandInt

      public int[][] decodeBandInt(String name, InputStream in, BHSDCodec defaultCodec, int[] counts) throws IOException, Pack200Exception
      Decodes a band and return an array of int[] values.
      Parameters:
      name - the name of the band (primarily for logging/debugging purposes)
      in - the InputStream to decode from
      defaultCodec - the default codec for this band
      counts - the numbers of elements to read for each int array within the array to be returned
      Returns:
      an array of decoded int[] values
      Throws:
      IOException - if there is a problem reading from the underlying input stream
      Pack200Exception - if there is a problem decoding the value or that the value is invalid
    • getReferences

      protected String[] getReferences(int[] ints, String[] reference)
      Gets a new array of String references for the subset defined by the given ints array.
      Parameters:
      ints - The indices into the reference array.
      reference - The source array.
      Returns:
      a new array.
    • getReferences

      protected String[][] getReferences(int[][] ints, String[] reference)
      Gets a new array of String references for the subset defined by the given ints array.
      Parameters:
      ints - The indices into the reference array.
      reference - The source array.
      Returns:
      a new array.
    • parseCPClassReferences

      public CPClass[] parseCPClassReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPClass.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPClass.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPDescriptorReferences

      Parses an input stream into an array of CPNameAndType.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPNameAndType.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPDoubleReferences

      public CPDouble[] parseCPDoubleReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPDouble.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPDouble.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPFieldRefReferences

      Parses an input stream into an array of CPFieldRef.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPFieldRef.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPFloatReferences

      public CPFloat[] parseCPFloatReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPFloat.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPFloat.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPInterfaceMethodRefReferences

      Parses an input stream into an array of CPInterfaceMethodRef.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPInterfaceMethodRef.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPIntReferences

      public CPInteger[] parseCPIntReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPInteger.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPInteger.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPLongReferences

      public CPLong[] parseCPLongReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPLong.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPLong.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPMethodRefReferences

      Parses an input stream into an array of CPMethodRef.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPMethodRef.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPSignatureReferences

      public CPUTF8[] parseCPSignatureReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPUTF8.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPUTF8.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPSignatureReferences

      protected CPUTF8[][] parseCPSignatureReferences(String name, InputStream in, BHSDCodec codec, int[] counts) throws IOException, Pack200Exception
      Parses an input stream into an array of array of CPUTF8.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      counts - the number of elements to read.
      Returns:
      an array of array of decoded CPUTF8.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPStringReferences

      public CPString[] parseCPStringReferences(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPString.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPString.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPUTF8References

      public CPUTF8[] parseCPUTF8References(String name, InputStream in, BHSDCodec codec, int count) throws IOException, Pack200Exception
      Parses an input stream into an array of CPUTF8.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      count - the number of elements to read.
      Returns:
      an array of decoded CPUTF8.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseCPUTF8References

      public CPUTF8[][] parseCPUTF8References(String name, InputStream in, BHSDCodec codec, int[] counts) throws IOException, Pack200Exception
      Parses an input stream into an array of array of CPUTF8.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to parse.
      codec - the default BHSDCodec for this band
      counts - the number of elements to read.
      Returns:
      an array of array of decoded CPUTF8.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseFlags

      public long[] parseFlags(String name, InputStream in, int count, BHSDCodec hiCodec, BHSDCodec loCodec) throws IOException, Pack200Exception
      Parses an input stream into an array of flags.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the InputStream to decode.
      count - the number of elements to read.
      hiCodec - an optional codec if the high flag is on.
      loCodec - the codec.
      Returns:
      an array of decoded long flags.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseFlags

      public long[] parseFlags(String name, InputStream in, int count, BHSDCodec codec, boolean hasHi) throws IOException, Pack200Exception
      Parses an input stream into an array of flags.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the InputStream to decode.
      count - the number of elements to read.
      codec - the codec.
      hasHi - whether to the high flag is enabled.
      Returns:
      an array of decoded long flags.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseFlags

      public long[][] parseFlags(String name, InputStream in, int[] counts, BHSDCodec hiCodec, BHSDCodec loCodec) throws IOException, Pack200Exception
      Parses an input stream into an array of flags.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the InputStream to decode.
      counts - the number of elements to read.
      hiCodec - an optional codec if the high flag is on.
      loCodec - the codec.
      Returns:
      an array of decoded long flags.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseFlags

      public long[][] parseFlags(String name, InputStream in, int[] counts, BHSDCodec codec, boolean hasHi) throws IOException, Pack200Exception
      Parses an input stream into an array of flags.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the InputStream to decode.
      counts - the number of elements to read.
      codec - the codec.
      hasHi - whether the high flag is enabnled.
      Returns:
      an array of decoded long flags.
      Throws:
      IOException - if there is a problem reading from the underlying input stream.
      Pack200Exception - if there is a problem decoding the value or that the value is invalid.
    • parseReferences

      public String[] parseReferences(String name, InputStream in, BHSDCodec codec, int count, String[] reference) throws IOException, Pack200Exception
      Parses count references from in, using codec to decode the values as indexes into reference (which is populated prior to this call). An exception is thrown if a decoded index falls outside the range [0..reference.length-1].
      Parameters:
      name - the band name
      in - the input stream to read from
      codec - the BHSDCodec to use for decoding
      count - the number of references to decode
      reference - the array of values to use for the references
      Returns:
      Parsed references.
      Throws:
      IOException - if a problem occurs during reading from the underlying stream.
      Pack200Exception - if a problem occurs with an unexpected value or unsupported Codec.
    • parseReferences

      public String[][] parseReferences(String name, InputStream in, BHSDCodec codec, int[] counts, String[] reference) throws IOException, Pack200Exception
      Parses count references from in, using codec to decode the values as indexes into reference (which is populated prior to this call). An exception is thrown if a decoded index falls outside the range [0..reference.length-1]. Unlike the other parseReferences, this post-processes the result into an array of results.
      Parameters:
      name - the name of the band (for logging and debugging).
      in - the input stream to read from.
      codec - the BHSDCodec to use for decoding.
      counts - the numbers of references to decode for each array entry.
      reference - the array of values to use for the references.
      Returns:
      Parsed references.
      Throws:
      IOException - if a problem occurs during reading from the underlying stream.
      Pack200Exception - if a problem occurs with an unexpected value or unsupported Codec.
    • read

      public abstract void read(InputStream inputStream) throws IOException, Pack200Exception
      Reads the input stream.
      Parameters:
      inputStream - the stream to read.
      Throws:
      IOException - if a problem occurs during reading from the underlying stream.
      Pack200Exception - if a problem occurs with an unexpected value or unsupported Codec.
    • unpack

      public abstract void unpack() throws IOException, Pack200Exception
      Unpacks this instance.
      Throws:
      IOException - if a problem occurs during reading from the underlying stream.
      Pack200Exception - if a problem occurs with an unexpected value or unsupported Codec.
    • unpack

      public void unpack(InputStream in) throws IOException, Pack200Exception
      Unpacks the input stream.
      Parameters:
      in - the stream to unpack.
      Throws:
      IOException - if a problem occurs during reading from the underlying stream.
      Pack200Exception - if a problem occurs with an unexpected value or unsupported Codec.