From 3714fdd41a251c02362b372568b023230e37aea9 Mon Sep 17 00:00:00 2001 From: Gary Gregory Date: Thu, 19 Oct 2023 08:10:47 -0400 Subject: [PATCH] Camel-case parameter and internal names Javadoc --- .../archivers/ar/ArArchiveInputStream.java | 6 +-- .../compress/archivers/sevenz/SevenZFile.java | 4 +- .../compress/archivers/tar/package-info.java | 2 +- .../gzip/GzipCompressorOutputStream.java | 8 ++-- .../compressors/gzip/GzipParameters.java | 6 +-- .../commons/compress/utils/FileNameUtils.java | 42 +++++++++---------- .../commons/compress/AbstractTestCase.java | 8 ++-- .../commons/compress/ArchiveReadTest.java | 2 +- .../memory/MemoryArchiveInputStream.java | 10 ++--- .../archivers/sevenz/SevenZFileTest.java | 4 +- .../archivers/zip/ExplodeSupportTest.java | 8 ++-- .../BrotliCompressorInputStreamTest.java | 2 +- 12 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java index 8da2689bec3..08b03cd3722 100644 --- a/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java +++ b/src/main/java/org/apache/commons/compress/archivers/ar/ArArchiveInputStream.java @@ -226,7 +226,7 @@ private String getBSDLongName(final String bsdLongName) throws IOException { */ private String getExtendedName(final int offset) throws IOException { if (namebuffer == null) { - throw new IOException("Cannot process GNU long filename as no // record was found"); + throw new IOException("Cannot process GNU long file name as no // record was found"); } for (int i = offset; i < namebuffer.length; i++) { if (namebuffer[i] == '\012' || namebuffer[i] == 0) { @@ -301,11 +301,11 @@ public ArArchiveEntry getNextArEntry() throws IOException { entryOffset = offset; -// GNU ar uses a '/' to mark the end of the filename; this allows for the use of spaces without the use of an extended filename. +// GNU ar uses a '/' to mark the end of the file name; this allows for the use of spaces without the use of an extended file name. // entry name is stored as ASCII string String temp = ArchiveUtils.toAsciiString(metaData, NAME_OFFSET, NAME_LEN).trim(); - if (isGNUStringTable(temp)) { // GNU extended filenames entry + if (isGNUStringTable(temp)) { // GNU extended file names entry currentEntry = readGNUStringTable(metaData, LENGTH_OFFSET, LENGTH_LEN); return getNextArEntry(); } diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java index 8dd12721649..47fcb5fb8a7 100644 --- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java +++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java @@ -471,11 +471,11 @@ public SevenZFile(final SeekableByteChannel channel, final String fileName, this(channel, fileName, password, false, SevenZFileOptions.DEFAULT); } - private SevenZFile(final SeekableByteChannel channel, final String filename, + private SevenZFile(final SeekableByteChannel channel, final String fileName, final byte[] password, final boolean closeOnError, final SevenZFileOptions options) throws IOException { boolean succeeded = false; this.channel = channel; - this.fileName = filename; + this.fileName = fileName; this.options = options; try { archive = readHeaders(password); diff --git a/src/main/java/org/apache/commons/compress/archivers/tar/package-info.java b/src/main/java/org/apache/commons/compress/archivers/tar/package-info.java index 842106dd3f4..5e64dc5ae2c 100644 --- a/src/main/java/org/apache/commons/compress/archivers/tar/package-info.java +++ b/src/main/java/org/apache/commons/compress/archivers/tar/package-info.java @@ -21,7 +21,7 @@ * Provides stream classes for reading and writing archives using the TAR format. *

* There are many different format dialects that call themselves TAR. The classes of this package can read and write archives in the traditional pre-POSIX - * ustar format and support GNU specific extensions for long filenames that GNU tar itself by now refers to as oldgnu. + * ustar format and support GNU specific extensions for long file names that GNU tar itself by now refers to as oldgnu. *

*/ package org.apache.commons.compress.archivers.tar; \ No newline at end of file diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java index ee7a74a5531..e1c1a1f7cf1 100644 --- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java +++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipCompressorOutputStream.java @@ -194,14 +194,14 @@ public void write(final int b) throws IOException { } private void writeHeader(final GzipParameters parameters) throws IOException { - final String filename = parameters.getFilename(); + final String fileName = parameters.getFilename(); final String comment = parameters.getComment(); final ByteBuffer buffer = ByteBuffer.allocate(10); buffer.order(ByteOrder.LITTLE_ENDIAN); buffer.putShort((short) GZIPInputStream.GZIP_MAGIC); buffer.put((byte) Deflater.DEFLATED); // compression method (8: deflate) - buffer.put((byte) ((filename != null ? FNAME : 0) | (comment != null ? FCOMMENT : 0))); // flags + buffer.put((byte) ((fileName != null ? FNAME : 0) | (comment != null ? FCOMMENT : 0))); // flags buffer.putInt((int) (parameters.getModificationTime() / 1000)); // extra flags @@ -218,8 +218,8 @@ private void writeHeader(final GzipParameters parameters) throws IOException { out.write(buffer.array()); - if (filename != null) { - out.write(getBytes(filename)); + if (fileName != null) { + out.write(getBytes(fileName)); out.write(0); } diff --git a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java index 4c6be46c30a..04abf5fc466 100644 --- a/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java +++ b/src/main/java/org/apache/commons/compress/compressors/gzip/GzipParameters.java @@ -33,7 +33,7 @@ public class GzipParameters { private int compressionLevel = Deflater.DEFAULT_COMPRESSION; private long modificationTime; - private String filename; + private String fileName; private String comment; private int operatingSystem = 255; // Unknown OS by default private int bufferSize = 512; @@ -70,7 +70,7 @@ public int getDeflateStrategy() { } public String getFilename() { - return filename; + return fileName; } public long getModificationTime() { @@ -132,7 +132,7 @@ public void setDeflateStrategy(final int deflateStrategy) { * @param fileName the name of the file without the directory path */ public void setFilename(final String fileName) { - this.filename = fileName; + this.fileName = fileName; } /** diff --git a/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java b/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java index ac5ef468e4b..fae96359695 100644 --- a/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java +++ b/src/main/java/org/apache/commons/compress/utils/FileNameUtils.java @@ -37,13 +37,13 @@ private static String fileNameToExtension(final String name) { } /** - * Gets the basename (i.e. the part up to and not including the - * last ".") of the last path segment of a filename. + * Gets the base name (i.e. the part up to and not including the + * last ".") of the last path segment of a file name. *

Will return the file name itself if it doesn't contain any - * dots. All leading directories of the {@code filename} parameter + * dots. All leading directories of the {@code file name} parameter * are skipped.

- * @return the basename of filename - * @param path the path of the file to obtain the basename of. + * @return the base name of file name + * @param path the path of the file to obtain the base name of. * @since 1.22 */ public static String getBaseName(final Path path) { @@ -55,30 +55,30 @@ public static String getBaseName(final Path path) { } /** - * Gets the basename (i.e. the part up to and not including the - * last ".") of the last path segment of a filename. + * Gets the base name (i.e. the part up to and not including the + * last ".") of the last path segment of a file name. * *

Will return the file name itself if it doesn't contain any - * dots. All leading directories of the {@code filename} parameter + * dots. All leading directories of the {@code file name} parameter * are skipped.

* - * @return the basename of filename - * @param filename the name of the file to obtain the basename of. + * @return the base name of file name + * @param fileName the name of the file to obtain the base name of. */ - public static String getBaseName(final String filename) { - if (filename == null) { + public static String getBaseName(final String fileName) { + if (fileName == null) { return null; } - return fileNameToBaseName(new File(filename).getName()); + return fileNameToBaseName(new File(fileName).getName()); } /** * Gets the extension (i.e. the part after the last ".") of a file. *

Will return an empty string if the file name doesn't contain * any dots. Only the last segment of a the file name is consulted - * - i.e. all leading directories of the {@code filename} + * - i.e. all leading directories of the {@code file name} * parameter are skipped.

- * @return the extension of filename + * @return the extension of file name * @param path the path of the file to obtain the extension of. * @since 1.22 */ @@ -95,16 +95,16 @@ public static String getExtension(final Path path) { * *

Will return an empty string if the file name doesn't contain * any dots. Only the last segment of a the file name is consulted - * - i.e. all leading directories of the {@code filename} + * - i.e. all leading directories of the {@code fileName} * parameter are skipped.

* - * @return the extension of filename - * @param filename the name of the file to obtain the extension of. + * @return the extension of file name + * @param fileName the name of the file to obtain the extension of. */ - public static String getExtension(final String filename) { - if (filename == null) { + public static String getExtension(final String fileName) { + if (fileName == null) { return null; } - return fileNameToExtension(new File(filename).getName()); + return fileNameToExtension(new File(fileName).getName()); } } diff --git a/src/test/java/org/apache/commons/compress/AbstractTestCase.java b/src/test/java/org/apache/commons/compress/AbstractTestCase.java index f92a29e6863..d06cfe6ea36 100644 --- a/src/test/java/org/apache/commons/compress/AbstractTestCase.java +++ b/src/test/java/org/apache/commons/compress/AbstractTestCase.java @@ -146,18 +146,18 @@ public static boolean tryHardToDelete(final Path f) { * Add an entry to the archive, and keep track of the names in archiveList. * * @param out - * @param filename + * @param fileName * @param infile * @throws IOException * @throws FileNotFoundException */ - private void addArchiveEntry(final ArchiveOutputStream out, final String filename, final File infile) + private void addArchiveEntry(final ArchiveOutputStream out, final String fileName, final File infile) throws IOException, FileNotFoundException { - final ArchiveEntry entry = out.createArchiveEntry(infile, filename); + final ArchiveEntry entry = out.createArchiveEntry(infile, fileName); out.putArchiveEntry(entry); Files.copy(infile.toPath(), out); out.closeArchiveEntry(); - archiveList.add(filename); + archiveList.add(fileName); } /** diff --git a/src/test/java/org/apache/commons/compress/ArchiveReadTest.java b/src/test/java/org/apache/commons/compress/ArchiveReadTest.java index 98091e78c0d..e3b62dff77c 100644 --- a/src/test/java/org/apache/commons/compress/ArchiveReadTest.java +++ b/src/test/java/org/apache/commons/compress/ArchiveReadTest.java @@ -80,7 +80,7 @@ public static void setUpFileList() throws Exception { } } - // files.txt contains size and filename + // files.txt contains size and file name @Override protected String getExpectedString(final ArchiveEntry entry) { return entry.getSize() + " " + entry.getName(); diff --git a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java index d896c6e67eb..22e74c26c91 100644 --- a/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java +++ b/src/test/java/org/apache/commons/compress/archivers/memory/MemoryArchiveInputStream.java @@ -25,18 +25,18 @@ public final class MemoryArchiveInputStream extends ArchiveInputStream { - private final String[] filenames; + private final String[] fileNames; private final String[] content; private int p; public MemoryArchiveInputStream( final String[][] pFiles ) { final int pFilesLength = pFiles.length; - filenames = new String[pFilesLength]; + fileNames = new String[pFilesLength]; content = new String[pFilesLength]; for (int i = 0; i < pFilesLength; i++) { final String[] nameAndContent = pFiles[i]; - filenames[i] = nameAndContent[0]; + fileNames[i] = nameAndContent[0]; content[i] = nameAndContent[1]; } p = 0; @@ -44,11 +44,11 @@ public MemoryArchiveInputStream( final String[][] pFiles ) { @Override public ArchiveEntry getNextEntry() throws IOException { - if (p >= filenames.length) { + if (p >= fileNames.length) { return null; } - return new MemoryArchiveEntry(filenames[p]); + return new MemoryArchiveEntry(fileNames[p]); } @Override diff --git a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java index c7176141d74..5747470ce33 100644 --- a/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/sevenz/SevenZFileTest.java @@ -89,8 +89,8 @@ private void assertDates(final SevenZArchiveEntry entry, final String modified, SevenZArchiveEntry::getCreationTime, SevenZArchiveEntry::getCreationDate); } - private void checkHelloWorld(final String filename) throws Exception { - try (SevenZFile sevenZFile = new SevenZFile(getFile(filename))) { + private void checkHelloWorld(final String fileName) throws Exception { + try (SevenZFile sevenZFile = new SevenZFile(getFile(fileName))) { final SevenZArchiveEntry entry = sevenZFile.getNextEntry(); assertEquals("Hello world.txt", entry.getName()); assertDates(entry, "2013-05-07T19:40:48Z", null, null); diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java index 4f080368e67..57f6a1b77a3 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ExplodeSupportTest.java @@ -38,8 +38,8 @@ public class ExplodeSupportTest { - private void testArchiveWithImplodeCompression(final String filename, final String entryName) throws IOException { - try (ZipFile zip = new ZipFile(new File(filename))) { + private void testArchiveWithImplodeCompression(final String fileName, final String entryName) throws IOException { + try (ZipFile zip = new ZipFile(new File(fileName))) { final ZipArchiveEntry entry = zip.getEntries().nextElement(); assertEquals(entryName, entry.getName(), "entry name"); assertTrue(zip.canReadEntryData(entry), "entry can't be read"); @@ -84,8 +84,8 @@ public void testTikaTestStream() throws IOException { testZipStreamWithImplodeCompression("target/test-classes/moby-imploded.zip", "README"); } - private void testZipStreamWithImplodeCompression(final String filename, final String entryName) throws IOException { - try (ZipArchiveInputStream zin = new ZipArchiveInputStream(Files.newInputStream(new File(filename).toPath()))) { + private void testZipStreamWithImplodeCompression(final String fileName, final String entryName) throws IOException { + try (ZipArchiveInputStream zin = new ZipArchiveInputStream(Files.newInputStream(new File(fileName).toPath()))) { final ZipArchiveEntry entry = zin.getNextZipEntry(); assertEquals(entryName, entry.getName(), "entry name"); assertTrue(zin.canReadEntryData(entry), "entry can't be read"); diff --git a/src/test/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStreamTest.java b/src/test/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStreamTest.java index 75cf1f6ba4c..1cb4dd6fd25 100644 --- a/src/test/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStreamTest.java +++ b/src/test/java/org/apache/commons/compress/compressors/brotli/BrotliCompressorInputStreamTest.java @@ -76,7 +76,7 @@ public void singleByteReadConsistentlyReturnsMinusOneAtEof() throws IOException public void singleByteReadWorksAsExpected() throws IOException { try (InputStream is = newInputStream("brotli.testdata.compressed"); final BrotliCompressorInputStream in = new BrotliCompressorInputStream(is)) { - // starts with filename "XXX" + // starts with file name "XXX" assertEquals('X', in.read()); } }