Unify method visibility of private classes
Apply checkstyle rule to ensure that private and package private classes do not have unnecessary public methods. Test classes have also been unified as much as possible to use default scoped inner-classes. Closes gh-7316
This commit is contained in:
@@ -225,7 +225,7 @@ public class ExplodedArchive implements Archive {
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public File getFile() {
|
||||
File getFile() {
|
||||
return this.file;
|
||||
}
|
||||
|
||||
|
||||
@@ -207,7 +207,7 @@ public class JarFileArchive implements Archive {
|
||||
this.jarEntry = jarEntry;
|
||||
}
|
||||
|
||||
public JarEntry getJarEntry() {
|
||||
JarEntry getJarEntry() {
|
||||
return this.jarEntry;
|
||||
}
|
||||
|
||||
|
||||
@@ -164,7 +164,7 @@ public class RandomAccessDataFile implements RandomAccessData {
|
||||
* {@code b} is {@code null}. Returns -1 when the end of the stream is reached
|
||||
* @throws IOException in case of I/O errors
|
||||
*/
|
||||
public int doRead(byte[] b, int off, int len) throws IOException {
|
||||
int doRead(byte[] b, int off, int len) throws IOException {
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -77,11 +77,11 @@ final class AsciiBytes {
|
||||
this.length = length;
|
||||
}
|
||||
|
||||
public int length() {
|
||||
int length() {
|
||||
return this.length;
|
||||
}
|
||||
|
||||
public boolean startsWith(AsciiBytes prefix) {
|
||||
boolean startsWith(AsciiBytes prefix) {
|
||||
if (this == prefix) {
|
||||
return true;
|
||||
}
|
||||
@@ -96,7 +96,7 @@ final class AsciiBytes {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean endsWith(AsciiBytes postfix) {
|
||||
boolean endsWith(AsciiBytes postfix) {
|
||||
if (this == postfix) {
|
||||
return true;
|
||||
}
|
||||
@@ -112,11 +112,11 @@ final class AsciiBytes {
|
||||
return true;
|
||||
}
|
||||
|
||||
public AsciiBytes substring(int beginIndex) {
|
||||
AsciiBytes substring(int beginIndex) {
|
||||
return substring(beginIndex, this.length);
|
||||
}
|
||||
|
||||
public AsciiBytes substring(int beginIndex, int endIndex) {
|
||||
AsciiBytes substring(int beginIndex, int endIndex) {
|
||||
int length = endIndex - beginIndex;
|
||||
if (this.offset + length > this.bytes.length) {
|
||||
throw new IndexOutOfBoundsException();
|
||||
@@ -124,7 +124,7 @@ final class AsciiBytes {
|
||||
return new AsciiBytes(this.bytes, this.offset + beginIndex, length);
|
||||
}
|
||||
|
||||
public boolean matches(CharSequence name, char suffix) {
|
||||
boolean matches(CharSequence name, char suffix) {
|
||||
int charIndex = 0;
|
||||
int nameLen = name.length();
|
||||
int totalLen = nameLen + ((suffix != 0) ? 1 : 0);
|
||||
@@ -239,7 +239,7 @@ final class AsciiBytes {
|
||||
return new String(bytes, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static int hashCode(CharSequence charSequence) {
|
||||
static int hashCode(CharSequence charSequence) {
|
||||
// We're compatible with String's hashCode()
|
||||
if (charSequence instanceof StringSequence) {
|
||||
// ... but save making an unnecessary String for StringSequence
|
||||
@@ -248,7 +248,7 @@ final class AsciiBytes {
|
||||
return charSequence.toString().hashCode();
|
||||
}
|
||||
|
||||
public static int hashCode(int hash, char suffix) {
|
||||
static int hashCode(int hash, char suffix) {
|
||||
return (suffix != 0) ? (31 * hash + suffix) : hash;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -26,7 +26,7 @@ final class Bytes {
|
||||
private Bytes() {
|
||||
}
|
||||
|
||||
public static long littleEndianValue(byte[] bytes, int offset, int length) {
|
||||
static long littleEndianValue(byte[] bytes, int offset, int length) {
|
||||
long value = 0;
|
||||
for (int i = length - 1; i >= 0; i--) {
|
||||
value = ((value << 8) | (bytes[offset + i] & 0xFF));
|
||||
|
||||
@@ -92,7 +92,7 @@ class CentralDirectoryEndRecord {
|
||||
* @param data the source data
|
||||
* @return the offset within the data where the archive begins
|
||||
*/
|
||||
public long getStartOfArchive(RandomAccessData data) {
|
||||
long getStartOfArchive(RandomAccessData data) {
|
||||
long length = Bytes.littleEndianValue(this.block, this.offset + 12, 4);
|
||||
long specifiedOffset = Bytes.littleEndianValue(this.block, this.offset + 16, 4);
|
||||
long actualOffset = data.getSize() - this.size - length;
|
||||
@@ -105,7 +105,7 @@ class CentralDirectoryEndRecord {
|
||||
* @param data the source data
|
||||
* @return the central directory data
|
||||
*/
|
||||
public RandomAccessData getCentralDirectory(RandomAccessData data) {
|
||||
RandomAccessData getCentralDirectory(RandomAccessData data) {
|
||||
long offset = Bytes.littleEndianValue(this.block, this.offset + 16, 4);
|
||||
long length = Bytes.littleEndianValue(this.block, this.offset + 12, 4);
|
||||
return data.getSubsection(offset, length);
|
||||
@@ -115,7 +115,7 @@ class CentralDirectoryEndRecord {
|
||||
* Return the number of ZIP entries in the file.
|
||||
* @return the number of records in the zip
|
||||
*/
|
||||
public int getNumberOfRecords() {
|
||||
int getNumberOfRecords() {
|
||||
long numberOfRecords = Bytes.littleEndianValue(this.block, this.offset + 10, 2);
|
||||
if (numberOfRecords == 0xFFFF) {
|
||||
throw new IllegalStateException("Zip64 archives are not supported");
|
||||
|
||||
@@ -93,7 +93,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
}
|
||||
}
|
||||
|
||||
public AsciiBytes getName() {
|
||||
AsciiBytes getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
return this.name.matches(name, suffix);
|
||||
}
|
||||
|
||||
public boolean isDirectory() {
|
||||
boolean isDirectory() {
|
||||
return this.name.endsWith(SLASH);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
return (int) Bytes.littleEndianValue(this.header, this.headerOffset + 10, 2);
|
||||
}
|
||||
|
||||
public long getTime() {
|
||||
long getTime() {
|
||||
long datetime = Bytes.littleEndianValue(this.header, this.headerOffset + 12, 4);
|
||||
return decodeMsDosFormatDateTime(datetime);
|
||||
}
|
||||
@@ -130,7 +130,7 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
return localDateTime.toEpochSecond(ZoneId.systemDefault().getRules().getOffset(localDateTime)) * 1000;
|
||||
}
|
||||
|
||||
public long getCrc() {
|
||||
long getCrc() {
|
||||
return Bytes.littleEndianValue(this.header, this.headerOffset + 16, 4);
|
||||
}
|
||||
|
||||
@@ -144,15 +144,15 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
return Bytes.littleEndianValue(this.header, this.headerOffset + 24, 4);
|
||||
}
|
||||
|
||||
public byte[] getExtra() {
|
||||
byte[] getExtra() {
|
||||
return this.extra;
|
||||
}
|
||||
|
||||
public boolean hasExtra() {
|
||||
boolean hasExtra() {
|
||||
return this.extra.length > 0;
|
||||
}
|
||||
|
||||
public AsciiBytes getComment() {
|
||||
AsciiBytes getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
@@ -168,8 +168,8 @@ final class CentralDirectoryFileHeader implements FileHeader {
|
||||
return new CentralDirectoryFileHeader(header, 0, this.name, header, this.comment, this.localHeaderOffset);
|
||||
}
|
||||
|
||||
public static CentralDirectoryFileHeader fromRandomAccessData(RandomAccessData data, int offset,
|
||||
JarEntryFilter filter) throws IOException {
|
||||
static CentralDirectoryFileHeader fromRandomAccessData(RandomAccessData data, int offset, JarEntryFilter filter)
|
||||
throws IOException {
|
||||
CentralDirectoryFileHeader fileHeader = new CentralDirectoryFileHeader();
|
||||
byte[] bytes = data.read(offset, 46);
|
||||
fileHeader.load(bytes, 0, data, offset, filter);
|
||||
|
||||
@@ -35,7 +35,7 @@ class CentralDirectoryParser {
|
||||
|
||||
private final List<CentralDirectoryVisitor> visitors = new ArrayList<>();
|
||||
|
||||
public <T extends CentralDirectoryVisitor> T addVisitor(T visitor) {
|
||||
<T extends CentralDirectoryVisitor> T addVisitor(T visitor) {
|
||||
this.visitors.add(visitor);
|
||||
return visitor;
|
||||
}
|
||||
@@ -47,7 +47,7 @@ class CentralDirectoryParser {
|
||||
* @return the actual archive data without any prefix bytes
|
||||
* @throws IOException on error
|
||||
*/
|
||||
public RandomAccessData parse(RandomAccessData data, boolean skipPrefixBytes) throws IOException {
|
||||
RandomAccessData parse(RandomAccessData data, boolean skipPrefixBytes) throws IOException {
|
||||
CentralDirectoryEndRecord endRecord = new CentralDirectoryEndRecord(data);
|
||||
if (skipPrefixBytes) {
|
||||
data = getArchiveData(endRecord, data);
|
||||
|
||||
@@ -195,20 +195,20 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
return new EntryIterator();
|
||||
}
|
||||
|
||||
public boolean containsEntry(CharSequence name) {
|
||||
boolean containsEntry(CharSequence name) {
|
||||
return getEntry(name, FileHeader.class, true) != null;
|
||||
}
|
||||
|
||||
public JarEntry getEntry(CharSequence name) {
|
||||
JarEntry getEntry(CharSequence name) {
|
||||
return getEntry(name, JarEntry.class, true);
|
||||
}
|
||||
|
||||
public InputStream getInputStream(String name) throws IOException {
|
||||
InputStream getInputStream(String name) throws IOException {
|
||||
FileHeader entry = getEntry(name, FileHeader.class, false);
|
||||
return getInputStream(entry);
|
||||
}
|
||||
|
||||
public InputStream getInputStream(FileHeader entry) throws IOException {
|
||||
InputStream getInputStream(FileHeader entry) throws IOException {
|
||||
if (entry == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -219,7 +219,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
return inputStream;
|
||||
}
|
||||
|
||||
public RandomAccessData getEntryData(String name) throws IOException {
|
||||
RandomAccessData getEntryData(String name) throws IOException {
|
||||
FileHeader entry = getEntry(name, FileHeader.class, false);
|
||||
if (entry == null) {
|
||||
return null;
|
||||
@@ -336,7 +336,7 @@ class JarFileEntries implements CentralDirectoryVisitor, Iterable<JarEntry> {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void clearCache() {
|
||||
void clearCache() {
|
||||
this.entriesCache.clear();
|
||||
}
|
||||
|
||||
|
||||
@@ -377,7 +377,7 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return ((char) ((hi << 4) + lo));
|
||||
}
|
||||
|
||||
public CharSequence toCharSequence() {
|
||||
CharSequence toCharSequence() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
@@ -386,11 +386,11 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return this.name.toString();
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
boolean isEmpty() {
|
||||
return this.name.isEmpty();
|
||||
}
|
||||
|
||||
public String getContentType() {
|
||||
String getContentType() {
|
||||
if (this.contentType == null) {
|
||||
this.contentType = deduceContentType();
|
||||
}
|
||||
@@ -405,11 +405,11 @@ final class JarURLConnection extends java.net.JarURLConnection {
|
||||
return type;
|
||||
}
|
||||
|
||||
public static JarEntryName get(StringSequence spec) {
|
||||
static JarEntryName get(StringSequence spec) {
|
||||
return get(spec, 0);
|
||||
}
|
||||
|
||||
public static JarEntryName get(StringSequence spec, int beginIndex) {
|
||||
static JarEntryName get(StringSequence spec, int beginIndex) {
|
||||
if (spec.length() <= beginIndex) {
|
||||
return EMPTY_JAR_ENTRY_NAME;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012-2018 the original author or authors.
|
||||
* Copyright 2012-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -52,7 +52,7 @@ final class StringSequence implements CharSequence {
|
||||
this.end = end;
|
||||
}
|
||||
|
||||
public StringSequence subSequence(int start) {
|
||||
StringSequence subSequence(int start) {
|
||||
return subSequence(start, length());
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ final class StringSequence implements CharSequence {
|
||||
return new StringSequence(this.source, subSequenceStart, subSequenceEnd);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
boolean isEmpty() {
|
||||
return length() == 0;
|
||||
}
|
||||
|
||||
@@ -86,23 +86,23 @@ final class StringSequence implements CharSequence {
|
||||
return this.source.charAt(this.start + index);
|
||||
}
|
||||
|
||||
public int indexOf(char ch) {
|
||||
int indexOf(char ch) {
|
||||
return this.source.indexOf(ch, this.start) - this.start;
|
||||
}
|
||||
|
||||
public int indexOf(String str) {
|
||||
int indexOf(String str) {
|
||||
return this.source.indexOf(str, this.start) - this.start;
|
||||
}
|
||||
|
||||
public int indexOf(String str, int fromIndex) {
|
||||
int indexOf(String str, int fromIndex) {
|
||||
return this.source.indexOf(str, this.start + fromIndex) - this.start;
|
||||
}
|
||||
|
||||
public boolean startsWith(CharSequence prefix) {
|
||||
boolean startsWith(CharSequence prefix) {
|
||||
return startsWith(prefix, 0);
|
||||
}
|
||||
|
||||
public boolean startsWith(CharSequence prefix, int offset) {
|
||||
boolean startsWith(CharSequence prefix, int offset) {
|
||||
int prefixLength = prefix.length();
|
||||
if (length() - prefixLength - offset < 0) {
|
||||
return false;
|
||||
|
||||
@@ -360,7 +360,7 @@ class PropertiesLauncherTests {
|
||||
};
|
||||
}
|
||||
|
||||
public static class TestLoader extends URLClassLoader {
|
||||
static class TestLoader extends URLClassLoader {
|
||||
|
||||
TestLoader(ClassLoader parent) {
|
||||
super(new URL[0], parent);
|
||||
|
||||
@@ -88,7 +88,7 @@ class CentralDirectoryParserTests {
|
||||
assertThat(headers.hasNext()).isFalse();
|
||||
}
|
||||
|
||||
private static class Collector implements CentralDirectoryVisitor {
|
||||
static class Collector implements CentralDirectoryVisitor {
|
||||
|
||||
private List<CentralDirectoryFileHeader> headers = new ArrayList<>();
|
||||
|
||||
@@ -105,13 +105,13 @@ class CentralDirectoryParserTests {
|
||||
public void visitEnd() {
|
||||
}
|
||||
|
||||
public List<CentralDirectoryFileHeader> getHeaders() {
|
||||
List<CentralDirectoryFileHeader> getHeaders() {
|
||||
return this.headers;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class MockCentralDirectoryVisitor implements CentralDirectoryVisitor {
|
||||
static class MockCentralDirectoryVisitor implements CentralDirectoryVisitor {
|
||||
|
||||
private final List<String> invocations = new ArrayList<>();
|
||||
|
||||
@@ -130,7 +130,7 @@ class CentralDirectoryParserTests {
|
||||
this.invocations.add("visitEnd");
|
||||
}
|
||||
|
||||
public List<String> getInvocations() {
|
||||
List<String> getInvocations() {
|
||||
return this.invocations;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user