refactor: manual YAML Cleanup (#3229)

* refactor: add missing license headers

* fix: remove unused exceptions

* refactor: remove unused single quote / slash param
This commit is contained in:
Connor Tumbleson 2023-07-29 06:14:40 -04:00 committed by GitHub
parent 6e5d49bd66
commit fe93fd21d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 122 additions and 22 deletions

View File

@ -146,15 +146,13 @@ public class ApkInfo implements YamlSerializable {
}
public static ApkInfo load(InputStream is) throws AndrolibException {
// return getYaml().loadAs(is, ApkInfo.class);
YamlReader reader = new YamlReader(is);
ApkInfo apkInfo = new ApkInfo();
reader.readRoot(apkInfo);
return apkInfo;
}
public static ApkInfo load(File appDir)
throws AndrolibException {
public static ApkInfo load(File appDir) throws AndrolibException {
try(
InputStream in = new FileDirectory(appDir).getFileInput("apktool.yml");
) {

View File

@ -16,14 +16,12 @@
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;
public class PackageInfo implements YamlSerializable {
public String forcedPackageId;
public String renameManifestPackage;
@Override
public void readItem(YamlReader reader) throws AndrolibException {
public void readItem(YamlReader reader) {
YamlLine line = reader.getLine();
switch (line.getKey()) {
case "forcedPackageId": {
@ -42,5 +40,4 @@ public class PackageInfo implements YamlSerializable {
writer.writeString("forcedPackageId", forcedPackageId);
writer.writeString("renameManifestPackage", renameManifestPackage);
}
}

View File

@ -16,14 +16,12 @@
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;
public class VersionInfo implements YamlSerializable {
public String versionCode;
public String versionName;
@Override
public void readItem(YamlReader reader) throws AndrolibException {
public void readItem(YamlReader reader) {
YamlLine line = reader.getLine();
switch (line.getKey()) {
case "versionCode": {

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import java.util.Objects;

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;

View File

@ -26,22 +26,20 @@ import java.io.Writer;
public class YamlStringEscapeUtils {
public static String escapeString(String str) {
return escapeJavaStyleString(str, false, false);
return escapeJavaStyleString(str);
}
/**
* @param str String to escape values in, may be null
* @param escapeSingleQuotes escapes single quotes if <code>true</code>
* @param escapeForwardSlash TODO
* @return the escaped string
*/
private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
private static String escapeJavaStyleString(String str) {
if (str == null) {
return null;
}
try {
StringWriter writer = new StringWriter(str.length() * 2);
escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
escapeJavaStyleString(writer, str);
return writer.toString();
} catch (IOException ioe) {
// this should never ever happen while writing to a StringWriter
@ -50,14 +48,11 @@ public class YamlStringEscapeUtils {
}
/**
* @param out write to receieve the escaped string
* @param out write to receive the escaped string
* @param str String to escape values in, may be null
* @param escapeSingleQuote escapes single quotes if <code>true</code>
* @param escapeForwardSlash TODO
* @throws IOException if an IOException occurs
*/
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,
boolean escapeForwardSlash) throws IOException {
private static void escapeJavaStyleString(Writer out, String str) throws IOException {
if (out == null) {
throw new IllegalArgumentException("The Writer must not be null");
}
@ -101,7 +96,7 @@ public class YamlStringEscapeUtils {
} else {
switch (ch) {
case '\'' :
if (escapeSingleQuote) {
if (false) {
out.write('\\');
}
out.write('\'');
@ -115,7 +110,7 @@ public class YamlStringEscapeUtils {
out.write('\\');
break;
case '/' :
if (escapeForwardSlash) {
if (false) {
out.write('\\');
}
out.write('/');

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import java.io.*;

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import brut.androlib.exceptions.AndrolibException;

View File

@ -1,3 +1,19 @@
/*
* Copyright (C) 2010 Ryszard Wiśniewski <brut.alll@gmail.com>
* Copyright (C) 2010 Connor Tumbleson <connor.tumbleson@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package brut.androlib.apk;
import org.junit.Test;