Methods Summary |
---|
public void | clear()Resets the both the main attributes as well as the entry attributes
associated with this {@code Manifest}.
entryAttributes.clear();
mainAttributes.clear();
|
public java.lang.Object | clone()Creates a copy of this {@code Manifest}. The returned {@code Manifest}
will equal the {@code Manifest} from which it was cloned.
return new Manifest(this);
|
public boolean | equals(java.lang.Object o)Determines if the receiver is equal to the parameter object. Two {@code
Manifest}s are equal if they have identical main attributes as well as
identical entry attributes.
if (o == null) {
return false;
}
if (o.getClass() != this.getClass()) {
return false;
}
if (!mainAttributes.equals(((Manifest) o).mainAttributes)) {
return false;
}
return entryAttributes.equals(((Manifest) o).entryAttributes);
|
public java.util.jar.Attributes | getAttributes(java.lang.String name)Returns the {@code Attributes} associated with the parameter entry
{@code name}.
return getEntries().get(name);
|
byte[] | getChunk(java.lang.String name)
return chunks.get(name);
|
public java.util.Map | getEntries()Returns a map containing the {@code Attributes} for each entry in the
{@code Manifest}.
return entryAttributes;
|
public java.util.jar.Attributes | getMainAttributes()Returns the main {@code Attributes} of the {@code JarFile}.
return mainAttributes;
|
byte[] | getMainAttributesChunk()
return mainAttributesChunk;
|
public int | hashCode()Returns the hash code for this instance.
return mainAttributes.hashCode() ^ entryAttributes.hashCode();
|
public void | read(java.io.InputStream is)Constructs a new {@code Manifest} instance obtaining attribute
information from the specified input stream.
InitManifest initManifest = new InitManifest(is, mainAttributes, entryAttributes,
chunks, null);
mainAttributesChunk = initManifest.getMainAttributesChunk();
|
void | removeChunks()
chunks = null;
|
public void | write(java.io.OutputStream os)Writes out the attribute information of the receiver to the specified
{@code OutputStream}.
write(this, os);
|
static void | write(java.util.jar.Manifest manifest, java.io.OutputStream out)Writes out the attribute information of the specified manifest to the
specified {@code OutputStream}
Charset charset = null;
String encoding = AccessController.doPrivileged(new PriviAction<String>(
"manifest.write.encoding")); //$NON-NLS-1$
if (encoding != null) {
if (encoding.length() == 0) {
encoding = "UTF8"; //$NON-NLS-1$
}
charset = Charset.forName(encoding);
}
String version = manifest.mainAttributes.getValue(Attributes.Name.MANIFEST_VERSION);
if (version != null) {
writeEntry(out, charset, Attributes.Name.MANIFEST_VERSION, version);
Iterator<?> entries = manifest.mainAttributes.keySet().iterator();
while (entries.hasNext()) {
Attributes.Name name = (Attributes.Name) entries.next();
if (!name.equals(Attributes.Name.MANIFEST_VERSION)) {
writeEntry(out, charset, name, manifest.mainAttributes.getValue(name));
}
}
}
out.write(LINE_SEPARATOR);
Iterator<String> i = manifest.entryAttributes.keySet().iterator();
while (i.hasNext()) {
String key = i.next();
writeEntry(out, charset, NAME_ATTRIBUTE, key);
Attributes attrib = manifest.entryAttributes.get(key);
Iterator<?> entries = attrib.keySet().iterator();
while (entries.hasNext()) {
Attributes.Name name = (Attributes.Name) entries.next();
writeEntry(out, charset, name, attrib.getValue(name));
}
out.write(LINE_SEPARATOR);
}
|
private static void | writeEntry(java.io.OutputStream os, java.nio.charset.Charset charset, java.util.jar.Attributes$Name name, java.lang.String value)
int offset = 0;
int limit = LINE_LENGTH_LIMIT;
byte[] out = (name.toString() + ": ").getBytes("ISO8859_1"); //$NON-NLS-1$ //$NON-NLS-2$
if (out.length > limit) {
while (out.length - offset >= limit) {
int len = out.length - offset;
if (len > limit) {
len = limit;
}
if (offset > 0) {
os.write(' ");
}
os.write(out, offset, len);
os.write(LINE_SEPARATOR);
offset += len;
limit = LINE_LENGTH_LIMIT - 1;
}
}
int size = out.length - offset;
final byte[] outBuf = new byte[LINE_LENGTH_LIMIT];
System.arraycopy(out, offset, outBuf, 0, size);
for (int i = 0; i < value.length(); i++) {
char[] oneChar = new char[1];
oneChar[0] = value.charAt(i);
byte[] buf;
if (oneChar[0] < 128 || charset == null) {
byte[] oneByte = new byte[1];
oneByte[0] = (byte) oneChar[0];
buf = oneByte;
} else {
buf = charset.encode(CharBuffer.wrap(oneChar, 0, 1)).array();
}
if (size + buf.length > limit) {
if (limit != LINE_LENGTH_LIMIT) {
os.write(' ");
}
os.write(outBuf, 0, size);
os.write(LINE_SEPARATOR);
limit = LINE_LENGTH_LIMIT - 1;
size = 0;
}
if (buf.length == 1) {
outBuf[size] = buf[0];
} else {
System.arraycopy(buf, 0, outBuf, size, buf.length);
}
size += buf.length;
}
if (size > 0) {
if (limit != LINE_LENGTH_LIMIT) {
os.write(' ");
}
os.write(outBuf, 0, size);
os.write(LINE_SEPARATOR);
}
|