You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by st...@apache.org on 2007/11/21 14:51:10 UTC
svn commit: r597087 - in /ant/core/trunk/src/main/org/apache/tools/tar:
TarBuffer.java TarInputStream.java TarOutputStream.java
Author: stevel
Date: Wed Nov 21 05:51:00 2007
New Revision: 597087
URL: http://svn.apache.org/viewvc?rev=597087&view=rev
Log:
pulling out unneeded this. references in everything but the constructors/initialisers. No other changes.
Modified:
ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java
ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java
ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java
Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java?rev=597087&r1=597086&r2=597087&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/tar/TarBuffer.java Wed Nov 21 05:51:00 2007
@@ -171,7 +171,7 @@
* @return true if the record data is an End of Archive
*/
public boolean isEOFRecord(byte[] record) {
- for (int i = 0, sz = this.getRecordSize(); i < sz; ++i) {
+ for (int i = 0, sz = getRecordSize(); i < sz; ++i) {
if (record[i] != 0) {
return false;
}
@@ -185,22 +185,22 @@
* @throws IOException on error
*/
public void skipRecord() throws IOException {
- if (this.debug) {
- System.err.println("SkipRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("SkipRecord: recIdx = " + currRecIdx
+ + " blkIdx = " + currBlkIdx);
}
- if (this.inStream == null) {
+ if (inStream == null) {
throw new IOException("reading (via skip) from an output buffer");
}
- if (this.currRecIdx >= this.recsPerBlock) {
- if (!this.readBlock()) {
+ if (currRecIdx >= recsPerBlock) {
+ if (!readBlock()) {
return; // UNDONE
}
}
- this.currRecIdx++;
+ currRecIdx++;
}
/**
@@ -210,28 +210,28 @@
* @throws IOException on error
*/
public byte[] readRecord() throws IOException {
- if (this.debug) {
- System.err.println("ReadRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("ReadRecord: recIdx = " + currRecIdx
+ + " blkIdx = " + currBlkIdx);
}
- if (this.inStream == null) {
+ if (inStream == null) {
throw new IOException("reading from an output buffer");
}
- if (this.currRecIdx >= this.recsPerBlock) {
- if (!this.readBlock()) {
+ if (currRecIdx >= recsPerBlock) {
+ if (!readBlock()) {
return null;
}
}
- byte[] result = new byte[this.recordSize];
+ byte[] result = new byte[recordSize];
- System.arraycopy(this.blockBuffer,
- (this.currRecIdx * this.recordSize), result, 0,
- this.recordSize);
+ System.arraycopy(blockBuffer,
+ (currRecIdx * recordSize), result, 0,
+ recordSize);
- this.currRecIdx++;
+ currRecIdx++;
return result;
}
@@ -240,21 +240,21 @@
* @return false if End-Of-File, else true
*/
private boolean readBlock() throws IOException {
- if (this.debug) {
- System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("ReadBlock: blkIdx = " + currBlkIdx);
}
- if (this.inStream == null) {
+ if (inStream == null) {
throw new IOException("reading from an output buffer");
}
- this.currRecIdx = 0;
+ currRecIdx = 0;
int offset = 0;
- int bytesNeeded = this.blockSize;
+ int bytesNeeded = blockSize;
while (bytesNeeded > 0) {
- long numBytes = this.inStream.read(this.blockBuffer, offset,
+ long numBytes = inStream.read(blockBuffer, offset,
bytesNeeded);
//
@@ -291,16 +291,16 @@
offset += numBytes;
bytesNeeded -= numBytes;
- if (numBytes != this.blockSize) {
- if (this.debug) {
+ if (numBytes != blockSize) {
+ if (debug) {
System.err.println("ReadBlock: INCOMPLETE READ "
- + numBytes + " of " + this.blockSize
+ + numBytes + " of " + blockSize
+ " bytes read.");
}
}
}
- this.currBlkIdx++;
+ currBlkIdx++;
return true;
}
@@ -311,7 +311,7 @@
* @return The current zero based block number.
*/
public int getCurrentBlockNum() {
- return this.currBlkIdx;
+ return currBlkIdx;
}
/**
@@ -321,7 +321,7 @@
* @return The current zero based record number.
*/
public int getCurrentRecordNum() {
- return this.currRecIdx - 1;
+ return currRecIdx - 1;
}
/**
@@ -331,31 +331,31 @@
* @throws IOException on error
*/
public void writeRecord(byte[] record) throws IOException {
- if (this.debug) {
- System.err.println("WriteRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("WriteRecord: recIdx = " + currRecIdx
+ + " blkIdx = " + currBlkIdx);
}
- if (this.outStream == null) {
+ if (outStream == null) {
throw new IOException("writing to an input buffer");
}
- if (record.length != this.recordSize) {
+ if (record.length != recordSize) {
throw new IOException("record to write has length '"
+ record.length
+ "' which is not the record size of '"
- + this.recordSize + "'");
+ + recordSize + "'");
}
- if (this.currRecIdx >= this.recsPerBlock) {
- this.writeBlock();
+ if (currRecIdx >= recsPerBlock) {
+ writeBlock();
}
- System.arraycopy(record, 0, this.blockBuffer,
- (this.currRecIdx * this.recordSize),
- this.recordSize);
+ System.arraycopy(record, 0, blockBuffer,
+ (currRecIdx * recordSize),
+ recordSize);
- this.currRecIdx++;
+ currRecIdx++;
}
/**
@@ -368,66 +368,66 @@
* @throws IOException on error
*/
public void writeRecord(byte[] buf, int offset) throws IOException {
- if (this.debug) {
- System.err.println("WriteRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("WriteRecord: recIdx = " + currRecIdx
+ + " blkIdx = " + currBlkIdx);
}
- if (this.outStream == null) {
+ if (outStream == null) {
throw new IOException("writing to an input buffer");
}
- if ((offset + this.recordSize) > buf.length) {
+ if ((offset + recordSize) > buf.length) {
throw new IOException("record has length '" + buf.length
+ "' with offset '" + offset
+ "' which is less than the record size of '"
- + this.recordSize + "'");
+ + recordSize + "'");
}
- if (this.currRecIdx >= this.recsPerBlock) {
- this.writeBlock();
+ if (currRecIdx >= recsPerBlock) {
+ writeBlock();
}
- System.arraycopy(buf, offset, this.blockBuffer,
- (this.currRecIdx * this.recordSize),
- this.recordSize);
+ System.arraycopy(buf, offset, blockBuffer,
+ (currRecIdx * recordSize),
+ recordSize);
- this.currRecIdx++;
+ currRecIdx++;
}
/**
* Write a TarBuffer block to the archive.
*/
private void writeBlock() throws IOException {
- if (this.debug) {
- System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx);
+ if (debug) {
+ System.err.println("WriteBlock: blkIdx = " + currBlkIdx);
}
- if (this.outStream == null) {
+ if (outStream == null) {
throw new IOException("writing to an input buffer");
}
- this.outStream.write(this.blockBuffer, 0, this.blockSize);
- this.outStream.flush();
+ outStream.write(blockBuffer, 0, blockSize);
+ outStream.flush();
- this.currRecIdx = 0;
- this.currBlkIdx++;
+ currRecIdx = 0;
+ currBlkIdx++;
}
/**
* Flush the current data block if it has any data in it.
*/
private void flushBlock() throws IOException {
- if (this.debug) {
+ if (debug) {
System.err.println("TarBuffer.flushBlock() called.");
}
- if (this.outStream == null) {
+ if (outStream == null) {
throw new IOException("writing to an input buffer");
}
- if (this.currRecIdx > 0) {
- this.writeBlock();
+ if (currRecIdx > 0) {
+ writeBlock();
}
}
@@ -437,24 +437,24 @@
* @throws IOException on error
*/
public void close() throws IOException {
- if (this.debug) {
+ if (debug) {
System.err.println("TarBuffer.closeBuffer().");
}
- if (this.outStream != null) {
- this.flushBlock();
+ if (outStream != null) {
+ flushBlock();
- if (this.outStream != System.out
- && this.outStream != System.err) {
- this.outStream.close();
+ if (outStream != System.out
+ && outStream != System.err) {
+ outStream.close();
- this.outStream = null;
+ outStream = null;
}
- } else if (this.inStream != null) {
- if (this.inStream != System.in) {
- this.inStream.close();
+ } else if (inStream != null) {
+ if (inStream != System.in) {
+ inStream.close();
- this.inStream = null;
+ inStream = null;
}
}
}
Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java?rev=597087&r1=597086&r2=597087&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/tar/TarInputStream.java Wed Nov 21 05:51:00 2007
@@ -99,7 +99,7 @@
*/
public void setDebug(boolean debug) {
this.debug = debug;
- this.buffer.setDebug(debug);
+ buffer.setDebug(debug);
}
/**
@@ -107,7 +107,7 @@
* @throws IOException on error
*/
public void close() throws IOException {
- this.buffer.close();
+ buffer.close();
}
/**
@@ -116,7 +116,7 @@
* @return The TarBuffer record size.
*/
public int getRecordSize() {
- return this.buffer.getRecordSize();
+ return buffer.getRecordSize();
}
/**
@@ -132,10 +132,10 @@
* @throws IOException for signature
*/
public int available() throws IOException {
- if (this.entrySize - this.entryOffset > Integer.MAX_VALUE) {
+ if (entrySize - entryOffset > Integer.MAX_VALUE) {
return Integer.MAX_VALUE;
}
- return (int) (this.entrySize - this.entryOffset);
+ return (int) (entrySize - entryOffset);
}
/**
@@ -157,7 +157,7 @@
long skip = numToSkip;
while (skip > 0) {
int realSkip = (int) (skip > skipBuf.length ? skipBuf.length : skip);
- int numRead = this.read(skipBuf, 0, realSkip);
+ int numRead = read(skipBuf, 0, realSkip);
if (numRead == -1) {
break;
}
@@ -203,60 +203,60 @@
* @throws IOException on error
*/
public TarEntry getNextEntry() throws IOException {
- if (this.hasHitEOF) {
+ if (hasHitEOF) {
return null;
}
- if (this.currEntry != null) {
- long numToSkip = this.entrySize - this.entryOffset;
+ if (currEntry != null) {
+ long numToSkip = entrySize - entryOffset;
- if (this.debug) {
+ if (debug) {
System.err.println("TarInputStream: SKIP currENTRY '"
- + this.currEntry.getName() + "' SZ "
- + this.entrySize + " OFF "
- + this.entryOffset + " skipping "
+ + currEntry.getName() + "' SZ "
+ + entrySize + " OFF "
+ + entryOffset + " skipping "
+ numToSkip + " bytes");
}
if (numToSkip > 0) {
- this.skip(numToSkip);
+ skip(numToSkip);
}
- this.readBuf = null;
+ readBuf = null;
}
- byte[] headerBuf = this.buffer.readRecord();
+ byte[] headerBuf = buffer.readRecord();
if (headerBuf == null) {
- if (this.debug) {
+ if (debug) {
System.err.println("READ NULL RECORD");
}
- this.hasHitEOF = true;
- } else if (this.buffer.isEOFRecord(headerBuf)) {
- if (this.debug) {
+ hasHitEOF = true;
+ } else if (buffer.isEOFRecord(headerBuf)) {
+ if (debug) {
System.err.println("READ EOF RECORD");
}
- this.hasHitEOF = true;
+ hasHitEOF = true;
}
- if (this.hasHitEOF) {
- this.currEntry = null;
+ if (hasHitEOF) {
+ currEntry = null;
} else {
- this.currEntry = new TarEntry(headerBuf);
+ currEntry = new TarEntry(headerBuf);
- if (this.debug) {
+ if (debug) {
System.err.println("TarInputStream: SET CURRENTRY '"
- + this.currEntry.getName()
+ + currEntry.getName()
+ "' size = "
- + this.currEntry.getSize());
+ + currEntry.getSize());
}
- this.entryOffset = 0;
+ entryOffset = 0;
- this.entrySize = this.currEntry.getSize();
+ entrySize = currEntry.getSize();
}
- if (this.currEntry != null && this.currEntry.isGNULongNameEntry()) {
+ if (currEntry != null && currEntry.isGNULongNameEntry()) {
// read in the name
StringBuffer longName = new StringBuffer();
byte[] buf = new byte[SMALL_BUFFER_SIZE];
@@ -265,7 +265,7 @@
longName.append(new String(buf, 0, length));
}
getNextEntry();
- if (this.currEntry == null) {
+ if (currEntry == null) {
// Bugzilla: 40334
// Malformed tar file - long entry name not followed by entry
return null;
@@ -275,10 +275,10 @@
&& longName.charAt(longName.length() - 1) == 0) {
longName.deleteCharAt(longName.length() - 1);
}
- this.currEntry.setName(longName.toString());
+ currEntry.setName(longName.toString());
}
- return this.currEntry;
+ return currEntry;
}
/**
@@ -290,8 +290,8 @@
* @throws IOException on error
*/
public int read() throws IOException {
- int num = this.read(this.oneBuf, 0, 1);
- return num == -1 ? -1 : ((int) this.oneBuf[0]) & BYTE_MASK;
+ int num = read(oneBuf, 0, 1);
+ return num == -1 ? -1 : ((int) oneBuf[0]) & BYTE_MASK;
}
/**
@@ -310,29 +310,29 @@
public int read(byte[] buf, int offset, int numToRead) throws IOException {
int totalRead = 0;
- if (this.entryOffset >= this.entrySize) {
+ if (entryOffset >= entrySize) {
return -1;
}
- if ((numToRead + this.entryOffset) > this.entrySize) {
- numToRead = (int) (this.entrySize - this.entryOffset);
+ if ((numToRead + entryOffset) > entrySize) {
+ numToRead = (int) (entrySize - entryOffset);
}
- if (this.readBuf != null) {
- int sz = (numToRead > this.readBuf.length) ? this.readBuf.length
+ if (readBuf != null) {
+ int sz = (numToRead > readBuf.length) ? readBuf.length
: numToRead;
- System.arraycopy(this.readBuf, 0, buf, offset, sz);
+ System.arraycopy(readBuf, 0, buf, offset, sz);
- if (sz >= this.readBuf.length) {
- this.readBuf = null;
+ if (sz >= readBuf.length) {
+ readBuf = null;
} else {
- int newLen = this.readBuf.length - sz;
+ int newLen = readBuf.length - sz;
byte[] newBuf = new byte[newLen];
- System.arraycopy(this.readBuf, sz, newBuf, 0, newLen);
+ System.arraycopy(readBuf, sz, newBuf, 0, newLen);
- this.readBuf = newBuf;
+ readBuf = newBuf;
}
totalRead += sz;
@@ -341,7 +341,7 @@
}
while (numToRead > 0) {
- byte[] rec = this.buffer.readRecord();
+ byte[] rec = buffer.readRecord();
if (rec == null) {
// Unexpected EOF!
@@ -355,9 +355,9 @@
if (recLen > sz) {
System.arraycopy(rec, 0, buf, offset, sz);
- this.readBuf = new byte[recLen - sz];
+ readBuf = new byte[recLen - sz];
- System.arraycopy(rec, sz, this.readBuf, 0, recLen - sz);
+ System.arraycopy(rec, sz, readBuf, 0, recLen - sz);
} else {
sz = recLen;
@@ -369,7 +369,7 @@
offset += sz;
}
- this.entryOffset += totalRead;
+ entryOffset += totalRead;
return totalRead;
}
@@ -385,7 +385,7 @@
byte[] buf = new byte[LARGE_BUFFER_SIZE];
while (true) {
- int numRead = this.read(buf, 0, buf.length);
+ int numRead = read(buf, 0, buf.length);
if (numRead == -1) {
break;
Modified: ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java?rev=597087&r1=597086&r2=597087&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/tar/TarOutputStream.java Wed Nov 21 05:51:00 2007
@@ -119,7 +119,7 @@
* @param debug True to turn on debugging.
*/
public void setBufferDebug(boolean debug) {
- this.buffer.setDebug(debug);
+ buffer.setDebug(debug);
}
/**
@@ -130,8 +130,8 @@
public void finish() throws IOException {
// See Bugzilla 28776 for a discussion on this
// http://issues.apache.org/bugzilla/show_bug.cgi?id=28776
- this.writeEOFRecord();
- this.writeEOFRecord();
+ writeEOFRecord();
+ writeEOFRecord();
}
/**
@@ -142,8 +142,8 @@
*/
public void close() throws IOException {
if (!closed) {
- this.finish();
- this.buffer.close();
+ finish();
+ buffer.close();
out.close();
closed = true;
}
@@ -155,7 +155,7 @@
* @return The TarBuffer record size.
*/
public int getRecordSize() {
- return this.buffer.getRecordSize();
+ return buffer.getRecordSize();
}
/**
@@ -191,15 +191,15 @@
}
}
- entry.writeEntryHeader(this.recordBuf);
- this.buffer.writeRecord(this.recordBuf);
+ entry.writeEntryHeader(recordBuf);
+ buffer.writeRecord(recordBuf);
- this.currBytes = 0;
+ currBytes = 0;
if (entry.isDirectory()) {
- this.currSize = 0;
+ currSize = 0;
} else {
- this.currSize = entry.getSize();
+ currSize = entry.getSize();
}
currName = entry.getName();
}
@@ -215,21 +215,21 @@
* @throws IOException on error
*/
public void closeEntry() throws IOException {
- if (this.assemLen > 0) {
- for (int i = this.assemLen; i < this.assemBuf.length; ++i) {
- this.assemBuf[i] = 0;
+ if (assemLen > 0) {
+ for (int i = assemLen; i < assemBuf.length; ++i) {
+ assemBuf[i] = 0;
}
- this.buffer.writeRecord(this.assemBuf);
+ buffer.writeRecord(assemBuf);
- this.currBytes += this.assemLen;
- this.assemLen = 0;
+ currBytes += assemLen;
+ assemLen = 0;
}
- if (this.currBytes < this.currSize) {
+ if (currBytes < currSize) {
throw new IOException("entry '" + currName + "' closed at '"
- + this.currBytes
- + "' before the '" + this.currSize
+ + currBytes
+ + "' before the '" + currSize
+ "' bytes specified in the header were written");
}
}
@@ -243,9 +243,9 @@
* @throws IOException on error
*/
public void write(int b) throws IOException {
- this.oneBuf[0] = (byte) b;
+ oneBuf[0] = (byte) b;
- this.write(this.oneBuf, 0, 1);
+ write(oneBuf, 0, 1);
}
/**
@@ -257,7 +257,7 @@
* @throws IOException on error
*/
public void write(byte[] wBuf) throws IOException {
- this.write(wBuf, 0, wBuf.length);
+ write(wBuf, 0, wBuf.length);
}
/**
@@ -275,10 +275,10 @@
* @throws IOException on error
*/
public void write(byte[] wBuf, int wOffset, int numToWrite) throws IOException {
- if ((this.currBytes + numToWrite) > this.currSize) {
+ if ((currBytes + numToWrite) > currSize) {
throw new IOException("request to write '" + numToWrite
+ "' bytes exceeds size in header of '"
- + this.currSize + "' bytes for entry '"
+ + currSize + "' bytes for entry '"
+ currName + "'");
//
@@ -290,26 +290,26 @@
//
}
- if (this.assemLen > 0) {
- if ((this.assemLen + numToWrite) >= this.recordBuf.length) {
- int aLen = this.recordBuf.length - this.assemLen;
-
- System.arraycopy(this.assemBuf, 0, this.recordBuf, 0,
- this.assemLen);
- System.arraycopy(wBuf, wOffset, this.recordBuf,
- this.assemLen, aLen);
- this.buffer.writeRecord(this.recordBuf);
+ if (assemLen > 0) {
+ if ((assemLen + numToWrite) >= recordBuf.length) {
+ int aLen = recordBuf.length - assemLen;
+
+ System.arraycopy(assemBuf, 0, recordBuf, 0,
+ assemLen);
+ System.arraycopy(wBuf, wOffset, recordBuf,
+ assemLen, aLen);
+ buffer.writeRecord(recordBuf);
- this.currBytes += this.recordBuf.length;
+ currBytes += recordBuf.length;
wOffset += aLen;
numToWrite -= aLen;
- this.assemLen = 0;
+ assemLen = 0;
} else {
- System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen,
+ System.arraycopy(wBuf, wOffset, assemBuf, assemLen,
numToWrite);
wOffset += numToWrite;
- this.assemLen += numToWrite;
+ assemLen += numToWrite;
numToWrite -= numToWrite;
}
}
@@ -320,20 +320,20 @@
// o No bytes to write (numToWrite == 0)
//
while (numToWrite > 0) {
- if (numToWrite < this.recordBuf.length) {
- System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen,
+ if (numToWrite < recordBuf.length) {
+ System.arraycopy(wBuf, wOffset, assemBuf, assemLen,
numToWrite);
- this.assemLen += numToWrite;
+ assemLen += numToWrite;
break;
}
- this.buffer.writeRecord(wBuf, wOffset);
+ buffer.writeRecord(wBuf, wOffset);
- int num = this.recordBuf.length;
+ int num = recordBuf.length;
- this.currBytes += num;
+ currBytes += num;
numToWrite -= num;
wOffset += num;
}
@@ -344,11 +344,11 @@
* An EOF record consists of a record of all zeros.
*/
private void writeEOFRecord() throws IOException {
- for (int i = 0; i < this.recordBuf.length; ++i) {
- this.recordBuf[i] = 0;
+ for (int i = 0; i < recordBuf.length; ++i) {
+ recordBuf[i] = 0;
}
- this.buffer.writeRecord(this.recordBuf);
+ buffer.writeRecord(recordBuf);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org