[kaffe] CVS kaffe (dalibor): Small cleanup in java.util.zip

Kaffe CVS cvs-commits at kaffe.org
Mon Sep 29 16:53:03 PDT 2003


PatchSet 4082 
Date: 2003/09/29 23:50:25
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Small cleanup in java.util.zip

Fixed java.util.zip classes to use accessor methods when accessing fields of
ZipEntrys.

Members: 
	ChangeLog:1.1677->1.1678 
	libraries/javalib/java/util/zip/ZipEntry.java:1.11->1.12 
	libraries/javalib/java/util/zip/ZipFile.java:1.10->1.11 
	libraries/javalib/java/util/zip/ZipInputStream.java:1.15->1.16 
	libraries/javalib/java/util/zip/ZipOutputStream.java:1.13->1.14 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.1677 kaffe/ChangeLog:1.1678
--- kaffe/ChangeLog:1.1677	Mon Sep 29 11:17:19 2003
+++ kaffe/ChangeLog	Mon Sep 29 23:50:25 2003
@@ -1,3 +1,21 @@
+2003-09-30  Dalibor Topic <robilad at kaffe.org>
+
+	* libraries/javalib/java/util/zip/ZipEntry.java:
+	(name, time, crc, size, method, extra, comment, csize) Changed
+	access to private.
+
+	* libraries/javalib/java/util/zip/ZipFile.java:
+	(getInputStream) Use accessor methods to access internal fields of
+	ZipEntry.
+
+	* libraries/javalib/java/util/zip/ZipInputStream.java:
+	(getNextEntry) Use accessor methods to access internal fields of
+	ZipEntry.
+
+	* libraries/javalib/java/util/zip/ZipOutputStream.java:
+	(closeEntry, finish, putNextEntry) Use accessor methods to access
+	internal fields of ZipEntry.
+
 2003-09-29  Dalibor Topic <robilad at kaffe.org>
 
 	* libraries/javalib/java/util/zip/GZIPOutputStream.java:
Index: kaffe/libraries/javalib/java/util/zip/ZipEntry.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipEntry.java:1.11 kaffe/libraries/javalib/java/util/zip/ZipEntry.java:1.12
--- kaffe/libraries/javalib/java/util/zip/ZipEntry.java:1.11	Sat Aug 26 22:21:58 2000
+++ kaffe/libraries/javalib/java/util/zip/ZipEntry.java	Mon Sep 29 23:50:26 2003
@@ -19,17 +19,17 @@
   public static final int STORED = Deflater.NO_COMPRESSION;
   public static final int DEFLATED = Deflater.DEFLATED;
 
-  String name;
-  long time = -1;
+  private String name;
+  private long time = -1;
   int dosTime;
-  long crc;
-  long size;
-  int method;
-  byte[] extra;
-  String comment;
+  private long crc;
+  private long size;
+  private int method;
+  private byte[] extra;
+  private String comment;
   int flag;
   int version;
