Commit c5f651bf by Mark Wielaard Committed by Mark Wielaard

backport: *.java: Reformat all to unofficial standard coding style.

	Merge with Classpath (changes by Bryce McKinlay)
	* java/util/jar/*.java: Reformat all to unofficial standard coding
	style. No changes of substance.

From-SVN: r37538
parent c003f378
2000-11-17 Mark Wielaar <mark@klomp.org>
Merge with Classpath (changes by Bryce McKinlay)
* java/util/jar/*.java: Reformat all to unofficial standard coding
style. No changes of substance.
2000-11-17 Mark Wielaard <mark@klomp.org>
* java/util/zip/*.java: Javadoc updates.
......
......@@ -44,8 +44,8 @@ import java.util.zip.ZipEntry;
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarEntry extends ZipEntry {
public class JarEntry extends ZipEntry
{
// (Packge local) fields
Attributes attr;
......@@ -64,7 +64,8 @@ public class JarEntry extends ZipEntry {
* than 65535 bytes
*/
public JarEntry(String name) throws NullPointerException,
IllegalArgumentException {
IllegalArgumentException
{
super(name);
attr = null;
certs = null;
......@@ -77,7 +78,8 @@ public class JarEntry extends ZipEntry {
*
* @param entry the ZipEntry whose fields should be copied
*/
public JarEntry(ZipEntry entry) {
public JarEntry(ZipEntry entry)
{
super(entry);
attr = null;
certs = null;
......@@ -89,11 +91,16 @@ public class JarEntry extends ZipEntry {
*
* @param entry the jarEntry whose fields should be copied
*/
public JarEntry(JarEntry entry) {
public JarEntry(JarEntry entry)
{
super(entry);
try {
try
{
attr = entry.getAttributes();
} catch(IOException _) {}
}
catch (IOException _)
{
}
certs = entry.getCertificates();
}
......@@ -107,10 +114,14 @@ public class JarEntry extends ZipEntry {
* @exception IOException This will never be thrown. It is here for
* binary compatibility.
*/
public Attributes getAttributes() throws IOException {
if (attr != null) {
public Attributes getAttributes() throws IOException
{
if (attr != null)
{
return (Attributes) attr.clone();
} else {
}
else
{
return null;
}
}
......@@ -129,10 +140,14 @@ public class JarEntry extends ZipEntry {
*
* @return a copy of the certificates set for this entry
*/
public Certificate[] getCertificates() {
if (certs != null) {
return (Certificate []) certs.clone();
} else {
public Certificate[] getCertificates()
{
if (certs != null)
{
return (Certificate[])certs.clone();
}
else
{
return null;
}
}
......
......@@ -40,14 +40,15 @@ import java.util.zip.ZipException;
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarException extends ZipException {
public class JarException extends ZipException
{
// Constructors
/**
* Create a new JarException without a descriptive error message.
*/
public JarException() {
public JarException()
{
super();
}
......@@ -59,7 +60,8 @@ public class JarException extends ZipException {
*
* @param message The descriptive error message
*/
public JarException(String message) {
public JarException(String message)
{
super(message);
}
}
......@@ -47,8 +47,8 @@ import java.util.Enumeration;
* @since 1.2
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarFile extends ZipFile {
public class JarFile extends ZipFile
{
// Fields
/** The name of the manifest entry: META-INF/MANIFEST.MF */
......@@ -73,9 +73,9 @@ public class JarFile extends ZipFile {
* @exception FileNotFoundException if the fileName cannot be found
* @exception IOException if another IO exception occurs while reading
*/
public JarFile(String fileName) throws FileNotFoundException,
IOException {
this (fileName, true);
public JarFile(String fileName) throws FileNotFoundException, IOException
{
this(fileName, true);
}
/**
......@@ -89,8 +89,8 @@ public class JarFile extends ZipFile {
* @exception IOException if another IO exception occurs while reading
*/
public JarFile(String fileName, boolean verify) throws
FileNotFoundException,
IOException {
FileNotFoundException, IOException
{
super(fileName);
manifest = readManifest();
if (verify)
......@@ -105,9 +105,9 @@ public class JarFile extends ZipFile {
* @exception FileNotFoundException if the file does not exits
* @exception IOException if another IO exception occurs while reading
*/
public JarFile(File file) throws FileNotFoundException,
IOException {
this (file, true);
public JarFile(File file) throws FileNotFoundException, IOException
{
this(file, true);
}
/**
......@@ -121,7 +121,8 @@ public class JarFile extends ZipFile {
* @exception IOException if another IO exception occurs while reading
*/
public JarFile(File file, boolean verify) throws FileNotFoundException,
IOException {
IOException
{
super(file);
manifest = readManifest();
if (verify)
......@@ -144,9 +145,8 @@ public class JarFile extends ZipFile {
* @since 1.3
*/
public JarFile(File file, boolean verify, int mode) throws
FileNotFoundException,
IOException,
IllegalArgumentException {
FileNotFoundException, IOException, IllegalArgumentException
{
super(file, mode);
manifest = readManifest();
if (verify)
......@@ -158,9 +158,11 @@ public class JarFile extends ZipFile {
/**
* XXX - should verify the manifest file
*/
private void verify() {
private void verify()
{
// only check if manifest is not null
if (manifest == null) {
if (manifest == null)
{
verify = false;
return;
}
......@@ -172,16 +174,23 @@ public class JarFile extends ZipFile {
/**
* Parses and returns the manifest if it exists, otherwise returns null.
*/
private Manifest readManifest() {
try {
private Manifest readManifest()
{
try
{
ZipEntry manEntry = super.getEntry(MANIFEST_NAME);
if (manEntry != null) {
if (manEntry != null)
{
InputStream in = super.getInputStream(manEntry);
return new Manifest(in);
} else {
}
else
{
return null;
}
} catch (IOException ioe) {
}
catch (IOException ioe)
{
return null;
}
}
......@@ -192,7 +201,8 @@ public class JarFile extends ZipFile {
*
* @exception IllegalStateException when the JarFile is already closed
*/
public Enumeration entries() throws IllegalStateException {
public Enumeration entries() throws IllegalStateException
{
return new JarEnumeration(super.entries());
}
......@@ -201,22 +211,27 @@ public class JarFile extends ZipFile {
* JarEntry is created and the corresponding Attributes are looked up.
* XXX - Should also look up the certificates.
*/
private class JarEnumeration implements Enumeration {
private class JarEnumeration implements Enumeration
{
private final Enumeration entries;
JarEnumeration(Enumeration e) {
JarEnumeration(Enumeration e)
{
entries = e;
}
public boolean hasMoreElements() {
public boolean hasMoreElements()
{
return entries.hasMoreElements();
}
public Object nextElement() {
public Object nextElement()
{
ZipEntry zip = (ZipEntry) entries.nextElement();
JarEntry jar = new JarEntry(zip);
if (manifest != null) {
if (manifest != null)
{
jar.attr = manifest.getAttributes(jar.getName());
}
// XXX jar.certs
......@@ -229,11 +244,14 @@ public class JarFile extends ZipFile {
* It actually returns a JarEntry not a zipEntry
* @param name XXX
*/
public ZipEntry getEntry(String name) {
public ZipEntry getEntry(String name)
{
ZipEntry entry = super.getEntry(name);
if (entry != null) {
if (entry != null)
{
JarEntry jarEntry = new JarEntry(entry);
if (manifest != null) {
if (manifest != null)
{
jarEntry.attr = manifest.getAttributes(name);
// XXX jarEntry.certs
}
......@@ -249,8 +267,8 @@ public class JarFile extends ZipFile {
* @exception IOException XXX
*/
public synchronized InputStream getInputStream(ZipEntry entry) throws
ZipException,
IOException {
ZipException, IOException
{
return super.getInputStream(entry); // XXX verify
}
......@@ -263,15 +281,17 @@ public class JarFile extends ZipFile {
* @param name the jar entry name to look up
* @return the JarEntry if it exists, null otherwise
*/
public JarEntry getJarEntry(String name) {
return (JarEntry)getEntry(name);
public JarEntry getJarEntry(String name)
{
return (JarEntry) getEntry(name);
}
/**
* Returns the manifest for this JarFile or null when the JarFile does not
* contain a manifest file.
*/
public Manifest getManifest() {
public Manifest getManifest()
{
return manifest;
}
}
......@@ -40,8 +40,8 @@ import java.util.zip.ZipInputStream;
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarInputStream extends ZipInputStream {
public class JarInputStream extends ZipInputStream
{
// Fields
/** The manifest for this file or null when there was no manifest. */
......@@ -64,7 +64,8 @@ public class JarInputStream extends ZipInputStream {
* @param in InputStream to read the jar from
* @exception IOException when an error occurs when opening or reading
*/
public JarInputStream(InputStream in) throws IOException {
public JarInputStream(InputStream in) throws IOException
{
this(in, true);
}
......@@ -77,7 +78,8 @@ public class JarInputStream extends ZipInputStream {
* @param verify wheter or not to verify the manifest entries
* @exception IOException when an error occurs when opening or reading
*/
public JarInputStream(InputStream in, boolean verify) throws IOException {
public JarInputStream(InputStream in, boolean verify) throws IOException
{
super(in);
readManifest(verify);
}
......@@ -91,18 +93,22 @@ public class JarInputStream extends ZipInputStream {
* when false no check is performed
* @exception IOException if an error occurs while reading
*/
private void readManifest(boolean verify) throws IOException {
private void readManifest(boolean verify) throws IOException
{
firstEntry = (JarEntry) super.getNextEntry();
while ((firstEntry != null) &&
firstEntry.getName().startsWith("META-INF/")) {
if(firstEntry.getName().equals(JarFile.MANIFEST_NAME)) {
firstEntry.getName().startsWith("META-INF/"))
{
if (firstEntry.getName().equals(JarFile.MANIFEST_NAME))
{
manifest = new Manifest(this);
}
firstEntry = (JarEntry) super.getNextEntry();
}
closeEntry();
if (verify) {
if (verify)
{
// XXX
}
}
......@@ -114,10 +120,12 @@ public class JarInputStream extends ZipInputStream {
*
* @param name the name of the new entry
*/
protected ZipEntry createZipEntry(String name) {
protected ZipEntry createZipEntry(String name)
{
ZipEntry zipEntry = super.createZipEntry(name);
JarEntry jarEntry = new JarEntry(zipEntry);
if (manifest != null) {
if (manifest != null)
{
jarEntry.attr = manifest.getAttributes(name);
}
return jarEntry;
......@@ -126,7 +134,8 @@ public class JarInputStream extends ZipInputStream {
/**
* Returns the Manifest for the jar file or null if there was no Manifest.
*/
public Manifest getManifest() {
public Manifest getManifest()
{
return manifest;
}
......@@ -139,12 +148,16 @@ public class JarInputStream extends ZipInputStream {
*
* @exception IOException if an IO error occurs when reading the entry
*/
public ZipEntry getNextEntry() throws IOException {
public ZipEntry getNextEntry() throws IOException
{
ZipEntry entry;
if (firstEntry != null) {
if (firstEntry != null)
{
entry = firstEntry;
firstEntry = null;
} else {
}
else
{
entry = super.getNextEntry();
}
return entry;
......@@ -155,8 +168,9 @@ public class JarInputStream extends ZipInputStream {
*
* @exception IOException if an IO error occurs when reading the entry
*/
public JarEntry getNextJarEntry() throws IOException {
return (JarEntry)getNextEntry();
public JarEntry getNextJarEntry() throws IOException
{
return (JarEntry) getNextEntry();
}
/**
......@@ -168,7 +182,8 @@ public class JarInputStream extends ZipInputStream {
* @return XXX
* @exception IOException XXX
*/
public int read(byte[] buf, int off, int len) throws IOException {
public int read(byte[]buf, int off, int len) throws IOException
{
// XXX if (verify) {}
return super.read(buf, off, len);
}
......
......@@ -39,8 +39,8 @@ import java.util.zip.ZipOutputStream;
* @author Mark Wielaard (mark@klomp.org)
*/
public class JarOutputStream extends ZipOutputStream {
public class JarOutputStream extends ZipOutputStream
{
// Constructors
/**
......@@ -49,7 +49,8 @@ public class JarOutputStream extends ZipOutputStream {
* @param out the stream to create the new jar on
* @exception IOException if something unexpected happend
*/
public JarOutputStream(OutputStream out) throws IOException {
public JarOutputStream(OutputStream out) throws IOException
{
this(out, null);
}
......@@ -62,7 +63,8 @@ public class JarOutputStream extends ZipOutputStream {
* for no manifest entry
* @exception IOException if something unexpected happend
*/
public JarOutputStream(OutputStream out, Manifest man) throws IOException {
public JarOutputStream(OutputStream out, Manifest man) throws IOException
{
super(out);
if (man != null)
writeManifest(man);
......@@ -77,7 +79,8 @@ public class JarOutputStream extends ZipOutputStream {
* @param manifest the non null manifest to be written
* @exception IOException if something unexpected happend
*/
private void writeManifest(Manifest manifest) throws IOException {
private void writeManifest(Manifest manifest) throws IOException
{
// Create a new Jar Entry for the Manifest
JarEntry entry = new JarEntry(JarFile.MANIFEST_NAME);
putNextEntry(entry);
......@@ -92,7 +95,8 @@ public class JarOutputStream extends ZipOutputStream {
* @param entry The information for the next entry
* @exception IOException when some unexpected I/O exception occured
*/
public void putNextEntry(ZipEntry entry) throws IOException {
public void putNextEntry(ZipEntry entry) throws IOException
{
super.putNextEntry(entry); // XXX
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment