|
Préférences
Moteurs de recherche
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||
JavaTM 2 Platform Std. Ed. v1.5.0
java.util.jar
|
Field Summary | |
---|---|
static String |
CLASS_ATTRIBUTE_PFX
When concatenated with a class attribute name, indicates the format of that attribute, using the layout language specified in the JSR 200 specification. |
static String |
CODE_ATTRIBUTE_PFX
When concatenated with a code attribute name, indicates the format of that attribute. |
static String |
DEFLATE_HINT
If this property is set to TRUE or FALSE , the packer
will set the deflation hint accordingly in the output archive, and
will not transmit the individual deflation hints of archive elements. |
static String |
EFFORT
If this property is set to a single decimal digit, the packer will use the indicated amount of effort in compressing the archive. |
static String |
ERROR
The string "error", a possible value for certain properties. |
static String |
FALSE
The string "false", a possible value for certain properties. |
static String |
FIELD_ATTRIBUTE_PFX
When concatenated with a field attribute name, indicates the format of that attribute. |
static String |
KEEP
The string "keep", a possible value for certain properties. |
static String |
KEEP_FILE_ORDER
If this property is set to TRUE , the packer will transmit
all elements in their original order within the source archive. |
static String |
LATEST
The string "latest", a possible value for certain properties. |
static String |
METHOD_ATTRIBUTE_PFX
When concatenated with a method attribute name, indicates the format of that attribute. |
static String |
MODIFICATION_TIME
If this property is set to the special string LATEST ,
the packer will attempt to determine the latest modification time,
among all the available entries in the original archive or the latest
modification time of all the available entries in each segment. |
static String |
PASS
The string "pass", a possible value for certain properties. |
static String |
PASS_FILE_PFX
Indicates that a file should be passed through bytewise, with no compression. |
static String |
PROGRESS
The unpacker's progress as a percentage, as periodically updated by the unpacker. |
static String |
SEGMENT_LIMIT
This property is a numeral giving the estimated target size N (in bytes) of each archive segment. |
static String |
STRIP
The string "strip", a possible value for certain properties. |
static String |
TRUE
The string "true", a possible value for certain properties. |
static String |
UNKNOWN_ATTRIBUTE
Indicates the action to take when a class-file containing an unknown attribute is encountered. |
Method Summary | |
---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Registers a listener for PropertyChange events on the properties map. |
void |
pack(JarFile in,
OutputStream out)
Takes a JarFile and converts it into a Pack200 archive. |
void |
pack(JarInputStream in,
OutputStream out)
Takes a JarInputStream and converts it into a Pack200 archive. |
SortedMap<String,String> |
properties()
Get the set of this engine's properties. |
void |
removePropertyChangeListener(PropertyChangeListener listener)
Remove a listener for PropertyChange events, added by the addPropertyChangeListener(java.beans.PropertyChangeListener) . |
Field Detail |
---|
static final String SEGMENT_LIMIT
As a special case, a value of -1 will produce a single large segment with all input files, while a value of 0 will produce one segment for each class. Larger archive segments result in less fragmentation and better compression, but processing them requires more memory.
The size of each segment is estimated by counting the size of each input file to be transmitted in the segment, along with the size of its name and other transmitted properties.
The default is 1000000 (a million bytes). This allows input JAR files of moderate size to be transmitted in one segment. It also puts a limit on memory requirements for packers and unpackers.
A 10Mb JAR packed without this limit will typically pack about 10% smaller, but the packer may require a larger Java heap (about ten times the segment limit).
static final String KEEP_FILE_ORDER
TRUE
, the packer will transmit
all elements in their original order within the source archive.
If it is set to FALSE
, the packer may reorder elements,
and also remove JAR directory entries, which carry no useful
information for Java applications.
(Typically this enables better compression.)
The default is TRUE
, which preserves the input information,
but may cause the transmitted archive to be larger than necessary.
static final String EFFORT
The special value 0 instructs the packer to copy through the original JAR file directly, with no compression. The JSR 200 standard requires any unpacker to understand this special case as a pass-through of the entire archive.
The default is 5, investing a modest amount of time to produce reasonable compression.
static final String DEFLATE_HINT
TRUE
or FALSE
, the packer
will set the deflation hint accordingly in the output archive, and
will not transmit the individual deflation hints of archive elements.
If this property is set to the special string KEEP
, the packer
will attempt to determine an independent deflation hint for each
available element of the input archive, and transmit this hint separately.
The default is KEEP
, which preserves the input information,
but may cause the transmitted archive to be larger than necessary.
It is up to the unpacker implementation to take action upon the hint to suitably compress the elements of the resulting unpacked jar.
The deflation hint of a ZIP or JAR element indicates whether the element was deflated or stored directly.
static final String MODIFICATION_TIME
LATEST
,
the packer will attempt to determine the latest modification time,
among all the available entries in the original archive or the latest
modification time of all the available entries in each segment.
This single value will be transmitted as part of the segment and applied
to all the entries in each segment, SEGMENT_LIMIT
.
This can marginally decrease the transmitted size of the archive, at the expense of setting all installed files to a single date.
If this property is set to the special string KEEP
,
the packer transmits a separate modification time for each input
element.
The default is KEEP
, which preserves the input information,
but may cause the transmitted archive to be larger than necessary.
It is up to the unpacker implementation to take action to suitably set the modification time of each element of its output file.
SEGMENT_LIMIT
,
Constant Field Valuesstatic final String PASS_FILE_PFX
There is no pathname transformation, except that the system file separator is replaced by the JAR file separator '/'.
The resulting file names must match exactly as strings with their occurrences in the JAR file.
If a property value is a directory name, all files under that directory will be passed also.
Examples:
Map p = packer.properties();
p.put(PASS_FILE_PFX+0, "mutants/Rogue.class");
p.put(PASS_FILE_PFX+1, "mutants/Wolverine.class");
p.put(PASS_FILE_PFX+2, "mutants/Storm.class");
# Pass all files in an entire directory hierarchy:
p.put(PASS_FILE_PFX+3, "police/");
.
static final String UNKNOWN_ATTRIBUTE
ERROR
,
STRIP
, and PASS
.
The string ERROR
means that the pack operation
as a whole will fail, with a suitable explanation.
The string
STRIP
means that the attribute will be dropped.
The string
PASS
means that the whole class-file will be passed through
(as if it were a resource file) without compression, with a suitable warning.
This is the default value for this property.
Examples:
Map p = pack200.getProperties();
p.put(UNKNOWN_ATTRIBUTE, ERROR);
p.put(UNKNOWN_ATTRIBUTE, STRIP);
p.put(UNKNOWN_ATTRIBUTE, PASS);
static final String CLASS_ATTRIBUTE_PFX
For example, the effect of this option is built in:
pack.class.attribute.SourceFile=RUH
.
The special strings ERROR
, STRIP
, and PASS
are
also allowed, with the same meaning as UNKNOWN_ATTRIBUTE
.
This provides a way for users to request that specific attributes be
refused, stripped, or passed bitwise (with no class compression).
Code like this might be used to support attributes for JCOV:
Map p = packer.properties();
p.put(CODE_ATTRIBUTE_PFX+"CoverageTable", "NH[PHHII]");
p.put(CODE_ATTRIBUTE_PFX+"CharacterRangeTable", "NH[PHPOHIIH]");
p.put(CLASS_ATTRIBUTE_PFX+"SourceID", "RUH");
p.put(CLASS_ATTRIBUTE_PFX+"CompilationID", "RUH");
Code like this might be used to strip debugging attributes:
Map p = packer.properties();
p.put(CODE_ATTRIBUTE_PFX+"LineNumberTable", STRIP);
p.put(CODE_ATTRIBUTE_PFX+"LocalVariableTable", STRIP);
p.put(CLASS_ATTRIBUTE_PFX+"SourceFile", STRIP);
static final String FIELD_ATTRIBUTE_PFX
pack.field.attribute.Deprecated=
.
The special strings ERROR
, STRIP
, and
PASS
are also allowed.
CLASS_ATTRIBUTE_PFX
,
Constant Field Valuesstatic final String METHOD_ATTRIBUTE_PFX
pack.method.attribute.Exceptions=NH[RCH]
.
The special strings ERROR
, STRIP
, and PASS
are also allowed.
CLASS_ATTRIBUTE_PFX
,
Constant Field Valuesstatic final String CODE_ATTRIBUTE_PFX
pack.code.attribute.LocalVariableTable=NH[PHOHRUHRSHH]
.
The special strings ERROR
, STRIP
, and PASS
are also allowed.
CLASS_ATTRIBUTE_PFX
,
Constant Field Valuesstatic final String PROGRESS
PropertyChangeListener
.
At a minimum, the unpacker must set progress to 0 at the beginning of a packing operation, and to 100 at the end.
static final String KEEP
DEFLATE_HINT
,
MODIFICATION_TIME
,
Constant Field Valuesstatic final String PASS
static final String STRIP
static final String ERROR
static final String TRUE
KEEP_FILE_ORDER
,
DEFLATE_HINT
,
Constant Field Valuesstatic final String FALSE
KEEP_FILE_ORDER
,
DEFLATE_HINT
,
Constant Field Valuesstatic final String LATEST
MODIFICATION_TIME
,
Constant Field ValuesMethod Detail |
---|
SortedMap<String,String> properties()
The property map may contain pre-defined implementation specific and default properties. Users are encouraged to read the information and fully understand the implications, before modifying pre-existing properties.
Implementation specific properties are prefixed with a package name associated with the implementor, beginning with com. or a similar prefix. All property names beginning with pack. and unpack. are reserved for use by this API.
Unknown properties may be ignored or rejected with an unspecified error, and invalid entries may cause an unspecified error to be thrown.
The returned map implements all optional SortedMap
operations
void pack(JarFile in, OutputStream out) throws IOException
Closes its input but not its output. (Pack200 archives are appendable.)
in
- a JarFileout
- an OutputStream
IOException
- if an error is encountered.void pack(JarInputStream in, OutputStream out) throws IOException
Closes its input but not its output. (Pack200 archives are appendable.)
The modification time and deflation hint attributes are not available, for the JAR manifest file and its containing directory.
in
- a JarInputStreamout
- an OutputStream
IOException
- if an error is encountered.MODIFICATION_TIME
,
DEFLATE_HINT
void addPropertyChangeListener(PropertyChangeListener listener)
listener
- An object to be invoked when a property is changed.properties()
,
PROGRESS
void removePropertyChangeListener(PropertyChangeListener listener)
addPropertyChangeListener(java.beans.PropertyChangeListener)
.
listener
- The PropertyChange listener to be removed.addPropertyChangeListener(java.beans.PropertyChangeListener)