Skip to content

Commit fe93fd2

Browse files
authored
refactor: manual YAML Cleanup (#3229)
* refactor: add missing license headers * fix: remove unused exceptions * refactor: remove unused single quote / slash param
1 parent 6e5d49b commit fe93fd2

File tree

11 files changed

+122
-22
lines changed

11 files changed

+122
-22
lines changed

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/ApkInfo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,15 +146,13 @@ public void save(File file) throws AndrolibException {
146146
}
147147

148148
public static ApkInfo load(InputStream is) throws AndrolibException {
149-
// return getYaml().loadAs(is, ApkInfo.class);
150149
YamlReader reader = new YamlReader(is);
151150
ApkInfo apkInfo = new ApkInfo();
152151
reader.readRoot(apkInfo);
153152
return apkInfo;
154153
}
155154

156-
public static ApkInfo load(File appDir)
157-
throws AndrolibException {
155+
public static ApkInfo load(File appDir) throws AndrolibException {
158156
try(
159157
InputStream in = new FileDirectory(appDir).getFileInput("apktool.yml");
160158
) {

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/PackageInfo.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
*/
1717
package brut.androlib.apk;
1818

19-
import brut.androlib.exceptions.AndrolibException;
20-
2119
public class PackageInfo implements YamlSerializable {
2220
public String forcedPackageId;
2321
public String renameManifestPackage;
2422

2523
@Override
26-
public void readItem(YamlReader reader) throws AndrolibException {
24+
public void readItem(YamlReader reader) {
2725
YamlLine line = reader.getLine();
2826
switch (line.getKey()) {
2927
case "forcedPackageId": {
@@ -42,5 +40,4 @@ public void write(YamlWriter writer) {
4240
writer.writeString("forcedPackageId", forcedPackageId);
4341
writer.writeString("renameManifestPackage", renameManifestPackage);
4442
}
45-
4643
}

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/VersionInfo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616
*/
1717
package brut.androlib.apk;
1818

19-
import brut.androlib.exceptions.AndrolibException;
20-
2119
public class VersionInfo implements YamlSerializable {
2220
public String versionCode;
2321
public String versionName;
2422

2523
@Override
26-
public void readItem(YamlReader reader) throws AndrolibException {
24+
public void readItem(YamlReader reader) {
2725
YamlLine line = reader.getLine();
2826
switch (line.getKey()) {
2927
case "versionCode": {

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlLine.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import java.util.Objects;

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlReader.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import brut.androlib.exceptions.AndrolibException;

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlSerializable.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import brut.androlib.exceptions.AndrolibException;

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlStringEscapeUtils.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,20 @@
2626
public class YamlStringEscapeUtils {
2727

2828
public static String escapeString(String str) {
29-
return escapeJavaStyleString(str, false, false);
29+
return escapeJavaStyleString(str);
3030
}
3131

3232
/**
3333
* @param str String to escape values in, may be null
34-
* @param escapeSingleQuotes escapes single quotes if <code>true</code>
35-
* @param escapeForwardSlash TODO
3634
* @return the escaped string
3735
*/
38-
private static String escapeJavaStyleString(String str, boolean escapeSingleQuotes, boolean escapeForwardSlash) {
36+
private static String escapeJavaStyleString(String str) {
3937
if (str == null) {
4038
return null;
4139
}
4240
try {
4341
StringWriter writer = new StringWriter(str.length() * 2);
44-
escapeJavaStyleString(writer, str, escapeSingleQuotes, escapeForwardSlash);
42+
escapeJavaStyleString(writer, str);
4543
return writer.toString();
4644
} catch (IOException ioe) {
4745
// this should never ever happen while writing to a StringWriter
@@ -50,14 +48,11 @@ private static String escapeJavaStyleString(String str, boolean escapeSingleQuot
5048
}
5149

5250
/**
53-
* @param out write to receieve the escaped string
51+
* @param out write to receive the escaped string
5452
* @param str String to escape values in, may be null
55-
* @param escapeSingleQuote escapes single quotes if <code>true</code>
56-
* @param escapeForwardSlash TODO
5753
* @throws IOException if an IOException occurs
5854
*/
59-
private static void escapeJavaStyleString(Writer out, String str, boolean escapeSingleQuote,
60-
boolean escapeForwardSlash) throws IOException {
55+
private static void escapeJavaStyleString(Writer out, String str) throws IOException {
6156
if (out == null) {
6257
throw new IllegalArgumentException("The Writer must not be null");
6358
}
@@ -101,7 +96,7 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape
10196
} else {
10297
switch (ch) {
10398
case '\'' :
104-
if (escapeSingleQuote) {
99+
if (false) {
105100
out.write('\\');
106101
}
107102
out.write('\'');
@@ -115,7 +110,7 @@ private static void escapeJavaStyleString(Writer out, String str, boolean escape
115110
out.write('\\');
116111
break;
117112
case '/' :
118-
if (escapeForwardSlash) {
113+
if (false) {
119114
out.write('\\');
120115
}
121116
out.write('/');

brut.apktool/apktool-lib/src/main/java/brut/androlib/apk/YamlWriter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import java.io.*;

brut.apktool/apktool-lib/src/test/java/brut/androlib/apk/ApkInfoReaderTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import brut.androlib.exceptions.AndrolibException;

brut.apktool/apktool-lib/src/test/java/brut/androlib/apk/DoNotCompressHieroglyphTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import brut.androlib.exceptions.AndrolibException;

brut.apktool/apktool-lib/src/test/java/brut/androlib/apk/YamlLineTest.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,19 @@
1+
/*
2+
* Copyright (C) 2010 Ryszard Wiśniewski <[email protected]>
3+
* Copyright (C) 2010 Connor Tumbleson <[email protected]>
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* https://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
117
package brut.androlib.apk;
218

319
import org.junit.Test;

0 commit comments

Comments
 (0)