From 578ad0d6bc408edf9e6c875156054374f5fd8337 Mon Sep 17 00:00:00 2001 From: Thomas <> Date: Mon, 22 Mar 2021 18:40:26 +0100 Subject: change to EGIZ codestyle --- .../gv/egiz/asic/impl/ZipCommentReaderStream.java | 250 ++++++++++----------- 1 file changed, 124 insertions(+), 126 deletions(-) (limited to 'moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/ZipCommentReaderStream.java') diff --git a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/ZipCommentReaderStream.java b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/ZipCommentReaderStream.java index 93b7651..dacc76e 100644 --- a/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/ZipCommentReaderStream.java +++ b/moaSig/moa-asic/src/main/java/at/gv/egiz/asic/impl/ZipCommentReaderStream.java @@ -1,7 +1,5 @@ package at.gv.egiz.asic.impl; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.InputStream; @@ -10,171 +8,171 @@ import java.io.InputStream; */ public class ZipCommentReaderStream extends InputStream { - private InputStream inputStream; + private final InputStream inputStream; - private int[] tempBuffer = new int[22]; + private final int[] tempBuffer = new int[22]; - private int[] commentBuffer = null; + private int[] commentBuffer = null; - private int commentBufferContentLen = 0; - private int commentBufferContentOff = 0; + private int commentBufferContentLen = 0; + private int commentBufferContentOff = 0; - private int tempBufferContentLen = 0; - private int tempBufferContentOff = 0; + private int tempBufferContentLen = 0; + private int tempBufferContentOff = 0; - private String fileComment = null; + private String fileComment = null; - private static final byte[] directoryRecord = new byte[] { (byte)0x50, (byte)0x4b, 0x05, 0x06 }; + private static final byte[] directoryRecord = new byte[] { (byte) 0x50, (byte) 0x4b, 0x05, 0x06 }; - public ZipCommentReaderStream(InputStream inputStream) { - this.inputStream = inputStream; - } - - private int readIntIntoBuffer() throws IOException { - int tValue = this.inputStream.read(); - - if(this.tempBuffer.length <= tempBufferContentOff) { - throw new IOException("Temp Buffer is out of space! @ " + tempBufferContentOff); - } + public ZipCommentReaderStream(InputStream inputStream) { + this.inputStream = inputStream; + } - this.tempBuffer[tempBufferContentOff] = tValue; - tempBufferContentOff++; - tempBufferContentLen++; + private int readIntIntoBuffer() throws IOException { + final int tValue = this.inputStream.read(); - return tValue; + if (this.tempBuffer.length <= tempBufferContentOff) { + throw new IOException("Temp Buffer is out of space! @ " + tempBufferContentOff); } - private int readIntIntoCommentBuffer() throws IOException { - int tValue = this.inputStream.read(); + this.tempBuffer[tempBufferContentOff] = tValue; + tempBufferContentOff++; + tempBufferContentLen++; - if(this.commentBuffer.length <= commentBufferContentOff) { - throw new IOException("Comment Buffer is out of space! @ " + commentBufferContentOff); - } + return tValue; + } - this.commentBuffer[commentBufferContentOff] = tValue; - commentBufferContentOff++; - commentBufferContentLen++; + private int readIntIntoCommentBuffer() throws IOException { + final int tValue = this.inputStream.read(); - return tValue; + if (this.commentBuffer.length <= commentBufferContentOff) { + throw new IOException("Comment Buffer is out of space! @ " + commentBufferContentOff); } - private void checkMagicBytes() throws IOException { - boolean foundMagic = true; - tempBufferContentOff = 0; - tempBufferContentLen = 0; - for(int i = 1; i < directoryRecord.length; i++) { - int tValue = readIntIntoBuffer(); - if(tValue != directoryRecord[i]) { - foundMagic = false; - break; - } - if(tValue < 0) { - // Found EOF - return; - } - } + this.commentBuffer[commentBufferContentOff] = tValue; + commentBufferContentOff++; + commentBufferContentLen++; + + return tValue; + } + + private void checkMagicBytes() throws IOException { + boolean foundMagic = true; + tempBufferContentOff = 0; + tempBufferContentLen = 0; + for (int i = 1; i < directoryRecord.length; i++) { + final int tValue = readIntIntoBuffer(); + if (tValue != directoryRecord[i]) { + foundMagic = false; + break; + } + if (tValue < 0) { + // Found EOF + return; + } + } - if(foundMagic) { - // read input stream until comment length - for(int i = 0; i < 16; i++) { - int tValue = readIntIntoBuffer(); + if (foundMagic) { + // read input stream until comment length + for (int i = 0; i < 16; i++) { + final int tValue = readIntIntoBuffer(); - if(tValue < 0) { - // Found EOF - return; - } - } + if (tValue < 0) { + // Found EOF + return; + } + } - int commentlengthHigh = readIntIntoBuffer(); + final int commentlengthHigh = readIntIntoBuffer(); - if(commentlengthHigh < 0) { - // Found EOF - return; - } + if (commentlengthHigh < 0) { + // Found EOF + return; + } - int commentlengthLow = readIntIntoBuffer(); + final int commentlengthLow = readIntIntoBuffer(); - if(commentlengthLow < 0) { - // Found EOF - return; - } + if (commentlengthLow < 0) { + // Found EOF + return; + } - int commentLength = commentlengthLow * 255 + commentlengthHigh; + final int commentLength = commentlengthLow * 255 + commentlengthHigh; - if(commentLength == 0) { - return; - } + if (commentLength == 0) { + return; + } - this.commentBuffer = new int[commentLength]; + this.commentBuffer = new int[commentLength]; - commentBufferContentOff = 0; - commentBufferContentLen = 0; + commentBufferContentOff = 0; + commentBufferContentLen = 0; - // read comment buffer string - for(int i = 0; i < commentLength; i++) { - int tValue = readIntIntoCommentBuffer(); + // read comment buffer string + for (int i = 0; i < commentLength; i++) { + final int tValue = readIntIntoCommentBuffer(); - if(tValue < 0) { - // Found EOF - return; - } - } + if (tValue < 0) { + // Found EOF + return; + } + } - byte[] stringBuffer = new byte[this.commentBuffer.length]; + final byte[] stringBuffer = new byte[this.commentBuffer.length]; - for(int i = 0; i < stringBuffer.length; i++) { - stringBuffer[i] = (byte)this.commentBuffer[i]; - } + for (int i = 0; i < stringBuffer.length; i++) { + stringBuffer[i] = (byte) this.commentBuffer[i]; + } - this.fileComment = new String(stringBuffer); - } + this.fileComment = new String(stringBuffer); } + } - @Override - public int read() throws IOException { - int value = -1; - if(tempBufferContentLen > 0) { - value = this.tempBuffer[tempBufferContentOff]; - tempBufferContentOff++; + @Override + public int read() throws IOException { + int value = -1; + if (tempBufferContentLen > 0) { + value = this.tempBuffer[tempBufferContentOff]; + tempBufferContentOff++; - // reset temp buffer - if(tempBufferContentOff >= tempBufferContentLen) { - tempBufferContentOff = 0; - tempBufferContentLen = 0; - } + // reset temp buffer + if (tempBufferContentOff >= tempBufferContentLen) { + tempBufferContentOff = 0; + tempBufferContentLen = 0; + } - return value; - } + return value; + } - if(this.commentBuffer != null) { - value = this.commentBuffer[commentBufferContentOff]; + if (this.commentBuffer != null) { + value = this.commentBuffer[commentBufferContentOff]; - commentBufferContentOff++; + commentBufferContentOff++; - // reset comment buffer - if(commentBufferContentOff >= commentBufferContentLen) { - commentBufferContentOff = 0; - commentBufferContentLen = 0; - this.commentBuffer = null; - } + // reset comment buffer + if (commentBufferContentOff >= commentBufferContentLen) { + commentBufferContentOff = 0; + commentBufferContentLen = 0; + this.commentBuffer = null; + } - return value; - } - - value = this.inputStream.read(); + return value; + } - if(value == directoryRecord[0] && this.fileComment == null) { - // might have found start of magic bytes - checkMagicBytes(); - // reset buffer offsets - tempBufferContentOff = 0; - commentBufferContentOff = 0; - } + value = this.inputStream.read(); - return value; + if (value == directoryRecord[0] && this.fileComment == null) { + // might have found start of magic bytes + checkMagicBytes(); + // reset buffer offsets + tempBufferContentOff = 0; + commentBufferContentOff = 0; } - public String getFileComment() { - return this.fileComment; - } + return value; + } + + public String getFileComment() { + return this.fileComment; + } } -- cgit v1.2.3