Class BandSet
- 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 java.lang.Object
Abstract superclass for a set of bands.
-
-
Field Summary
Fields Modifier and Type Field Description protected SegmentHeaderheaderSegment header.protected SegmentsegmentSegment.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int[]decodeBandInt(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Decodes a band and return an array ofintvalues.int[][]decodeBandInt(java.lang.String name, java.io.InputStream in, BHSDCodec defaultCodec, int[] counts)Decodes a band and return an array ofint[]values.protected java.lang.String[][]getReferences(int[][] ints, java.lang.String[] reference)Gets a new array of String references for the subset defined by the givenintsarray.protected java.lang.String[]getReferences(int[] ints, java.lang.String[] reference)Gets a new array of String references for the subset defined by the givenintsarray.CPClass[]parseCPClassReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPClass.CPNameAndType[]parseCPDescriptorReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPNameAndType.CPDouble[]parseCPDoubleReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPDouble.CPFieldRef[]parseCPFieldRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPFieldRef.CPFloat[]parseCPFloatReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPFloat.CPInterfaceMethodRef[]parseCPInterfaceMethodRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPInterfaceMethodRef.CPInteger[]parseCPIntReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPInteger.CPLong[]parseCPLongReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPLong.CPMethodRef[]parseCPMethodRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPMethodRef.CPUTF8[]parseCPSignatureReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPUTF8.protected CPUTF8[][]parseCPSignatureReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts)Parses an input stream into an array of array ofCPUTF8.CPString[]parseCPStringReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPString.CPUTF8[]parseCPUTF8References(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count)Parses an input stream into an array ofCPUTF8.CPUTF8[][]parseCPUTF8References(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts)Parses an input stream into an array of array ofCPUTF8.long[][]parseFlags(java.lang.String name, java.io.InputStream in, int[] counts, BHSDCodec codec, boolean hasHi)Parses an input stream into an array of flags.long[][]parseFlags(java.lang.String name, java.io.InputStream in, int[] counts, BHSDCodec hiCodec, BHSDCodec loCodec)Parses an input stream into an array of flags.long[]parseFlags(java.lang.String name, java.io.InputStream in, int count, BHSDCodec codec, boolean hasHi)Parses an input stream into an array of flags.long[]parseFlags(java.lang.String name, java.io.InputStream in, int count, BHSDCodec hiCodec, BHSDCodec loCodec)Parses an input stream into an array of flags.java.lang.String[][]parseReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts, java.lang.String[] reference)Parses count references fromin, usingcodecto decode the values as indexes intoreference(which is populated prior to this call).java.lang.String[]parseReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count, java.lang.String[] reference)Parses count references fromin, usingcodecto decode the values as indexes intoreference(which is populated prior to this call).abstract voidread(java.io.InputStream inputStream)Reads the input stream.abstract voidunpack()Unpacks this instance.voidunpack(java.io.InputStream in)Unpacks the input stream.
-
-
-
Field Detail
-
header
protected SegmentHeader header
Segment header.
-
-
Method Detail
-
decodeBandInt
public int[] decodeBandInt(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Decodes a band and return an array ofintvalues.- 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
intvalues. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec defaultCodec, int[] counts) throws java.io.IOException, Pack200Exception
Decodes a band and return an array ofint[]values.- Parameters:
name- the name of the band (primarily for logging/debugging purposes)in- the InputStream to decode fromdefaultCodec- the default codec for this bandcounts- the numbers of elements to read for each int array within the array to be returned- Returns:
- an array of decoded
int[]values - Throws:
java.io.IOException- if there is a problem reading from the underlying input streamPack200Exception- if there is a problem decoding the value or that the value is invalid
-
getReferences
protected java.lang.String[] getReferences(int[] ints, java.lang.String[] reference)
Gets a new array of String references for the subset defined by the givenintsarray.- Parameters:
ints- The indices into thereferencearray.reference- The source array.- Returns:
- a new array.
-
getReferences
protected java.lang.String[][] getReferences(int[][] ints, java.lang.String[] reference)
Gets a new array of String references for the subset defined by the givenintsarray.- Parameters:
ints- The indices into thereferencearray.reference- The source array.- Returns:
- a new array.
-
parseCPClassReferences
public CPClass[] parseCPClassReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPClass.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPClass. - Throws:
java.io.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
public CPNameAndType[] parseCPDescriptorReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPNameAndType.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPNameAndType. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPDouble.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPDouble. - Throws:
java.io.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
public CPFieldRef[] parseCPFieldRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPFieldRef.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPFieldRef. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPFloat.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPFloat. - Throws:
java.io.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
public CPInterfaceMethodRef[] parseCPInterfaceMethodRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPInterfaceMethodRef.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPInterfaceMethodRef. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPInteger.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPInteger. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPLong.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPLong. - Throws:
java.io.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
public CPMethodRef[] parseCPMethodRefReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPMethodRef.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPMethodRef. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPUTF8.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPUTF8. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts) throws java.io.IOException, Pack200Exception
Parses an input stream into an array of array ofCPUTF8.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcounts- the number of elements to read.- Returns:
- an array of array of decoded
CPUTF8. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPString.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPString. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count) throws java.io.IOException, Pack200Exception
Parses an input stream into an array ofCPUTF8.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcount- the number of elements to read.- Returns:
- an array of decoded
CPUTF8. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts) throws java.io.IOException, Pack200Exception
Parses an input stream into an array of array ofCPUTF8.- Parameters:
name- the name of the band (for logging and debugging).in- the input stream to parse.codec- the defaultBHSDCodecfor this bandcounts- the number of elements to read.- Returns:
- an array of array of decoded
CPUTF8. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, int count, BHSDCodec hiCodec, BHSDCodec loCodec) throws java.io.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
longflags. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, int count, BHSDCodec codec, boolean hasHi) throws java.io.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
longflags. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, int[] counts, BHSDCodec hiCodec, BHSDCodec loCodec) throws java.io.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
longflags. - Throws:
java.io.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(java.lang.String name, java.io.InputStream in, int[] counts, BHSDCodec codec, boolean hasHi) throws java.io.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
longflags. - Throws:
java.io.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 java.lang.String[] parseReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int count, java.lang.String[] reference) throws java.io.IOException, Pack200Exception
Parses count references fromin, usingcodecto decode the values as indexes intoreference(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 namein- the input stream to read fromcodec- the BHSDCodec to use for decodingcount- the number of references to decodereference- the array of values to use for the references- Returns:
- Parsed references.
- Throws:
java.io.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 java.lang.String[][] parseReferences(java.lang.String name, java.io.InputStream in, BHSDCodec codec, int[] counts, java.lang.String[] reference) throws java.io.IOException, Pack200Exception
Parses count references fromin, usingcodecto decode the values as indexes intoreference(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:
java.io.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(java.io.InputStream inputStream) throws java.io.IOException, Pack200Exception
Reads the input stream.- Parameters:
inputStream- the stream to read.- Throws:
java.io.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 java.io.IOException, Pack200Exception
Unpacks this instance.- Throws:
java.io.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(java.io.InputStream in) throws java.io.IOException, Pack200Exception
Unpacks the input stream.- Parameters:
in- the stream to unpack.- Throws:
java.io.IOException- if a problem occurs during reading from the underlying stream.Pack200Exception- if a problem occurs with an unexpected value or unsupported Codec.
-
-