-  long csize;
+  private long csize;
   long offset;
 
   /**
Index: kaffe/libraries/javalib/java/util/zip/ZipFile.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.10 kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.11
--- kaffe/libraries/javalib/java/util/zip/ZipFile.java:1.10	Thu Sep 25 09:27:46 2003
+++ kaffe/libraries/javalib/java/util/zip/ZipFile.java	Mon Sep 29 23:50:26 2003
@@ -76,8 +76,8 @@
 		throw new NullPointerException();
 	}
 
-	if (ze.size == -1) {
-		ze = getEntry(ze.name);
+	if (ze.getSize() == -1) {
+		ze = getEntry(ze.getName());
 	}
 
 	byte[] buf = getZipData0(zip, ze);
Index: kaffe/libraries/javalib/java/util/zip/ZipInputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.15 kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.16
--- kaffe/libraries/javalib/java/util/zip/ZipInputStream.java:1.15	Mon Sep 29 00:38:59 2003
+++ kaffe/libraries/javalib/java/util/zip/ZipInputStream.java	Mon Sep 29 23:50:26 2003
@@ -79,9 +79,9 @@
       entry.offset = 0;
 
       // Select the loader, simple or inflater.
-      if (entry.method == ZipEntry.STORED) {
+      if (entry.getMethod() == ZipEntry.STORED) {
 	sinf.setMode(true);
-	sinf.setLength((int)entry.csize);
+	sinf.setLength((int)entry.getCompressedSize());
       }
       else {
 	sinf.setMode(false);
@@ -120,7 +120,7 @@
 	// from the DATA header. This is so that users can find out
 	// the compressed and uncompressed sizes of data written in
 	// a compressed entry.
-	if (entry.method == ZipEntry.DEFLATED && peekSig() == (int)EXTSIG) {
+	if (entry.getMethod() == ZipEntry.DEFLATED && peekSig() == (int)EXTSIG) {
 
 	  // Consume signature
 	  readSig();
Index: kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java
diff -u kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.13 kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.14
--- kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java:1.13	Mon Sep 29 00:38:59 2003
+++ kaffe/libraries/javalib/java/util/zip/ZipOutputStream.java	Mon Sep 29 23:50:26 2003
@@ -117,30 +117,30 @@
 	def.reset();
 	crc.reset();
 
-	if (curr.csize != -1 && curr.csize != out) {
+	if (curr.getCompressedSize() != -1 && curr.getCompressedSize() != out) {
 		throw new ZipException("compress size set incorrectly");
 	}
-	if (curr.size != -1 && curr.size != in) {
+	if (curr.getSize() != -1 && curr.getSize() != in) {
 		throw new ZipException("uncompress size set incorrectly");
 	}
-	if (curr.crc != -1 && curr.crc != crcval) {
+	if (curr.getCrc() != -1 && curr.getCrc() != crcval) {
 		throw new ZipException("crc set incorrectly");
 	}
 
-	curr.csize = out;
-	curr.size = in;
-	curr.crc = crcval;
+	curr.setCompressedSize(out);
+	curr.setSize(in);
+	curr.setCrc(crcval);
 
-	dout += curr.csize;
+	dout += curr.getCompressedSize();
 
 	// We only add the data descriptor when writing a compressed entry
 
 	if (curr.flag == 0x0008) {
 	    byte[] da = new byte[EXTHDR];
 	    put32(da, 0, (int)EXTSIG);
-	    put32(da, EXTCRC, (int)curr.crc);
-	    put32(da, EXTSIZ, (int) curr.csize);
-	    put32(da, EXTLEN, (int) curr.size);
+	    put32(da, EXTCRC, (int)curr.getCrc());
+	    put32(da, EXTSIZ, (int) curr.getCompressedSize());
+	    put32(da, EXTLEN, (int) curr.getSize());
 	    strm.write(da);
 	    dout += EXTHDR;
 	}
@@ -164,25 +164,25 @@
 		ZipEntry ze = (ZipEntry)e.nextElement();
 
 		// Convert name to UTF-8 binary
-		byte[] nameBuf = (ze.name != null) ?
-		    UTF8.encode(ze.name) : new byte[0];
+		byte[] nameBuf = (ze.getName() != null) ?
+		    UTF8.encode(ze.getName()) : new byte[0];
 
 		// Write central directory entry
 		put32(ch, 0, (int)CENSIG);
-		int zipver = (ze.method == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
+		int zipver = (ze.getMethod() == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
 		put16(ch, CENVEM, zipver);
 		put16(ch, CENVER, zipver);
 		put16(ch, CENFLG, ze.flag);
-		put16(ch, CENHOW, ze.method);
+		put16(ch, CENHOW, ze.getMethod());
 		put32(ch, CENTIM, ze.dosTime);
-		put32(ch, CENCRC, (int)ze.crc);
-		put32(ch, CENSIZ, (int)ze.csize);
-		put32(ch, CENLEN, (int)ze.size);
+		put32(ch, CENCRC, (int)ze.getCrc());
+		put32(ch, CENSIZ, (int)ze.getCompressedSize());
+		put32(ch, CENLEN, (int)ze.getSize());
 		put16(ch, CENNAM, nameBuf.length);
-		put16(ch, CENEXT, ze.extra == null ?
-			0 : ze.extra.length);
-		put16(ch, CENCOM, ze.comment == null ?
-			0 : ze.comment.length());
+		put16(ch, CENEXT, ze.getExtra() == null ?
+			0 : ze.getExtra().length);
+		put16(ch, CENCOM, ze.getComment() == null ?
+			0 : ze.getComment().length());
 		put16(ch, CENDSK, 0);
 		put16(ch, CENATT, 0);
 		put32(ch, CENATX, 0);
@@ -196,9 +196,9 @@
 		size += nameBuf.length;
 
 		// Write any extra stuff
-		if (ze.extra != null) {
-		    strm.write(ze.extra);
-		    size += ze.extra.length;
+		if (ze.getExtra() != null) {
+		    strm.write(ze.getExtra());
+		    size += ze.getExtra().length;
 		}
 
 		count++;
@@ -228,15 +228,15 @@
 {
 	closeEntry();	// Close previous entry
 
-	if (ze.method == -1) {
-		ze.method = method;
+	if (ze.getMethod() == -1) {
+		ze.setMethod(method);
 	}
-	if (ze.method == STORED) {
-		if (ze.size == -1) {
+	if (ze.getMethod() == STORED) {
+		if (ze.getSize() == -1) {
 			throw new ZipException("size not set in stored entry");
 		}
-		ze.csize = ze.size;
-		if (ze.crc == -1) {
+		ze.setCompressedSize(ze.getSize());
+		if (ze.getCrc() == -1) {
 			throw new ZipException("crc not set in stored entry");
 		}
 		ze.flag = 0;
@@ -244,8 +244,8 @@
 		ze.flag = 0x0008;
 	}
 
-	if (curr == null || curr.method != ze.method) {
-		if (ze.method == STORED) {
+	if (curr == null || curr.getMethod() != ze.getMethod()) {
+		if (ze.getMethod() == STORED) {
 			def = new Storer();
 		}
 		else {
@@ -254,21 +254,21 @@
 	}
 
 	// Convert name to UTF-8 binary
-	byte[] nameBuf = (ze.name != null) ?
-	    UTF8.encode(ze.name) : new byte[0];
+	byte[] nameBuf = (ze.getName() != null) ?
+	    UTF8.encode(ze.getName()) : new byte[0];
 
 	byte[] lh = new byte[LOCHDR];
 	put32(lh, 0, (int)LOCSIG);
 	put16(lh, LOCVER,
-		ze.method == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
+		ze.getMethod() == STORED ? ZIPVER_1_0 : ZIPVER_2_0);
 	put16(lh, LOCFLG, ze.flag);
-	put16(lh, LOCHOW, ze.method);
+	put16(lh, LOCHOW, ze.getMethod());
 	put32(lh, LOCTIM, ze.dosTime);
 
-	if (ze.method == STORED) {
-		put32(lh, LOCCRC, (int)ze.crc);
-		put32(lh, LOCSIZ, (int)ze.csize);
-		put32(lh, LOCLEN, (int)ze.size);
+	if (ze.getMethod() == STORED) {
+		put32(lh, LOCCRC, (int)ze.getCrc());
+		put32(lh, LOCSIZ, (int)ze.getCompressedSize());
+		put32(lh, LOCLEN, (int)ze.getSize());
 	} else {
 		put32(lh, LOCCRC, 0);
 		put32(lh, LOCSIZ, 0);
@@ -276,7 +276,7 @@
 	}
 
 	put16(lh, LOCNAM, nameBuf.length);
-	put16(lh, LOCEXT, ze.extra == null ? 0 : ze.extra.length);
+	put16(lh, LOCEXT, ze.getExtra() == null ? 0 : ze.getExtra().length);
 
 	strm.write(lh);
 
@@ -288,9 +288,9 @@
 	dout += nameBuf.length;
 
 	// Write any extra stuff
-	if (ze.extra != null) {
-		strm.write(ze.extra);
-		dout += ze.extra.length;
+	if (ze.getExtra() != null) {
+		strm.write(ze.getExtra());
+		dout += ze.getExtra().length;
 	}
 
 	// Add entry to list of entries we need to write at the end.




More information about the kaffe mailing list