Package org.gjt.cuspy
Class JarX.Build
- java.lang.Object
-
- org.gjt.cuspy.JarX
-
- org.gjt.cuspy.JarX.Build
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class org.gjt.cuspy.JarX
JarX.Build
-
-
Field Summary
-
Fields inherited from class org.gjt.cuspy.JarX
ALL, ARCHIVE_CHARSET, archiveCharset, ATOM, BYTES, CHARACTERS, COMMENT, defaultArchiveCharset, defaultExecutePermission, defaultReadPermission, defaultTreatment, defaultUnpackedCharset, defaultWritePermission, DOMAINLITERAL, executePermission, LINES, mainAttributes, manifestCode, manifestName, NONE, OWNER, PATHRESOLVER, PERMISSIONS, QUOTEDSTRING, readPermission, resolverEngine, resolverScript, treatment, TSPECIAL, type, UNPACKED_CHARSET, unpackedCharset, value, writePermission
-
-
Constructor Summary
Constructors Constructor Description Build()
-
Method Summary
Modifier and Type Method Description void
build(String jarFile, String manif)
Method to be used by an application using this class to build a jar.String
header(BufferedReader r)
Return one header line (complete after RFC822 continuation unfolding).static void
main(String[] args)
Entry point for building a jar.void
manifest(InputStream is)
Read the manifest and build lists of file names and Attributes objects.boolean
section(BufferedReader r)
Process one manifest section, adding a dictionary entry if the section contains both aName:
and aContent-Type
attribute.void
shovelChars(InputStream is, OutputStream os)
Overridden to apply the archive encoding to the output stream (jar entry) and the unpacked encoding to the input stream (local file).void
shovelLines(InputStream is, OutputStream os)
Overridden to apply the archive encoding to the output stream (jar entry), the unpacked encoding to the input stream (local file), and use the RFC2046-required CRLF line separator on the output.-
Methods inherited from class org.gjt.cuspy.JarX
archiveCharsetFromType, classify, describeTranscoding, extract, extract, holds, holdsIgnoreCase, is, notMe, prepareResolver, resolve, setDefaults, shovel, shovelBytes, shovelText, structuredFieldBody
-
-
-
-
Method Detail
-
main
public static void main(String[] args) throws Exception
Entry point for building a jar. Names of all files to be put in the jar (except the manifest itself) are taken from the manifest.- Parameters:
args
- two command line arguments: 1) the name of the jar file to create; 2) the name of the manifest file.- Throws:
Exception
- if anything goes wrong, punt
-
build
public void build(String jarFile, String manif) throws Exception
Method to be used by an application using this class to build a jar.- Parameters:
jarFile
- name of jar file to be createdmanif
- name of an existing manifest file containing the names of files to include in the jar. File names in the manifest obey zip conventions with the forward slash / as the path operator, which may differ from the local platform convention.- Throws:
Exception
- if anything doesn't work, punt
-
shovelLines
public void shovelLines(InputStream is, OutputStream os) throws IOException
Overridden to apply the archive encoding to the output stream (jar entry), the unpacked encoding to the input stream (local file), and use the RFC2046-required CRLF line separator on the output.- Overrides:
shovelLines
in classJarX
- Parameters:
is
- source of input (local file)os
- destination of output (jar entry)- Throws:
IOException
- for any problem involving I/O
-
shovelChars
public void shovelChars(InputStream is, OutputStream os) throws IOException
Overridden to apply the archive encoding to the output stream (jar entry) and the unpacked encoding to the input stream (local file).- Overrides:
shovelChars
in classJarX
- Parameters:
is
- source of input (local file)os
- destination of output (jar entry)- Throws:
IOException
- for any problem involving I/O
-
manifest
public void manifest(InputStream is) throws IOException
Read the manifest and build lists of file names and Attributes objects. This was originally here because JarX wanted to support Java 1.1, which lacked java.util.jar. The reason it is still here (in Build only) is that the java.util.jar.Manifest implementation doesn't preserve the order of manifest sections, while it is nice to build the jar in the specified order.- Parameters:
is
- an input stream already open on the manifest- Throws:
IOException
- if unable to read the manifest
-
section
public boolean section(BufferedReader r) throws IOException
Process one manifest section, adding a dictionary entry if the section contains both aName:
and aContent-Type
attribute.- Parameters:
r
- BufferedReader already open on the manifest- Returns:
- true if there is another section to read, false if the end of the manifest has been reached
- Throws:
IOException
- if the manifest can't be read
-
header
public String header(BufferedReader r) throws IOException
Return one header line (complete after RFC822 continuation unfolding). Note: The Jar specification says it is "inspired by" RFC822, but the folding rule differs. RFC822 allows "linear whitespace" (i.e. space or tab) to start the continuation line, and the LWSP remains in the line (RFC822 lines are only supposed to be folded at places LWSP can appear). A jar manifest line continuation can only begin with a space, and the space is eaten; Java's manifest writer can arbitrarily fold in the middle of anything.- Parameters:
r
- BufferedReader to read from- Returns:
- the line read, or null at end of input
- Throws:
IOException
- if the input cannot be read
-
-