Gracefully handle null values

This commit is contained in:
Connor Tumbleson 2015-12-14 07:00:46 -06:00
parent be4bdf1d75
commit 7e803aeac9
2 changed files with 5 additions and 8 deletions

View File

@ -26,16 +26,14 @@ public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
@Override @Override
public void startDocument(String encoding, Boolean standalone) public void startDocument(String encoding, Boolean standalone)
throws IOException, IllegalArgumentException, IllegalStateException { throws IOException, IllegalArgumentException, IllegalStateException {
super.startDocument(encoding != null ? encoding : mDefaultEncoding, super.startDocument(encoding != null ? encoding : mDefaultEncoding, standalone);
standalone);
this.newLine(); this.newLine();
} }
@Override @Override
protected void writeAttributeValue(String value, Writer out) protected void writeAttributeValue(String value, Writer out) throws IOException {
throws IOException {
if (mIsDisabledAttrEscape) { if (mIsDisabledAttrEscape) {
out.write(value); out.write(value == null ? "" : value);
return; return;
} }
super.writeAttributeValue(value, out); super.writeAttributeValue(value, out);
@ -55,8 +53,7 @@ public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
} }
@Override @Override
public void setProperty(String name, Object value) public void setProperty(String name, Object value) throws IllegalArgumentException, IllegalStateException {
throws IllegalArgumentException, IllegalStateException {
if (PROPERTY_DEFAULT_ENCODING.equals(name)) { if (PROPERTY_DEFAULT_ENCODING.equals(name)) {
mDefaultEncoding = (String) value; mDefaultEncoding = (String) value;
} else { } else {

View File

@ -34,7 +34,7 @@ public final class ResXmlEncoders {
} }
public static String encodeAsResXmlAttr(String str) { public static String encodeAsResXmlAttr(String str) {
if (str.isEmpty()) { if (str == null || str.isEmpty()) {
return str; return str;
} }