in xstream/src/java/com/thoughtworks/xstream/io/xml/SaxWriter.java [289:341]
public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
switch (name) {
case CONFIGURED_XSTREAM_PROPERTY:
if (!(value instanceof XStream)) {
throw new SAXNotSupportedException(String
.format("Value for property \"%s\" must be a non-null XStream object",
CONFIGURED_XSTREAM_PROPERTY));
}
break;
case SOURCE_OBJECT_LIST_PROPERTY:
if (value instanceof List) {
value = new LinkedList<>((List<?>)value);
properties.put(name, value); // just for backward compatibility
} else {
throw new SAXNotSupportedException(String
.format("Value for property \"%s\" must be a non-null List object", name));
}
//$FALL-THROUGH$
case SOURCE_OBJECT_QUEUE_PROPERTY:
if (value instanceof BlockingQueue) {
// OK, take it directly
} else if (value instanceof Queue) {
final Queue<?> queue = (Queue<?>)value;
if (queue.isEmpty()) {
throw new SAXNotSupportedException(String
.format("Value for property \"%s\" shall not be an empty %s", name, name
.equals(SOURCE_OBJECT_QUEUE_PROPERTY) ? "queue" : "list"));
} else if (name.equals(SOURCE_OBJECT_QUEUE_PROPERTY)) {
// Perform a copy of the list to prevent the application to
// modify its content while the parse is being performed.
value = new ArrayDeque<>(queue);
}
} else {
throw new SAXNotSupportedException(String
.format("Value for property \"%s\" must be a non-null Queue object", name));
}
name = SOURCE_OBJECT_QUEUE_PROPERTY;
break;
case OOS_SUPPLIER_PROPERTY:
if (value instanceof Supplier) {
// OK
} else {
throw new SAXNotSupportedException(String
.format("Value for property \"%s\" has to be a supplier for the ObjectOutputStream",
OOS_SUPPLIER_PROPERTY));
}
break;
default:
throw new SAXNotRecognizedException(name);
}
properties.put(name, value);
}