ExtXmlSerializer: added possibility to disable escaping of attr values.

This commit is contained in:
Ryszard Wiśniewski 2011-05-03 03:31:52 +02:00
parent 888c9082ce
commit 90f789ff01
2 changed files with 17 additions and 2 deletions

View File

@ -16,8 +16,7 @@
package brut.androlib.res.util;
import java.io.IOException;
import java.io.OutputStream;
import java.io.*;
import org.xmlpull.mxp1_serializer.MXSerializer;
/**
@ -32,6 +31,16 @@ public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
this.newLine();
}
@Override
protected void writeAttributeValue(String value, Writer out)
throws IOException {
if (mIsDisabledAttrEscape) {
out.write(value);
return;
}
super.writeAttributeValue(value, out);
}
@Override
public void setOutput(OutputStream os, String encoding) throws IOException {
super.setOutput(os, encoding != null ? encoding : mDefaultEncoding);
@ -60,5 +69,10 @@ public class ExtMXSerializer extends MXSerializer implements ExtXmlSerializer {
return this;
}
public void setDisabledAttrEscape(boolean disabled) {
mIsDisabledAttrEscape = disabled;
}
private String mDefaultEncoding;
private boolean mIsDisabledAttrEscape = false;
}

View File

@ -25,6 +25,7 @@ import org.xmlpull.v1.XmlSerializer;
public interface ExtXmlSerializer extends XmlSerializer {
public ExtXmlSerializer newLine() throws IOException;
public void setDisabledAttrEscape(boolean disabled);
public static final String PROPERTY_SERIALIZER_INDENTATION =
"http://xmlpull.org/v1/doc/properties.html#serializer-indentation";