[skip] code style cleanup

This commit is contained in:
Connor Tumbleson 2015-12-14 07:10:14 -06:00
parent eabb7d819b
commit b2d50bec5f
9 changed files with 33 additions and 63 deletions

View File

@ -81,8 +81,7 @@ public class ResPackage {
return mResSpecs.size();
}
public ResType getOrCreateConfig(ResConfigFlags flags)
throws AndrolibException {
public ResType getOrCreateConfig(ResConfigFlags flags) throws AndrolibException {
ResType config = mConfigs.get(flags);
if (config == null) {
config = new ResType(flags);
@ -126,8 +125,7 @@ public class ResPackage {
if (res.getValue() instanceof ResValuesXmlSerializable) {
ResTypeSpec type = res.getResSpec().getType();
ResType config = res.getConfig();
Duo<ResTypeSpec, ResType> key = new Duo<ResTypeSpec, ResType>(
type, config);
Duo<ResTypeSpec, ResType> key = new Duo<ResTypeSpec, ResType>(type, config);
ResValuesFile values = ret.get(key);
if (values == null) {
values = new ResValuesFile(this, type, config);
@ -204,9 +202,7 @@ public class ResPackage {
return false;
}
final ResPackage other = (ResPackage) obj;
if (this.mResTable != other.mResTable
&& (this.mResTable == null || !this.mResTable
.equals(other.mResTable))) {
if (this.mResTable != other.mResTable && (this.mResTable == null || !this.mResTable.equals(other.mResTable))) {
return false;
}
if (this.mId != other.mId) {
@ -218,8 +214,7 @@ public class ResPackage {
@Override
public int hashCode() {
int hash = 17;
hash = 31 * hash
+ (this.mResTable != null ? this.mResTable.hashCode() : 0);
hash = 31 * hash + (this.mResTable != null ? this.mResTable.hashCode() : 0);
hash = 31 * hash + this.mId;
return hash;
}
@ -231,6 +226,5 @@ public class ResPackage {
return mValueFactory;
}
private final static Logger LOGGER = Logger
.getLogger(ResPackage.class.getName());
private final static Logger LOGGER = Logger.getLogger(ResPackage.class.getName());
}

View File

@ -46,12 +46,10 @@ public class ResResSpec {
return getResource(config.getFlags());
}
public ResResource getResource(ResConfigFlags config)
throws AndrolibException {
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 UndefinedResObject(String.format("resource: spec=%s, config=%s", this, config));
}
return res;
}
@ -109,12 +107,10 @@ public class ResResSpec {
addResource(res, false);
}
public void addResource(ResResource res, boolean overwrite)
throws AndrolibException {
public void addResource(ResResource res, boolean overwrite) throws AndrolibException {
ResConfigFlags flags = res.getConfig().getFlags();
if (mResources.put(flags, res) != null && !overwrite) {
throw new AndrolibException(String.format(
"Multiple resources: spec=%s, config=%s", this, flags));
throw new AndrolibException(String.format("Multiple resources: spec=%s, config=%s", this, flags));
}
}

View File

@ -34,8 +34,7 @@ public class ResResource {
}
public String getFilePath() {
return mResSpec.getType().getName()
+ mConfig.getFlags().getQualifiers() + "/" + mResSpec.getName();
return mResSpec.getType().getName() + mConfig.getFlags().getQualifiers() + "/" + mResSpec.getName();
}
public ResType getConfig() {

View File

@ -87,8 +87,8 @@ public class ResTable {
public ResPackage getHighestSpecPackage() throws AndrolibException {
int id = 0;
int value = 0;
for(ResPackage resPackage : mPackagesById.values()) {
if(resPackage.getResSpecCount() > value && !resPackage.getName().equalsIgnoreCase("android")) {
for (ResPackage resPackage : mPackagesById.values()) {
if (resPackage.getResSpecCount() > value && !resPackage.getName().equalsIgnoreCase("android")) {
value = resPackage.getResSpecCount();
id = resPackage.getId();
}
@ -123,18 +123,14 @@ public class ResTable {
return mPackagesByName.containsKey(name);
}
public ResValue getValue(String package_, String type, String name)
throws AndrolibException {
return getPackage(package_).getType(type).getResSpec(name)
.getDefaultResource().getValue();
public ResValue getValue(String package_, String type, String name) throws AndrolibException {
return getPackage(package_).getType(type).getResSpec(name).getDefaultResource().getValue();
}
public void addPackage(ResPackage pkg, boolean main)
throws AndrolibException {
public void addPackage(ResPackage pkg, boolean main) throws AndrolibException {
Integer id = pkg.getId();
if (mPackagesById.containsKey(id)) {
throw new AndrolibException("Multiple packages: id="
+ id.toString());
throw new AndrolibException("Multiple packages: id=" + id.toString());
}
String name = pkg.getName();
if (mPackagesByName.containsKey(name)) {

View File

@ -38,8 +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 UndefinedResObject(String.format("resource: spec=%s, config=%s", spec, this));
}
return res;
}
@ -61,12 +60,10 @@ public class ResType {
mResources.remove(spec);
}
public void addResource(ResResource res, boolean overwrite)
throws AndrolibException {
public void addResource(ResResource res, boolean overwrite) throws AndrolibException {
ResResSpec spec = res.getResSpec();
if (mResources.put(spec, res) != null && !overwrite) {
throw new AndrolibException(String.format(
"Multiple resources: spec=%s, config=%s", spec, this));
throw new AndrolibException(String.format("Multiple resources: spec=%s, config=%s", spec, this));
}
}

View File

@ -64,8 +64,7 @@ public final class ResTypeSpec {
public ResResSpec getResSpec(String name) throws AndrolibException {
ResResSpec spec = mResSpecs.get(name);
if (spec == null) {
throw new UndefinedResObject(String.format("resource spec: %s/%s",
getName(), name));
throw new UndefinedResObject(String.format("resource spec: %s/%s", getName(), name));
}
return spec;
}
@ -76,8 +75,7 @@ public final class ResTypeSpec {
public void addResSpec(ResResSpec spec) throws AndrolibException {
if (mResSpecs.put(spec.getName(), spec) != null) {
throw new AndrolibException(String.format(
"Multiple res specs: %s/%s", getName(), spec.getName()));
throw new AndrolibException(String.format("Multiple res specs: %s/%s", getName(), spec.getName()));
}
}

View File

@ -69,12 +69,10 @@ public class ResValuesFile {
return false;
}
final ResValuesFile other = (ResValuesFile) obj;
if (this.mType != other.mType
&& (this.mType == null || !this.mType.equals(other.mType))) {
if (this.mType != other.mType && (this.mType == null || !this.mType.equals(other.mType))) {
return false;
}
if (this.mConfig != other.mConfig
&& (this.mConfig == null || !this.mConfig.equals(other.mConfig))) {
if (this.mConfig != other.mConfig && (this.mConfig == null || !this.mConfig.equals(other.mConfig))) {
return false;
}
return true;

View File

@ -27,12 +27,11 @@ import brut.util.Duo;
public class ResValueFactory {
private final ResPackage mPackage;
public ResValueFactory(ResPackage pakage_) {
this.mPackage = pakage_;
public ResValueFactory(ResPackage package_) {
this.mPackage = package_;
}
public ResScalarValue factory(int type, int value, String rawValue)
throws AndrolibException {
public ResScalarValue factory(int type, int value, String rawValue) throws AndrolibException {
switch (type) {
case TypedValue.TYPE_NULL:
if (value == TypedValue.DATA_NULL_EMPTY) { // Special case $empty as explicitly defined empty value
@ -57,12 +56,10 @@ public class ResValueFactory {
return newReference(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_COLOR_INT
&& type <= TypedValue.TYPE_LAST_COLOR_INT) {
if (type >= TypedValue.TYPE_FIRST_COLOR_INT && type <= TypedValue.TYPE_LAST_COLOR_INT) {
return new ResColorValue(value, rawValue);
}
if (type >= TypedValue.TYPE_FIRST_INT
&& type <= TypedValue.TYPE_LAST_INT) {
if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT) {
return new ResIntValue(value, rawValue, type);
}
@ -76,8 +73,7 @@ public class ResValueFactory {
return new ResStringValue(value, rawValue);
}
public ResBagValue bagFactory(int parent,
Duo<Integer, ResScalarValue>[] items) throws AndrolibException {
public ResBagValue bagFactory(int parent, Duo<Integer, ResScalarValue>[] items) throws AndrolibException {
ResReferenceValue parentVal = newReference(parent, null);
if (items.length == 0) {
@ -90,8 +86,7 @@ public class ResValueFactory {
if (key == ResArrayValue.BAG_KEY_ARRAY_START) {
return new ResArrayValue(parentVal, items);
}
if (key >= ResPluralsValue.BAG_KEY_PLURALS_START
&& key <= ResPluralsValue.BAG_KEY_PLURALS_END) {
if (key >= ResPluralsValue.BAG_KEY_PLURALS_START && key <= ResPluralsValue.BAG_KEY_PLURALS_END) {
return new ResPluralsValue(parentVal, items);
}
return new ResStyleValue(parentVal, items, this);
@ -101,8 +96,7 @@ public class ResValueFactory {
return newReference(resID, rawValue, false);
}
public ResReferenceValue newReference(int resID, String rawValue,
boolean theme) {
public ResReferenceValue newReference(int resID, String rawValue, boolean theme) {
return new ResReferenceValue(mPackage, resID, rawValue, theme);
}
}

View File

@ -289,8 +289,7 @@ public class ARSCDecoder {
: mPkg.getValueFactory().factory(type, data, null);
}
private ResConfigFlags readConfigFlags() throws IOException,
AndrolibException {
private ResConfigFlags readConfigFlags() throws IOException, AndrolibException {
int size = mIn.readInt();
int read = 28;
@ -465,8 +464,7 @@ public class ARSCDecoder {
}
}
private void nextChunkCheckType(int expectedType) throws IOException,
AndrolibException {
private void nextChunkCheckType(int expectedType) throws IOException, AndrolibException {
nextChunk();
checkChunkType(expectedType);
}