Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.util.jar
Class JarUtils  view JarUtils download JarUtils.java

java.lang.Object
  extended bygnu.java.util.jar.JarUtils

public abstract class JarUtils
extends java.lang.Object

Utility methods for reading and writing JAR Manifest and Manifest-like files.

JAR-related files that resemble Manifest files are Signature files (with an .SF extension) found in signed JARs.


Field Summary
private static java.util.jar.Attributes.Name CREATED_BY
           
private static java.lang.String CREATOR
           
static byte[] CRLF
          Platform-independent line-ending.
private static java.lang.String DEFAULT_MF_VERSION
           
private static java.lang.String DEFAULT_SF_VERSION
           
static java.lang.String DSA_SUFFIX
           
private static java.util.logging.Logger log
           
static java.lang.String MANIFEST_VERSION
          The original string representation of the manifest version attribute name.
static java.lang.String META_INF
           
static java.lang.String NAME
           
static java.lang.String SF_SUFFIX
           
static java.lang.String SIGNATURE_VERSION
          The original string representation of the signature version attribute name.
 
Constructor Summary
JarUtils()
           
 
Method Summary
private static java.lang.String expectHeader(java.lang.String header, java.io.BufferedReader br)
           
private static java.lang.String expectHeader(java.lang.String header, java.io.BufferedReader br, java.lang.String s)
           
private static void read_attributes(java.util.jar.Attributes attr, java.io.BufferedReader br)
           
private static void readAttribute(java.util.jar.Attributes attr, java.lang.String s, java.io.BufferedReader br)
           
private static java.lang.String readHeaderValue(java.lang.String s, java.io.BufferedReader br)
           
private static void readIndividualSections(java.util.Map entries, java.io.BufferedReader br)
           
private static void readMainSection(java.util.jar.Attributes attr, java.io.BufferedReader br)
           
static void readMFManifest(java.util.jar.Attributes attr, java.util.Map entries, java.io.InputStream in)
           
private static java.util.jar.Attributes readSectionName(java.lang.String s, java.io.BufferedReader br, java.util.Map entries)
           
static void readSFManifest(java.util.jar.Attributes attr, java.util.Map entries, java.io.InputStream in)
           
private static void readVersionInfo(java.util.jar.Attributes attr, java.io.BufferedReader br)
          Pedantic method that requires the next attribute in the Manifest to be the "Manifest-Version".
private static void writeAttributeEntry(java.util.Map.Entry entry, java.io.OutputStream out)
           
private static void writeHeader(java.lang.String name, java.lang.String value, java.io.OutputStream out)
          The basic method for writing Mainfest attributes.
static void writeMFManifest(java.util.jar.Attributes attr, java.util.Map entries, java.io.OutputStream stream)
           
static void writeSFManifest(java.util.jar.Attributes attr, java.util.Map entries, java.io.OutputStream stream)
           
private static void writeVersionInfo(java.util.jar.Attributes attr, java.io.OutputStream out)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static final java.util.logging.Logger log

META_INF

public static final java.lang.String META_INF
See Also:
Constant Field Values

DSA_SUFFIX

public static final java.lang.String DSA_SUFFIX
See Also:
Constant Field Values

SF_SUFFIX

public static final java.lang.String SF_SUFFIX
See Also:
Constant Field Values

NAME

public static final java.lang.String NAME
See Also:
Constant Field Values

MANIFEST_VERSION

public static final java.lang.String MANIFEST_VERSION
The original string representation of the manifest version attribute name.

See Also:
Constant Field Values

SIGNATURE_VERSION

public static final java.lang.String SIGNATURE_VERSION
The original string representation of the signature version attribute name.

See Also:
Constant Field Values

CRLF

public static final byte[] CRLF
Platform-independent line-ending.


DEFAULT_MF_VERSION

private static final java.lang.String DEFAULT_MF_VERSION
See Also:
Constant Field Values

DEFAULT_SF_VERSION

private static final java.lang.String DEFAULT_SF_VERSION
See Also:
Constant Field Values

CREATED_BY

private static final java.util.jar.Attributes.Name CREATED_BY

CREATOR

private static final java.lang.String CREATOR
Constructor Detail

JarUtils

public JarUtils()
Method Detail

readMFManifest

public static void readMFManifest(java.util.jar.Attributes attr,
                                  java.util.Map entries,
                                  java.io.InputStream in)
                           throws java.io.IOException

readSFManifest

public static void readSFManifest(java.util.jar.Attributes attr,
                                  java.util.Map entries,
                                  java.io.InputStream in)
                           throws java.io.IOException

readMainSection

private static void readMainSection(java.util.jar.Attributes attr,
                                    java.io.BufferedReader br)
                             throws java.io.IOException

readIndividualSections

private static void readIndividualSections(java.util.Map entries,
                                           java.io.BufferedReader br)
                                    throws java.io.IOException

readVersionInfo

private static void readVersionInfo(java.util.jar.Attributes attr,
                                    java.io.BufferedReader br)
                             throws java.io.IOException
Pedantic method that requires the next attribute in the Manifest to be the "Manifest-Version". This follows the Manifest spec closely but reject some jar Manifest files out in the wild.


expectHeader

private static java.lang.String expectHeader(java.lang.String header,
                                             java.io.BufferedReader br)
                                      throws java.io.IOException

read_attributes

private static void read_attributes(java.util.jar.Attributes attr,
                                    java.io.BufferedReader br)
                             throws java.io.IOException

readAttribute

private static void readAttribute(java.util.jar.Attributes attr,
                                  java.lang.String s,
                                  java.io.BufferedReader br)
                           throws java.io.IOException

readHeaderValue

private static java.lang.String readHeaderValue(java.lang.String s,
                                                java.io.BufferedReader br)
                                         throws java.io.IOException

readSectionName

private static java.util.jar.Attributes readSectionName(java.lang.String s,
                                                        java.io.BufferedReader br,
                                                        java.util.Map entries)
                                                 throws java.util.jar.JarException

expectHeader

private static java.lang.String expectHeader(java.lang.String header,
                                             java.io.BufferedReader br,
                                             java.lang.String s)
                                      throws java.io.IOException

writeMFManifest

public static void writeMFManifest(java.util.jar.Attributes attr,
                                   java.util.Map entries,
                                   java.io.OutputStream stream)
                            throws java.io.IOException

writeSFManifest

public static void writeSFManifest(java.util.jar.Attributes attr,
                                   java.util.Map entries,
                                   java.io.OutputStream stream)
                            throws java.io.IOException

writeVersionInfo

private static void writeVersionInfo(java.util.jar.Attributes attr,
                                     java.io.OutputStream out)
                              throws java.io.IOException

writeAttributeEntry

private static void writeAttributeEntry(java.util.Map.Entry entry,
                                        java.io.OutputStream out)
                                 throws java.io.IOException

writeHeader

private static void writeHeader(java.lang.String name,
                                java.lang.String value,
                                java.io.OutputStream out)
                         throws java.io.IOException
The basic method for writing Mainfest attributes. This implementation respects the rule stated in the Jar Specification concerning the maximum allowed line length; i.e.
 No line may be longer than 72 bytes (not characters), in its UTF8-encoded
 form. If a value would make the initial line longer than this, it should
 be continued on extra lines (each starting with a single SPACE).
 
and
 Because header names cannot be continued, the maximum length of a header
 name is 70 bytes (there must be a colon and a SPACE after the name).