in xstream/src/java/com/thoughtworks/xstream/io/xml/SaxWriter.java [602:642]
private void parse() throws SAXException {
XStream xstream = (XStream)properties.get(CONFIGURED_XSTREAM_PROPERTY);
if (xstream == null) {
xstream = new XStream();
}
final Queue<?> source = (Queue<?>)properties.get(SOURCE_OBJECT_QUEUE_PROPERTY);
if (source == null || source.isEmpty() && !(source instanceof BlockingQueue)) {
throw new SAXException("Missing or empty source object queue. Setting property \""
+ SOURCE_OBJECT_QUEUE_PROPERTY
+ "\" is mandatory");
}
try {
@SuppressWarnings("unchecked")
final Supplier<ObjectOutputStream> supplier = (Supplier<ObjectOutputStream>)properties
.get(OOS_SUPPLIER_PROPERTY);
if (supplier != null) {
final ObjectOutputStream oos = supplier.get();
for (Object o = null; o != EOS;) {
o = source instanceof BlockingQueue ? ((BlockingQueue<?>)source).take() : source.poll();
if (o != EOS) {
oos.writeObject(o);
}
}
oos.close();
} else {
startDocument(true);
for (final Object name : source) {
xstream.marshal(name, this);
}
endDocument(true);
}
} catch (final IOException | InterruptedException e) {
if (e.getCause() instanceof SAXException) {
throw (SAXException)e.getCause();
} else {
throw new SAXException(e);
}
}
}