From e5a724286d683da01f012014d551d787009ab787 Mon Sep 17 00:00:00 2001 From: Hiroshi Miura Date: Sun, 8 Oct 2023 20:06:06 +0900 Subject: [PATCH] refactor: library codes - change method argument name other than field name - remove IOException which never happen - javadoc: add explanations Signed-off-by: Hiroshi Miura --- .../main/java/org/dict/zip/DictZipInputStream.java | 21 ++++++++------------- .../java/org/dict/zip/RandomAccessInputStream.java | 7 ++++++- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/dictzip-lib/src/main/java/org/dict/zip/DictZipInputStream.java b/dictzip-lib/src/main/java/org/dict/zip/DictZipInputStream.java index 15d6260..7f8509c 100644 --- a/dictzip-lib/src/main/java/org/dict/zip/DictZipInputStream.java +++ b/dictzip-lib/src/main/java/org/dict/zip/DictZipInputStream.java @@ -126,11 +126,11 @@ public class DictZipInputStream extends InflaterInputStream { } @Override - public final void mark(final int markOffset) { - if (markOffset < 0) { + public final void mark(final int offset) { + if (offset < 0) { throw new IllegalArgumentException("markOffset should be positive number."); } - this.markOffset = markOffset; + markOffset = offset; mark = position(); } @@ -304,45 +304,40 @@ public class DictZipInputStream extends InflaterInputStream { * Get type of compression. * * @return "DZIP" or "GZIP" - * @throws IOException if I/O error occurred. */ - public String getType() throws IOException { + public String getType() { return header.getType(); } /** * Get length of each chunk. * @return size of chunk. - * @throws IOException if I/O error occurred. */ - public int getChunkLength() throws IOException { + public int getChunkLength() { return header.getChunkLength(); } /** * Get number of chunks. * @return number of chunks. - * @throws IOException if I/O error occurred. */ - public int getChunkCount() throws IOException { + public int getChunkCount() { return header.getChunkCount(); } /** * Get mtime in long. * @return mtime in long. - * @throws IOException if I/O error occurred. */ - public long getMtime() throws IOException { + public long getMtime() { return header.getMtime(); } /** * Get Filename field if exist. * @return filename or null. - * @throws IOException if I/O error occurred. */ - public String getFilename() throws IOException { + public String getFilename() { return header.getFilename(); } diff --git a/dictzip-lib/src/main/java/org/dict/zip/RandomAccessInputStream.java b/dictzip-lib/src/main/java/org/dict/zip/RandomAccessInputStream.java index 162ec5c..93c62bd 100644 --- a/dictzip-lib/src/main/java/org/dict/zip/RandomAccessInputStream.java +++ b/dictzip-lib/src/main/java/org/dict/zip/RandomAccessInputStream.java @@ -109,6 +109,11 @@ public class RandomAccessInputStream extends InputStream { return fileChannel.size(); } + /** + * Get length of stream. + * @return length in int. + * @throws IOException if an I/O error has occurred. + */ public final int getLength() throws IOException { return (int) length(); } @@ -118,7 +123,7 @@ public class RandomAccessInputStream extends InputStream { * Get cursor position. * * @return position in byte. - * @exception IOException if an I/O error has occurred. + * @throws IOException if an I/O error has occurred. */ public final long position() throws IOException { return currentpos; -- 2.11.0