public class ManifestWriter
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
(package private) static byte[] |
CONTINUE
Unfortunately we have to write our own manifest :-( because of a stupid
bug in the manifest code.
|
(package private) static java.util.Set<java.lang.String> |
NICE_HEADERS |
Constructor and Description |
---|
ManifestWriter() |
Modifier and Type | Method and Description |
---|---|
private static void |
attributes(java.util.jar.Attributes value,
java.io.OutputStream out,
boolean nice)
Output an Attributes map.
|
static void |
outputManifest(java.util.jar.Manifest manifest,
java.io.OutputStream out,
boolean nice)
Main function to output a manifest properly in UTF-8.
|
private static int |
write(java.io.OutputStream out,
int width,
byte[] bytes)
Write the bytes but ensure that the line length does not exceed 72
characters.
|
private static int |
write(java.io.OutputStream out,
int i,
java.lang.String s)
Convert a string to bytes with UTF8 and then output in max 72 bytes
|
private static void |
writeEntry(java.io.OutputStream out,
java.lang.String name,
java.lang.String value,
boolean nice)
Write out an entry, handling proper unicode and line length constraints
|
static byte[] CONTINUE
'Manifest-Version: 1.0\r\n' main-attributes * \r\n name-section main-attributes ::= attributes attributes ::= key ': ' value '\r\n' name-section ::= 'Name: ' name '\r\n' attributesLines in the manifest should not exceed 72 bytes (! this is where the manifest screwed up as well when 16 bit unicodes were used).
As a bonus, we can now sort the manifest!
static java.util.Set<java.lang.String> NICE_HEADERS
public static void outputManifest(java.util.jar.Manifest manifest, java.io.OutputStream out, boolean nice) throws java.io.IOException
manifest
- The manifest to outputout
- The output streamjava.io.IOException
- when something failsprivate static void writeEntry(java.io.OutputStream out, java.lang.String name, java.lang.String value, boolean nice) throws java.io.IOException
java.io.IOException
private static int write(java.io.OutputStream out, int i, java.lang.String s) throws java.io.IOException
out
- the output stringi
- the current widths
- the string to outputjava.io.IOException
- when something failsprivate static int write(java.io.OutputStream out, int width, byte[] bytes) throws java.io.IOException
out
- The output streamwidth
- The nr of characters output in a line before this method
startedbytes
- the bytes to outputjava.io.IOException
- if something failsprivate static void attributes(java.util.jar.Attributes value, java.io.OutputStream out, boolean nice) throws java.io.IOException
value
- the attrbutesout
- the output streamjava.io.IOException
- when something fails