Package org.apache.felix.bundleplugin
Class ManifestWriter
java.lang.Object
org.apache.felix.bundleplugin.ManifestWriter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final byte[]
Unfortunately we have to write our own manifest :-( because of a stupid bug in the manifest code. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static void
attributes
(Attributes value, OutputStream out, boolean nice) Output an Attributes map.static void
outputManifest
(Manifest manifest, OutputStream out, boolean nice) Main function to output a manifest properly in UTF-8.private static int
write
(OutputStream out, int width, byte[] bytes) Write the bytes but ensure that the line length does not exceed 72 characters.private static int
write
(OutputStream out, int i, String s) Convert a string to bytes with UTF8 and then output in max 72 bytesprivate static void
writeEntry
(OutputStream out, String name, String value, boolean nice) Write out an entry, handling proper unicode and line length constraints
-
Field Details
-
CONTINUE
private static final byte[] CONTINUEUnfortunately 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
-
-
Constructor Details
-
ManifestWriter
public ManifestWriter()
-
-
Method Details
-
outputManifest
public static void outputManifest(Manifest manifest, OutputStream out, boolean nice) throws IOException Main function to output a manifest properly in UTF-8.- Parameters:
manifest
- The manifest to outputout
- The output stream- Throws:
IOException
- when something fails
-
writeEntry
private static void writeEntry(OutputStream out, String name, String value, boolean nice) throws IOException Write out an entry, handling proper unicode and line length constraints- Throws:
IOException
-
write
Convert 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:
IOException
- when something fails
-
write
Write 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:
IOException
- if something fails
-
attributes
Output an Attributes map. We will sort this map before outputing.- Parameters:
value
- the attrbutesout
- the output stream- Throws:
IOException
- when something fails
-