mirror of
https://github.com/revanced/Apktool.git
synced 2024-12-11 21:37:47 +01:00
Code smell reduction (#2554)
* Correct use of <> diamond operator * Correct modifiers order * Private constructor for utility class * Correct use of diamond operator * Corrected naming convention * Correct modifier order * Use not synchronized class * Introduced try/resource in stream copy * Removed unused private field * Code reformat Reformat of IOUtils.copy from to stream * Add a space Improved code formatting * Code reformat Only a new space * Code reformat Removed extra spaces
This commit is contained in:
parent
baf8bb592a
commit
b3741409f5
@ -44,7 +44,7 @@ public abstract class AbstractDirectory implements Directory {
|
|||||||
return mFiles;
|
return mFiles;
|
||||||
}
|
}
|
||||||
if (mFilesRecursive == null) {
|
if (mFilesRecursive == null) {
|
||||||
mFilesRecursive = new LinkedHashSet<String>(mFiles);
|
mFilesRecursive = new LinkedHashSet<>(mFiles);
|
||||||
for (Map.Entry<String, ? extends Directory> dir : getAbstractDirs().entrySet()) {
|
for (Map.Entry<String, ? extends Directory> dir : getAbstractDirs().entrySet()) {
|
||||||
for (String path : dir.getValue().getFiles(true)) {
|
for (String path : dir.getValue().getFiles(true)) {
|
||||||
mFilesRecursive.add(dir.getKey() + separator + path);
|
mFilesRecursive.add(dir.getKey() + separator + path);
|
||||||
@ -93,7 +93,7 @@ public abstract class AbstractDirectory implements Directory {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Directory> getDirs(boolean recursive)
|
public Map<String, Directory> getDirs(boolean recursive)
|
||||||
throws UnsupportedOperationException {
|
throws UnsupportedOperationException {
|
||||||
return new LinkedHashMap<String, Directory>(getAbstractDirs(recursive));
|
return new LinkedHashMap<>(getAbstractDirs(recursive));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -225,7 +225,7 @@ public abstract class AbstractDirectory implements Directory {
|
|||||||
return mDirs;
|
return mDirs;
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String, AbstractDirectory> dirs = new LinkedHashMap<String, AbstractDirectory>(mDirs);
|
Map<String, AbstractDirectory> dirs = new LinkedHashMap<>(mDirs);
|
||||||
for (Map.Entry<String, AbstractDirectory> dir : getAbstractDirs().entrySet()) {
|
for (Map.Entry<String, AbstractDirectory> dir : getAbstractDirs().entrySet()) {
|
||||||
for (Map.Entry<String, AbstractDirectory> subdir : dir.getValue().getAbstractDirs(
|
for (Map.Entry<String, AbstractDirectory> subdir : dir.getValue().getAbstractDirs(
|
||||||
true).entrySet()) {
|
true).entrySet()) {
|
||||||
@ -260,15 +260,15 @@ public abstract class AbstractDirectory implements Directory {
|
|||||||
return new ParsedPath(path.substring(0, pos), path.substring(pos + 1));
|
return new ParsedPath(path.substring(0, pos), path.substring(pos + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract protected void loadFiles();
|
protected abstract void loadFiles();
|
||||||
abstract protected void loadDirs();
|
protected abstract void loadDirs();
|
||||||
abstract protected InputStream getFileInputLocal(String name)
|
protected abstract InputStream getFileInputLocal(String name)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
abstract protected OutputStream getFileOutputLocal(String name)
|
protected abstract OutputStream getFileOutputLocal(String name)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
abstract protected AbstractDirectory createDirLocal(String name)
|
protected abstract AbstractDirectory createDirLocal(String name)
|
||||||
throws DirectoryException;
|
throws DirectoryException;
|
||||||
abstract protected void removeFileLocal(String name);
|
protected abstract void removeFileLocal(String name);
|
||||||
|
|
||||||
|
|
||||||
private class ParsedPath {
|
private class ParsedPath {
|
||||||
|
@ -28,6 +28,10 @@ import java.util.logging.Logger;
|
|||||||
public class DirUtil {
|
public class DirUtil {
|
||||||
private static final Logger LOGGER = Logger.getLogger("");
|
private static final Logger LOGGER = Logger.getLogger("");
|
||||||
|
|
||||||
|
private DirUtil() {
|
||||||
|
// Private constructor for utility class
|
||||||
|
}
|
||||||
|
|
||||||
public static void copyToDir(Directory in, Directory out)
|
public static void copyToDir(Directory in, Directory out)
|
||||||
throws DirectoryException {
|
throws DirectoryException {
|
||||||
for (String fileName : in.getFiles(true)) {
|
for (String fileName : in.getFiles(true)) {
|
||||||
|
@ -31,6 +31,10 @@ public class ZipUtils {
|
|||||||
|
|
||||||
private static Collection<String> mDoNotCompress;
|
private static Collection<String> mDoNotCompress;
|
||||||
|
|
||||||
|
private ZipUtils() {
|
||||||
|
// Private constructor for utility class
|
||||||
|
}
|
||||||
|
|
||||||
public static void zipFolders(final File folder, final File zip, final File assets, final Collection<String> doNotCompress)
|
public static void zipFolders(final File folder, final File zip, final File assets, final Collection<String> doNotCompress)
|
||||||
throws BrutException, IOException {
|
throws BrutException, IOException {
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ package brut.util;
|
|||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
abstract public class DataInputDelegate implements DataInput {
|
public abstract class DataInputDelegate implements DataInput {
|
||||||
protected final DataInput mDelegate;
|
protected final DataInput mDelegate;
|
||||||
|
|
||||||
public DataInputDelegate(DataInput delegate) {
|
public DataInputDelegate(DataInput delegate) {
|
||||||
|
@ -21,14 +21,11 @@ import org.apache.commons.io.IOUtils;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
import java.util.concurrent.ThreadLocalRandom;
|
||||||
|
|
||||||
abstract public class Jar {
|
public abstract class Jar {
|
||||||
private final static Set<String> mLoaded = new HashSet<String>();
|
private static final Map<String, File> mExtracted = new HashMap<>();
|
||||||
private final static Map<String, File> mExtracted = new HashMap<String, File>();
|
|
||||||
|
|
||||||
public static File getResourceAsFile(String name, Class clazz) throws BrutException {
|
public static File getResourceAsFile(String name, Class clazz) throws BrutException {
|
||||||
File file = mExtracted.get(name);
|
File file = mExtracted.get(name);
|
||||||
|
@ -72,11 +72,11 @@ public class OS {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
InputStream in = new FileInputStream(file);
|
try (InputStream in = new FileInputStream(file)) {
|
||||||
OutputStream out = new FileOutputStream(destFile);
|
try (OutputStream out = new FileOutputStream(destFile)) {
|
||||||
IOUtils.copy(in, out);
|
IOUtils.copy(in, out);
|
||||||
in.close();
|
}
|
||||||
out.close();
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new BrutException("Could not copy file: " + file, ex);
|
throw new BrutException("Could not copy file: " + file, ex);
|
||||||
}
|
}
|
||||||
@ -173,7 +173,7 @@ public class OS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class StreamCollector implements Runnable {
|
static class StreamCollector implements Runnable {
|
||||||
private final StringBuffer buffer = new StringBuffer();
|
private final StringBuilder buffer = new StringBuilder();
|
||||||
private final InputStream inputStream;
|
private final InputStream inputStream;
|
||||||
|
|
||||||
public StreamCollector(InputStream inputStream) {
|
public StreamCollector(InputStream inputStream) {
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
package brut.util;
|
package brut.util;
|
||||||
|
|
||||||
public class OSDetection {
|
public class OSDetection {
|
||||||
private static String OS = System.getProperty("os.name").toLowerCase();
|
private static final String OS = System.getProperty("os.name").toLowerCase();
|
||||||
private static String Bit = System.getProperty("sun.arch.data.model").toLowerCase();
|
private static final String BIT = System.getProperty("sun.arch.data.model").toLowerCase();
|
||||||
|
|
||||||
public static boolean isWindows() {
|
public static boolean isWindows() {
|
||||||
return (OS.contains("win"));
|
return (OS.contains("win"));
|
||||||
@ -39,7 +39,7 @@ public class OSDetection {
|
|||||||
|
|
||||||
return arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64");
|
return arch != null && arch.endsWith("64") || wow64Arch != null && wow64Arch.endsWith("64");
|
||||||
}
|
}
|
||||||
return Bit.equalsIgnoreCase("64");
|
return BIT.equalsIgnoreCase("64");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String returnOS() {
|
public static String returnOS() {
|
||||||
|
Loading…
Reference in New Issue
Block a user