ResAttr::convertToResXmlFormat() : now it returns null if it can't convert a value.

Since now this method was calling toResXmlFormat() on an unconvertable value and was always returning a string. But because of that calling object couldn't know, whether returned value is converted one or not.
This commit is contained in:
Ryszard Wiśniewski 2011-05-09 11:07:00 +02:00
parent fc814c50d8
commit b3866d034d
3 changed files with 13 additions and 6 deletions

View File

@ -38,7 +38,7 @@ public class ResAttr extends ResBagValue implements ResValuesXmlSerializable {
public String convertToResXmlFormat(ResScalarValue value)
throws AndrolibException {
return value.toResXmlFormat();
return null;
}
@Override

View File

@ -51,6 +51,10 @@ public class ResStyleValue extends ResBagValue implements ResValuesXmlSerializab
ResAttr attr = (ResAttr) spec.getDefaultResource().getValue();
String value = attr.convertToResXmlFormat(mItems[i].m2);
if (value == null) {
value = mItems[i].m2.toResXmlFormat();
}
if (value == null) {
continue;
}

View File

@ -29,12 +29,15 @@ public class ResAttrDecoder {
throws AndrolibException {
ResScalarValue resValue = mCurrentPackage.getValueFactory()
.factory(type, value, rawValue);
if (attrResId == 0) {
return resValue.toResXmlFormat();
}
String decoded = null;
if (attrResId != 0) {
ResAttr attr = (ResAttr) getCurrentPackage().getResTable()
.getResSpec(attrResId).getDefaultResource().getValue();
return attr.convertToResXmlFormat(resValue);
decoded = attr.convertToResXmlFormat(resValue);
}
return decoded != null ? decoded : resValue.toResXmlFormat();
}
public ResPackage getCurrentPackage() throws AndrolibException {