package com.fasterxml.aalto.dom;
import java.util.Collections;
import javax.xml.stream.*;
import javax.xml.transform.dom.DOMSource;
import org.codehaus.stax2.ri.dom.DOMWrappingReader;
import com.fasterxml.aalto.WFCException;
import com.fasterxml.aalto.in.ReaderConfig;
public class DOMReaderImpl
extends DOMWrappingReader
{
protected final ReaderConfig _config;
protected DOMReaderImpl(DOMSource src, ReaderConfig cfg)
throws XMLStreamException
{
super(src, cfg.willSupportNamespaces(), cfg.willCoalesceText());
_config = cfg;
if (cfg.hasInternNamesBeenEnabled()) {
setInternNames(cfg.willInternNames());
}
if (cfg.hasInternNsURIsBeenEnabled()) {
setInternNsURIs(cfg.willInternNsURIs());
}
}
public static DOMReaderImpl createFrom(DOMSource src, ReaderConfig cfg)
throws XMLStreamException
{
return new DOMReaderImpl(src, cfg);
}
@Override
public boolean isPropertySupported(String name) {
return _config.isPropertySupported(name);
}
@Override
public Object getProperty(String name)
{
if (name.equals("javax.xml.stream.entities")) {
return Collections.EMPTY_LIST;
}
if (name.equals("javax.xml.stream.notations")) {
return Collections.EMPTY_LIST;
}
return _config.getProperty(name, true);
}
@Override
public boolean setProperty(String name, Object value)
{
return _config.setProperty(name, value);
}
@Override
protected void throwStreamException(String msg, Location loc)
throws XMLStreamException
{
throw new WFCException(msg, loc);
}
}