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

View File

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