Package org.apache.felix.bundleplugin
Class ManifestWriter
- java.lang.Object
-
- org.apache.felix.bundleplugin.ManifestWriter
-
public class ManifestWriter extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static byte[]CONTINUEUnfortunately we have to write our own manifest :-( because of a stupid bug in the manifest code.private static java.util.Set<java.lang.String>NICE_HEADERS
-
Constructor Summary
Constructors Constructor Description ManifestWriter()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidattributes(java.util.jar.Attributes value, java.io.OutputStream out, boolean nice)Output an Attributes map.static voidoutputManifest(java.util.jar.Manifest manifest, java.io.OutputStream out, boolean nice)Main function to output a manifest properly in UTF-8.private static intwrite(java.io.OutputStream out, int width, byte[] bytes)Write the bytes but ensure that the line length does not exceed 72 characters.private static intwrite(java.io.OutputStream out, int i, java.lang.String s)Convert a string to bytes with UTF8 and then output in max 72 bytesprivate static voidwriteEntry(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
-
-
-
Field Detail
-
CONTINUE
private static final byte[] CONTINUE
Unfortunately we have to write our own manifest :-( because of a stupid bug in the manifest code. It tries to handle UTF-8 but the way it does it it makes the bytes platform dependent. So the following code outputs the manifest. A Manifest consists of'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' attributes
Lines 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!
-
NICE_HEADERS
private static final java.util.Set<java.lang.String> NICE_HEADERS
-
-
Method Detail
-
outputManifest
public static void outputManifest(java.util.jar.Manifest manifest, java.io.OutputStream out, boolean nice) throws java.io.IOExceptionMain function to output a manifest properly in UTF-8.- Parameters:
manifest- The manifest to outputout- The output stream- Throws:
java.io.IOException- when something fails
-
writeEntry
private static void writeEntry(java.io.OutputStream out, java.lang.String name, java.lang.String value, boolean nice) throws java.io.IOExceptionWrite out an entry, handling proper unicode and line length constraints- Throws:
java.io.IOException
-
write
private static int write(java.io.OutputStream out, int i, java.lang.String s) throws java.io.IOExceptionConvert a string to bytes with UTF8 and then output in max 72 bytes- Parameters:
out- the output stringi- the current widths- the string to output- Returns:
- the new width
- Throws:
java.io.IOException- when something fails
-
write
private static int write(java.io.OutputStream out, int width, byte[] bytes) throws java.io.IOExceptionWrite the bytes but ensure that the line length does not exceed 72 characters. If it is more than 70 characters, we just put a cr/lf + space.- Parameters:
out- The output streamwidth- The nr of characters output in a line before this method startedbytes- the bytes to output- Returns:
- the nr of characters in the last line
- Throws:
java.io.IOException- if something fails
-
attributes
private static void attributes(java.util.jar.Attributes value, java.io.OutputStream out, boolean nice) throws java.io.IOExceptionOutput an Attributes map. We will sort this map before outputing.- Parameters:
value- the attrbutesout- the output stream- Throws:
java.io.IOException- when something fails
-
-