Skip to content

Commit

Permalink
Camel-case parameter and internal names
Browse files Browse the repository at this point in the history
Javadoc
  • Loading branch information
garydgregory committed Oct 19, 2023
1 parent 24b54c8 commit 3714fdd
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* Provides stream classes for reading and writing archives using the TAR format.
* <p>
* 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
* <strong>ustar</strong> format and support GNU specific extensions for long filenames that GNU tar itself by now refers to as <strong>oldgnu</strong>.
* <strong>ustar</strong> format and support GNU specific extensions for long file names that GNU tar itself by now refers to as <strong>oldgnu</strong>.
* </p>
*/
package org.apache.commons.compress.archivers.tar;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -70,7 +70,7 @@ public int getDeflateStrategy() {
}

public String getFilename() {
return filename;
return fileName;
}

public long getModificationTime() {
Expand Down Expand Up @@ -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;
}

/**
Expand Down
42 changes: 21 additions & 21 deletions src/main/java/org/apache/commons/compress/utils/FileNameUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
* <p>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.</p>
* @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) {
Expand All @@ -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.
*
* <p>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.</p>
*
* @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.
* <p>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.</p>
* @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
*/
Expand All @@ -95,16 +95,16 @@ public static String getExtension(final Path path) {
*
* <p>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.</p>
*
* @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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,30 @@

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;
}

@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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down

0 comments on commit 3714fdd

Please sign in to comment.