Fixed code style

This commit is contained in:
Jindra Petřík
2024-08-05 11:17:25 +02:00
parent cc34fae1c5
commit 1d9329e9be
363 changed files with 8559 additions and 8277 deletions
@@ -20,8 +20,9 @@ import java.io.IOException;
import java.io.InputStream;
/**
* Special MemoryInputStream that is not a MemoryInputStream in fact.
* Input stream to handle some edge cases
* Special MemoryInputStream that is not a MemoryInputStream in fact. Input
* stream to handle some edge cases
*
* @author JPEXS
*/
public class FakeMemoryInputStream extends MemoryInputStream {
@@ -29,12 +30,12 @@ public class FakeMemoryInputStream extends MemoryInputStream {
private long pos;
private final int maxLength;
private final InputStream is;
public FakeMemoryInputStream(InputStream is) throws IOException {
super(new byte[0]);
this.maxLength = Integer.MAX_VALUE;
this.maxLength = Integer.MAX_VALUE;
this.is = is;
}
@@ -63,7 +64,7 @@ public class FakeMemoryInputStream extends MemoryInputStream {
@Override
public int read() throws IOException {
if (pos < maxLength) {
if (pos < maxLength) {
pos++;
return is.read();
}
@@ -129,7 +129,7 @@ public class Helper {
}
sb.append("]");
return sb.toString();
}
}
/**
* Formats specified address to four numbers xxxx (or five numbers when
@@ -596,7 +596,7 @@ public class Helper {
public static String byteToHex(byte b) {
return hexStringCache[b & 0xff];
}
}
public static String format(String str, int len) {
if (len <= str.length()) {
@@ -787,15 +787,15 @@ public class Helper {
return baos.toByteArray();
}
public static void copyStreamEx(InputStream is, OutputStream os) throws IOException {
public static void copyStreamEx(InputStream is, OutputStream os) throws IOException {
final int bufSize = 4096;
byte[] buf = new byte[bufSize];
int cnt = 0;
while ((cnt = is.read(buf)) > 0) {
os.write(buf, 0, cnt);
}
}
}
public static void copyStream(InputStream is, OutputStream os) {
try {
final int bufSize = 4096;
@@ -1079,7 +1079,7 @@ public class Helper {
public static String bytesToHexString(byte[] bytes) {
return bytesToHexString(bytes, 0);
}
public static String bytesToHexString(byte[] bytes, int start) {
StringBuilder sb = new StringBuilder();
if (start < bytes.length) {
@@ -1109,7 +1109,7 @@ public class Helper {
}
return sb.toString();
}
public static String byteArrayToHex(byte[] data) {
StringBuilder sb = new StringBuilder(data.length * 2);
for (byte b : data) {
@@ -1118,7 +1118,7 @@ public class Helper {
return sb.toString();
}
public static GraphTextWriter byteArrayToHex(GraphTextWriter writer, byte[] data, int bytesPerRow, int groupSize, boolean addChars, boolean showAddress) {
/* // hex data from decompiled actions
@@ -1328,7 +1328,7 @@ public class Helper {
}
return ret.toString();
}
StringBuilder ret = new StringBuilder(s.length());
for (int i = 0; i < s.length(); i++) {
char c = s.charAt(i);
@@ -25,25 +25,27 @@ import java.util.Set;
/**
* Identity hash set which maintains insertion order.
*
* @author JPEXS
* @param <E>
*/
public class LinkedIdentityHashSet<E> implements Set<E> {
private class MyObj {
private final Object obj;
public MyObj(Object obj) {
this.obj = obj;
}
}
@Override
public int hashCode() {
return System.identityHashCode(obj);
}
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
public boolean equals(Object obj) {
if (this == obj) {
return true;
@@ -56,18 +58,18 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
}
final MyObj other = (MyObj) obj;
return this.obj == other.obj;
}
}
}
private final Set<MyObj> set = new LinkedHashSet<>();
public LinkedIdentityHashSet() {
}
public LinkedIdentityHashSet(Collection<? extends E> c) {
addAll(c);
}
@Override
public int size() {
return set.size();
@@ -76,7 +78,7 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
@Override
public boolean isEmpty() {
return set.isEmpty();
}
}
@Override
public boolean contains(Object o) {
@@ -85,7 +87,7 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
@Override
public Iterator<E> iterator() {
final Iterator<MyObj> setIterator = set.iterator();
final Iterator<MyObj> setIterator = set.iterator();
return new Iterator<E>() {
@Override
public boolean hasNext() {
@@ -93,7 +95,7 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
public E next() {
return (E) setIterator.next().obj;
}
@@ -109,9 +111,9 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
}
return objs;
}
@Override
@SuppressWarnings("unchecked")
@SuppressWarnings("unchecked")
public <T> T[] toArray(T[] a) {
T[] ret = prepareArray(a);
Object[] objs = set.toArray();
@@ -120,7 +122,7 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
}
return ret;
}
@SuppressWarnings("unchecked")
private <T> T[] prepareArray(T[] a) {
int size = this.set.size();
@@ -135,7 +137,7 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
@Override
public boolean add(E e) {
return set.add(new MyObj(e));
return set.add(new MyObj(e));
}
@Override
@@ -188,5 +190,5 @@ public class LinkedIdentityHashSet<E> implements Set<E> {
@Override
public void clear() {
set.clear();
}
}
}
@@ -62,7 +62,7 @@ public class MD5Crypt {
sb.append(SALT_CHARS.charAt(rnd.nextInt(SALT_CHARS.length())));
}
return sb.toString();
}
}
public static String cryptApache(String password, int saltLength) {
return crypt(password, generateSalt(saltLength), MAGIC_APACHE);
@@ -71,7 +71,7 @@ public class MD5Crypt {
public static String cryptApache(String password, String salt) {
return crypt(password, salt, MAGIC_APACHE);
}
public static String crypt(String password, int saltLength, String magic) {
return crypt(password, generateSalt(saltLength), magic);
}
@@ -79,7 +79,7 @@ public class MD5Crypt {
public static String crypt(String password, int saltLength) {
return crypt(password, generateSalt(saltLength), MAGIC);
}
public static String crypt(String password, String salt) {
return crypt(password, salt, MAGIC);
}
@@ -27,5 +27,5 @@ public class NulStream extends OutputStream {
@Override
public void write(int i) {
}
}
}
@@ -106,9 +106,9 @@ public class Utf8Helper {
public static String stripEscapes(String string) {
return string.replaceAll("\\{invalid_utf8=[0-9]+\\}", "")
.replaceAll("\\{\\+(\\+*invalid_utf8=[0-9]+)\\}", "{$1}");
.replaceAll("\\{\\+(\\+*invalid_utf8=[0-9]+)\\}", "{$1}");
}
public static byte[] getBytes(String string) {
if (!string.contains("invalid_utf8")) {
return string.getBytes(charset);
@@ -119,7 +119,7 @@ public class Utf8Helper {
try {
Pattern invPattern = Pattern.compile("^(\\{invalid_utf8[=:]([0-9]+)\\}).*", Pattern.DOTALL);
for (int i = 0; i < string.length(); i++) {
char c = string.charAt(i);
char c = string.charAt(i);
if (c == '{') {
String subStr = string.substring(i);
if (!subStr.isEmpty() && subStr.charAt(0) == '+') {
@@ -127,7 +127,7 @@ public class Utf8Helper {
i++;
continue;
}
Matcher m = invPattern.matcher(subStr);
if (m.matches()) {
int v = Integer.parseInt(m.group(2));
@@ -136,7 +136,7 @@ public class Utf8Helper {
i--;
continue;
}
}
baos.write(("" + c).getBytes(charset));
}
@@ -150,7 +150,7 @@ public class Utf8Helper {
public static int getBytesLength(String string) {
// todo: make it faster without actually writing it to an array
return getBytes(string).length;
}
}
private static String escapeInvalidUtf8Char(int v) {
//Note: for writing the string "{invalid_utf8=xxx}" itself, you can escape it with "{+invalid_utf8=xxx}"
@@ -160,7 +160,7 @@ public class Utf8Helper {
public static String decode(byte[] data) {
return decode(data, 0, data.length);
}
public static String decode(byte[] data, int start, int length) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
try {
@@ -21,7 +21,7 @@ import java.nio.charset.Charset;
public class ShiftJis extends AbstractCharsetConverter {
private static final Charset SHIFT_JIS_ENCODING = Charset.forName("Shift_JIS");
@Override
public int toUnicode(int codePoint) {
byte[] b;
@@ -31,19 +31,18 @@ public class ShiftJis extends AbstractCharsetConverter {
b = new byte[]{(byte) codePoint};
}
return new String(b, SHIFT_JIS_ENCODING).charAt(0);
}
@Override
public int fromUnicode(int codePoint) {
public int fromUnicode(int codePoint) {
byte[] b = ("" + (char) codePoint).getBytes(SHIFT_JIS_ENCODING);
int r = 0;
for (int i = 0; i < b.length; i++) {
int v = b[b.length - 1 - i] & 0xff;
r = r + (v << (8 * i));
}
return r;
return r;
}
}