| java.lang.Object org.apache.harmony.pack200.Segment
Segment | public class Segment (Code) | | A Pack200 archive consists of one (or more) segments. Each segment is
standalone, in the sense that every segment has the magic number header;
thus, every segment is also a valid archive. However, it is possible to
combine (non-GZipped) archives into a single large archive by concatenation
alone. Thus all the hard work in unpacking an archive falls to understanding
a segment.
This class implements the Pack200 specification by an entry point (
Segment.parse(InputStream) )
which in turn delegates to a variety of other parse methods. Each parse
method corresponds (roughly) to the name of the bands in the Pack200
specification.
The first component of a segment is the header; this contains (amongst other
things) the expected counts of constant pool entries, which in turn defines
how many values need to be read from the stream. Because values are variable
width (see
Codec ), it is not possible to calculate the start of the
next segment, although one of the header values does hint at the size of the
segment if non-zero, which can be used for buffering purposes.
Note that this does not perform any buffering of the input stream; each value
will be read on a byte-by-byte basis. It does not perform GZip decompression
automatically; both of these are expected to be done by the caller if the
stream has the magic header for GZip streams (
GZIPInputStream.GZIP_MAGIC ).
In any case, if GZip decompression is being performed the input stream will
be buffered at a higher level, and thus this can read on a byte-oriented
basis.
|
debug | protected void debug(String message)(Code) | | This is a local debugging message to aid the developer in writing this
class. It will be removed before going into production. If the property
'debug.pack200' is set, this will generate messages to stderr; otherwise,
it will be silent.
Parameters: message - |
overrideDeflateHint | public void overrideDeflateHint(boolean deflateHint)(Code) | | Override the archive's deflate hint with the given boolean
Parameters: deflateHint - - the deflate hint to use |
parse | public static Segment parse(InputStream in) throws IOException, Pack200Exception(Code) | | TODO: Do we need this method now we have Archive as the main entry point?
Decode a segment from the given input stream. This does not attempt to
re-assemble or export any class files, but it contains enough information
to be able to re-assemble class files by external callers.
Parameters: in - the input stream to read from a segment parsed from the input stream throws: IOException - if a problem occurs during reading from the underlying stream throws: Pack200Exception - if a problem occurs with an unexpected value or unsupportedcodec |
setLogLevel | public void setLogLevel(int logLevel)(Code) | | |
writeJar | public void writeJar(JarOutputStream out) throws IOException, Pack200Exception(Code) | | Writes the segment to an output stream. The output stream should be
pre-buffered for efficiency. Also takes the same input stream for
reading, since the file bits may not be loaded and thus just copied from
one stream to another. Doesn't close the output stream when finished, in
case there are more entries (e.g. further segments) to be written.
Parameters: out - the JarOutputStream to write data to Parameters: in - the same InputStream that was used to parse the segment throws: IOException - if an error occurs whilst reading or writing to the streams throws: Pack200Exception - if an error occurs whilst unpacking data |
|
|