public static XMLStreamReader getXMLStreamReader(IContainer container, boolean cache) {
return getXMLStreamReader(container, cache, defaultReaderConfiguration);
}
public static XMLStreamReader getXMLStreamReader(IContainer container, boolean cache, OMXMLStreamReaderConfiguration configuration) {
OMXMLParserWrapper builder = container.getBuilder();
if (builder != null && builder instanceof StAXOMBuilder) {
if (!container.isComplete()) {
if (((StAXOMBuilder) builder).isLookahead()) {
buildNext(container);
}
}
}
// The om tree was built by hand and is already complete
OMXMLStreamReader reader;
boolean done = container.isComplete();
if ((builder == null) && done) {
reader = new OMStAXWrapper(null, container, false, configuration.isPreserveNamespaceContext());
} else {
if ((builder == null) && !cache) {
throw new UnsupportedOperationException(
"This element was not created in a manner to be switched");
}
if (builder != null && builder.isCompleted() && !cache && !done) {
throw new UnsupportedOperationException(
"The parser is already consumed!");
}
reader = new OMStAXWrapper(builder, container, cache, configuration.isPreserveNamespaceContext());
}