style: re-org exceptions to have suffix (#2400)

* style: re-org exceptions to have suffix

* fix: add missing exception for ResResSpec
This commit is contained in:
Connor Tumbleson 2020-09-13 08:40:03 -04:00 committed by GitHub
parent 22fdee4d2e
commit 35a4bd6718
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 29 additions and 109 deletions

View File

@ -18,7 +18,7 @@ package brut.androlib;
import brut.androlib.err.InFileNotFoundException;
import brut.androlib.err.OutDirExistsException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import brut.androlib.meta.MetaInfo;
import brut.androlib.meta.PackageInfo;
import brut.androlib.meta.UsesFramework;
@ -416,7 +416,7 @@ public class ApkDecoder {
int id = getResTable().getPackageId();
try {
id = getResTable().getPackage(renamed).getId();
} catch (UndefinedResObject ignored) {}
} catch (UndefinedResObjectException ignored) {}
if (Strings.isNullOrEmpty(original)) {
return;

View File

@ -19,19 +19,7 @@ package brut.androlib.err;
import brut.androlib.AndrolibException;
public class AXmlDecodingException extends AndrolibException {
public AXmlDecodingException(Throwable cause) {
super(cause);
}
public AXmlDecodingException(String message, Throwable cause) {
super(message, cause);
}
public AXmlDecodingException(String message) {
super(message);
}
public AXmlDecodingException() {
}
}

View File

@ -21,19 +21,8 @@ import brut.androlib.AndrolibException;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class UndefinedResObject extends AndrolibException {
public UndefinedResObject(Throwable cause) {
super(cause);
}
public UndefinedResObject(String message, Throwable cause) {
public class CantFind9PatchChunkException extends AndrolibException {
public CantFind9PatchChunkException(String message, Throwable cause) {
super(message, cause);
}
public UndefinedResObject(String message) {
super(message);
}
public UndefinedResObject() {
}
}

View File

@ -22,12 +22,6 @@ import brut.androlib.AndrolibException;
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class CantFindFrameworkResException extends AndrolibException {
public CantFindFrameworkResException(Throwable cause, int id) {
super(cause);
mPkgId = id;
}
public CantFindFrameworkResException(int id) {
mPkgId = id;
}

View File

@ -22,19 +22,6 @@ import brut.androlib.AndrolibException;
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class InFileNotFoundException extends AndrolibException {
public InFileNotFoundException(Throwable cause) {
super(cause);
}
public InFileNotFoundException(String message, Throwable cause) {
super(message, cause);
}
public InFileNotFoundException(String message) {
super(message);
}
public InFileNotFoundException() {
}
}

View File

@ -22,19 +22,6 @@ import brut.androlib.AndrolibException;
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class OutDirExistsException extends AndrolibException {
public OutDirExistsException(Throwable cause) {
super(cause);
}
public OutDirExistsException(String message, Throwable cause) {
super(message, cause);
}
public OutDirExistsException(String message) {
super(message);
}
public OutDirExistsException() {
}
}

View File

@ -19,19 +19,7 @@ package brut.androlib.err;
import brut.androlib.AndrolibException;
public class RawXmlEncounteredException extends AndrolibException {
public RawXmlEncounteredException(Throwable cause) {
super(cause);
}
public RawXmlEncounteredException(String message, Throwable cause) {
super(message, cause);
}
public RawXmlEncounteredException(String message) {
super(message);
}
public RawXmlEncounteredException() {
}
}

View File

@ -21,20 +21,8 @@ import brut.androlib.AndrolibException;
/**
* @author Ryszard Wiśniewski <brut.alll@gmail.com>
*/
public class CantFind9PatchChunk extends AndrolibException {
public CantFind9PatchChunk(Throwable cause) {
super(cause);
}
public CantFind9PatchChunk(String message, Throwable cause) {
super(message, cause);
}
public CantFind9PatchChunk(String message) {
public class UndefinedResObjectException extends AndrolibException {
public UndefinedResObjectException(String message) {
super(message);
}
public CantFind9PatchChunk() {
}
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import brut.androlib.res.data.value.ResFileValue;
import brut.androlib.res.data.value.ResValueFactory;
import brut.androlib.res.xml.ResValuesXmlSerializable;
@ -53,10 +53,10 @@ public class ResPackage {
return mResSpecs.containsKey(resID);
}
public ResResSpec getResSpec(ResID resID) throws UndefinedResObject {
public ResResSpec getResSpec(ResID resID) throws UndefinedResObjectException {
ResResSpec spec = mResSpecs.get(resID);
if (spec == null) {
throw new UndefinedResObject("resource spec: " + resID.toString());
throw new UndefinedResObjectException("resource spec: " + resID.toString());
}
return spec;
}
@ -72,7 +72,7 @@ public class ResPackage {
public ResType getConfig(ResConfigFlags flags) throws AndrolibException {
ResType config = mConfigs.get(flags);
if (config == null) {
throw new UndefinedResObject("config: " + flags);
throw new UndefinedResObjectException("config: " + flags);
}
return config;
}
@ -101,7 +101,7 @@ public class ResPackage {
public ResTypeSpec getType(String typeName) throws AndrolibException {
ResTypeSpec type = mTypes.get(typeName);
if (type == null) {
throw new UndefinedResObject("type: " + typeName);
throw new UndefinedResObjectException("type: " + typeName);
}
return type;
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import java.util.*;
import org.apache.commons.lang3.StringUtils;
@ -58,7 +58,7 @@ public class ResResSpec {
public ResResource getResource(ResConfigFlags config) throws AndrolibException {
ResResource res = mResources.get(config);
if (res == null) {
throw new UndefinedResObject(String.format("resource: spec=%s, config=%s", this, config));
throw new UndefinedResObjectException(String.format("resource: spec=%s, config=%s", this, config));
}
return res;
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import brut.androlib.meta.VersionInfo;
import brut.androlib.res.AndrolibResources;
import brut.androlib.res.data.value.ResValue;
@ -83,7 +83,7 @@ public class ResTable {
if (mAndRes != null) {
return mAndRes.loadFrameworkPkg(this, id, mAndRes.apkOptions.frameworkTag);
}
throw new UndefinedResObject(String.format("package: id=%d", id));
throw new UndefinedResObjectException(String.format("package: id=%d", id));
}
public ResPackage getHighestSpecPackage() throws AndrolibException {
@ -115,7 +115,7 @@ public class ResTable {
public ResPackage getPackage(String name) throws AndrolibException {
ResPackage pkg = mPackagesByName.get(name);
if (pkg == null) {
throw new UndefinedResObject("package: name=" + name);
throw new UndefinedResObjectException("package: name=" + name);
}
return pkg;
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import java.util.*;
/**
@ -38,7 +38,7 @@ public class ResType {
public ResResource getResource(ResResSpec spec) throws AndrolibException {
ResResource res = mResources.get(spec);
if (res == null) {
throw new UndefinedResObject(String.format("resource: spec=%s, config=%s", spec, this));
throw new UndefinedResObjectException(String.format("resource: spec=%s, config=%s", spec, this));
}
return res;
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import java.util.*;
/**
@ -70,7 +70,7 @@ public final class ResTypeSpec {
public ResResSpec getResSpec(String name) throws AndrolibException {
ResResSpec spec = getResSpecUnsafe(name);
if (spec == null) {
throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name));
throw new UndefinedResObjectException(String.format("resource spec: %s/%s", getName(), name));
}
return spec;
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.data.value;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import brut.androlib.res.data.ResPackage;
import brut.androlib.res.data.ResResSpec;
@ -60,7 +60,7 @@ public class ResReferenceValue extends ResIntValue {
public ResResSpec getReferent() throws AndrolibException {
try {
return mPackage.getResTable().getResSpec(getValue());
} catch (UndefinedResObject ex) {
} catch (UndefinedResObjectException ex) {
return null;
}
}

View File

@ -17,14 +17,13 @@
package brut.androlib.res.decoder;
import brut.androlib.AndrolibException;
import brut.androlib.err.CantFind9PatchChunk;
import brut.androlib.err.CantFind9PatchChunkException;
import brut.util.ExtDataInput;
import java.awt.image.BufferedImage;
import java.awt.image.Raster;
import java.awt.image.WritableRaster;
import java.io.*;
import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier;
import org.apache.commons.io.IOUtils;
@ -110,7 +109,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
int y = h - i;
im2.setRGB(w + 1, y, OI_COLOR);
}
} catch (CantFind9PatchChunk t) {
} catch (CantFind9PatchChunkException t) {
// This chunk might not exist
}
@ -147,7 +146,7 @@ public class Res9patchStreamDecoder implements ResStreamDecoder {
try {
size = di.readInt();
} catch (IOException ex) {
throw new CantFind9PatchChunk("Cant find nine patch chunk", ex);
throw new CantFind9PatchChunkException("Cant find nine patch chunk", ex);
}
if (di.readInt() == magic) {
return;

View File

@ -17,7 +17,7 @@
package brut.androlib.res.decoder;
import brut.androlib.AndrolibException;
import brut.androlib.err.UndefinedResObject;
import brut.androlib.err.UndefinedResObjectException;
import brut.androlib.res.data.ResPackage;
import brut.androlib.res.data.ResResSpec;
import brut.androlib.res.data.value.ResAttr;
@ -39,7 +39,7 @@ public class ResAttrDecoder {
.getResSpec(attrResId).getDefaultResource().getValue();
decoded = attr.convertToResXmlFormat(resValue);
} catch (UndefinedResObject | ClassCastException ex) {
} catch (UndefinedResObjectException | ClassCastException ex) {
// ignored
}
}

View File

@ -17,7 +17,7 @@
package brut.androlib.res.decoder;
import brut.androlib.AndrolibException;
import brut.androlib.err.CantFind9PatchChunk;
import brut.androlib.err.CantFind9PatchChunkException;
import brut.androlib.err.RawXmlEncounteredException;
import brut.androlib.res.data.ResResource;
import brut.androlib.res.data.value.ResBoolValue;
@ -93,7 +93,7 @@ public class ResFileDecoder {
try {
decode(inDir, inFileName, outDir, outFileName, "9patch");
return;
} catch (CantFind9PatchChunk ex) {
} catch (CantFind9PatchChunkException ex) {
LOGGER.log(
Level.WARNING,
String.format(