Open laeubi opened 1 year ago
Yes, that package is for private use and does not provide any API stability. So, what's your use case for QuickWriter apart from the fact that it is in a protected method?
If it is private I think it should only be used in private methods as otherwise it can drip into user-code anyways. I'm currently using it to add a CDATA section into the emitted XML code like this:
CompactWriter compactWriter = new CompactWriter(writer) {
boolean cdata = false;
@Override
public void startNode(String name, @SuppressWarnings("rawtypes") Class clazz) {
super.startNode(name, clazz);
cdata = name.equals("sectionText");
}
@Override
protected void writeText(QuickWriter writer, String text) {
if (cdata) {
writer.write("<![CDATA[");
writer.write(text);
writer.write("]]>");
} else {
super.writeText(writer, text);
}
}
};
Yeah, that's an unfortunate very old leak into the public API.
com.thoughtworks.xstream.io.xml.PrettyPrintWriter
usescom.thoughtworks.xstream.core.util.QuickWriter
in the method:PrettyPrintWriter#writeText
but this type is not exported in the OSGi Manifest so one can't use this type in client code.I'm using the latest release from here: https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream
it seems it is explicitly removed from export here:
https://github.com/x-stream/xstream/blob/d03f6987b793fac71ab89a31d7aa633c366c5289/xstream/pom.xml#L423
but I wonder what is the purpose of that?
Instead of experting the package, it mit be possible to have some abstraction or move QuickWriter to the com.thoughtworks.xstream.io.xml package...