* return (Attributes)getEntries().get(name) ** Though {@code null} is a valid {@code name}, when * {@code getAttributes(null)} is invoked on a {@code Manifest} * obtained from a jar file, {@code null} will be returned. While jar * files themselves do not allow {@code null}-named attributes, it is * possible to invoke {@link #getEntries} on a {@code Manifest}, and * on that result, invoke {@code put} with a null key and an * arbitrary value. Subsequent invocations of * {@code getAttributes(null)} will return the just-{@code put} * value. *
* Note that this method does not return the manifest's main attributes;
* see {@link #getMainAttributes}.
*
* @param name entry name
* @return the Attributes for the specified entry name
*/
public Attributes getAttributes(String name) {
return getEntries().get(name);
}
/**
* Clears the main Attributes as well as the entries in this Manifest.
*/
public void clear() {
attr.clear();
entries.clear();
}
/**
* Writes the Manifest to the specified OutputStream.
* Attributes.Name.MANIFEST_VERSION must be set in
* MainAttributes prior to invoking this method.
*
* @param out the output stream
* @exception IOException if an I/O error has occurred
* @see #getMainAttributes
*/
public void write(OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
// Write out the main attributes for the manifest
attr.writeMain(dos);
// Now write out the pre-entry attributes
Iterator
* public Object clone() { return new Manifest(this); }
*
* @return a shallow copy of this Manifest
*/
public Object clone() {
return new Manifest(this);
}
/*
* A fast buffered input stream for parsing manifest files.
*/
static class FastInputStream extends FilterInputStream {
private byte buf[];
private int count = 0;
private int pos = 0;
FastInputStream(InputStream in) {
this(in, 8192);
}
FastInputStream(InputStream in, int size) {
super(in);
buf = new byte[size];
}
public int read() throws IOException {
if (pos >= count) {
fill();
if (pos >= count) {
return -1;
}
}
return Byte.toUnsignedInt(buf[pos++]);
}
public int read(byte[] b, int off, int len) throws IOException {
int avail = count - pos;
if (avail <= 0) {
if (len >= buf.length) {
return in.read(b, off, len);
}
fill();
avail = count - pos;
if (avail <= 0) {
return -1;
}
}
if (len > avail) {
len = avail;
}
System.arraycopy(buf, pos, b, off, len);
pos += len;
return len;
}
/*
* Reads 'len' bytes from the input stream, or until an end-of-line
* is reached. Returns the number of bytes read.
*/
public int readLine(byte[] b, int off, int len) throws IOException {
byte[] tbuf = this.buf;
int total = 0;
while (total < len) {
int avail = count - pos;
if (avail <= 0) {
fill();
avail = count - pos;
if (avail <= 0) {
return -1;
}
}
int n = len - total;
if (n > avail) {
n = avail;
}
int tpos = pos;
int maxpos = tpos + n;
while (tpos < maxpos && tbuf[tpos++] != '\n') ;
n = tpos - pos;
System.arraycopy(tbuf, pos, b, off, n);
off += n;
total += n;
pos = tpos;
if (tbuf[tpos-1] == '\n') {
break;
}
}
return total;
}
public byte peek() throws IOException {
if (pos == count)
fill();
if (pos == count)
return -1; // nothing left in buffer
return buf[pos];
}
public int readLine(byte[] b) throws IOException {
return readLine(b, 0, b.length);
}
public long skip(long n) throws IOException {
if (n <= 0) {
return 0;
}
long avail = count - pos;
if (avail <= 0) {
return in.skip(n);
}
if (n > avail) {
n = avail;
}
pos += n;
return n;
}
public int available() throws IOException {
return (count - pos) + in.available();
}
public void close() throws IOException {
if (in != null) {
in.close();
in = null;
buf = null;
}
}
private void fill() throws IOException {
count = pos = 0;
int n = in.read(buf, 0, buf.length);
if (n > 0) {
count = n;
}
}
}
}