This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git
The following commit(s) were added to refs/heads/master by this push:
new 4269e250d Javadoc
4269e250d is described below
commit 4269e250df0318e9517ac0616306b279bc5871b7
Author: Gary Gregory <[email protected]>
AuthorDate: Mon Feb 10 09:07:25 2025 -0500
Javadoc
---
.../commons/compress/harmony/pack200/Segment.java | 17 ++++
.../compress/harmony/unpack200/BcBands.java | 9 ++-
.../compress/harmony/unpack200/Segment.java | 94 ++++++++++++++++++----
3 files changed, 102 insertions(+), 18 deletions(-)
diff --git
a/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
b/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
index 80a79cf2d..0ddd07591 100644
--- a/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
+++ b/src/main/java/org/apache/commons/compress/harmony/pack200/Segment.java
@@ -39,6 +39,23 @@
/**
* A Pack200 archive consists of one or more Segments.
+ * <p>
+ * Format:
+ * </p>
+ * <pre>
+ * pack200_archive:
+ * (pack200_segment)+
+ *
+ * pack200_segment:
+ * segment_header
+ * *band_headers :BYTE1
+ * cp_bands
+ * attr_definition_bands
+ * ic_bands
+ * class_bands
+ * bc_bands
+ * file_bands
+ * </pre>
*/
public class Segment extends ClassVisitor {
diff --git
a/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
b/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
index e2375111a..67927e193 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/BcBands.java
@@ -37,12 +37,11 @@
import org.apache.commons.compress.harmony.unpack200.bytecode.OperandManager;
/**
- * Bytecode bands
+ * Bytecode bands.
*/
public class BcBands extends BandSet {
- // The bytecodes for each method in each class as they come (i.e. in their
- // packed format)
+ /** The bytecodes for each method in each class as they come (i.e. in
their packed format). */
private byte[][][] methodByteCodePacked;
// The bands
@@ -75,7 +74,9 @@ public class BcBands extends BandSet {
private List<Integer> wideByteCodes;
/**
- * @param segment TODO
+ * Constructs a new instance for the given segment.
+ *
+ * @param segment The segment.
*/
public BcBands(final Segment segment) {
super(segment);
diff --git
a/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
index 3d502d808..55d417d95 100644
--- a/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
+++ b/src/main/java/org/apache/commons/compress/harmony/unpack200/Segment.java
@@ -57,21 +57,49 @@
* A Pack200 archive consists of one or more segments. Each segment is
stand-alone, 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.
- *
+ * <p>
* 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 {@link 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.
- *
+ * </p>
+ * <p>
* 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 ({@link
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.
+ * </p>
+ * <p>
+ * Format:
+ * </p>
+ * <pre>
+ * pack200_archive:
+ * (pack200_segment)+
+ *
+ * pack200_segment:
+ * segment_header
+ * *band_headers :BYTE1
+ * cp_bands
+ * attr_definition_bands
+ * ic_bands
+ * class_bands
+ * bc_bands
+ * file_bands
+ * </pre>
*/
public class Segment {
+ /**
+ * Log level verbose {@value}
+ */
public static final int LOG_LEVEL_VERBOSE = 2;
+ /**
+ * Log level standard {@value}
+ */
public static final int LOG_LEVEL_STANDARD = 1;
+ /**
+ * Log level quiet {@value}
+ */
public static final int LOG_LEVEL_QUIET = 0;
private SegmentHeader header;
@@ -96,7 +124,7 @@ public class Segment {
private int logLevel;
- private PrintWriter logStream;
+ private PrintWriter logPrintWriter;
private byte[][] classFilesContents;
@@ -332,30 +360,56 @@ protected ClassBands getClassBands() {
return classBands;
}
+ /**
+ * Gets the constant pool.
+ *
+ * @return the constant pool.
+ */
public SegmentConstantPool getConstantPool() {
return cpBands.getConstantPool();
}
+ /**
+ * Gets the constant pool bands.
+ *
+ * @return the constant pool bands.
+ */
protected CpBands getCpBands() {
return cpBands;
}
+ /**
+ * Gets the inner class bands.
+ *
+ * @return the inner class bands.
+ */
protected IcBands getIcBands() {
return icBands;
}
+ /**
+ * Gets the segment header.
+ *
+ * @return the segment header.
+ */
public SegmentHeader getSegmentHeader() {
return header;
}
- public void log(final int logLevel, final String message) {
- if (this.logLevel >= logLevel) {
- logStream.println(message);
+ /**
+ * Logs a message.
+ *
+ * @param messageLevel the message level.
+ * @param message the message.
+ */
+ public void log(final int messageLevel, final String message) {
+ if (logLevel >= messageLevel) {
+ logPrintWriter.println(message);
}
}
/**
- * Override the archive's deflate hint with the given boolean
+ * Overrides the archive's deflate hint with the given boolean
*
* @param deflateHint the deflate hint to use
*/
@@ -365,7 +419,7 @@ public void overrideDeflateHint(final boolean deflateHint) {
}
/**
- * This performs the actual work of parsing against a non-static instance
of Segment. This method is intended to run concurrently for multiple segments.
+ * Performs the actual work of parsing against a non-static instance of
Segment. This method is intended to run concurrently for multiple segments.
*
* @throws IOException if a problem occurs during reading from the
underlying stream
* @throws Pack200Exception if a problem occurs with an unexpected value
or unsupported codec
@@ -449,14 +503,29 @@ private void readSegment(final InputStream in) throws
IOException, Pack200Except
fileBands.processFileBits();
}
+ /**
+ * Sets the log level.
+ *
+ * @param logLevel the log level.
+ */
public void setLogLevel(final int logLevel) {
this.logLevel = logLevel;
}
+ /**
+ * Sets the log output.
+ *
+ * @param logStream log output.
+ */
public void setLogStream(final OutputStream logStream) {
- this.logStream = new PrintWriter(new OutputStreamWriter(logStream,
Charset.defaultCharset()), false);
+ this.logPrintWriter = new PrintWriter(new
OutputStreamWriter(logStream, Charset.defaultCharset()), false);
}
+ /**
+ * Sets whether unpacking buffers its input.
+ *
+ * @param value whether unpacking buffers its input.
+ */
public void setPreRead(final boolean value) {
doPreRead = value;
}
@@ -482,9 +551,6 @@ void unpackProcess() throws IOException, Pack200Exception {
parseSegment();
}
- /*
- * Package-private accessors for unpacking stages
- */
void unpackRead(final InputStream inputStream) throws IOException,
Pack200Exception {
@SuppressWarnings("resource")
final InputStream in =
Pack200UnpackerAdapter.newBoundedInputStream(inputStream);
@@ -505,8 +571,8 @@ void unpackRead(final InputStream inputStream) throws
IOException, Pack200Except
void unpackWrite(final JarOutputStream out) throws IOException {
writeJar(out);
- if (logStream != null) {
- logStream.close();
+ if (logPrintWriter != null) {
+ logPrintWriter.close();
}
}