org.xmlresolver.sources.ResolverSAXSource Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of xmlresolver Show documentation
Show all versions of xmlresolver Show documentation
An XML entity/uri resolver
package org.xmlresolver.sources;
import org.xml.sax.InputSource;
import org.xmlresolver.ResourceResponse;
import org.xmlresolver.utils.RsrcUtils;
import javax.xml.transform.sax.SAXSource;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;
/** A {@link javax.xml.transform.sax.SAXSource} with a resolvedURI
. */
public class ResolverSAXSource extends SAXSource implements ResolverResourceInfo {
private final ResourceResponse response;
private final URI resolvedURI;
private final int statusCode;
private final Map> resolvedHeaders;
/**
* Create an extended {@code SAXSource}.
* @param resp the response.
*/
public ResolverSAXSource(ResourceResponse resp) {
super(new InputSource(resp.getInputStream()));
this.response = resp;
resolvedURI = resp.getResolvedURI();
statusCode = resp.getStatusCode();
resolvedHeaders = resp.getHeaders();
}
@Override
public ResourceResponse getResponse() {
return response;
}
@Override
public URI getResolvedURI() {
return resolvedURI;
}
@Override
public int getStatusCode() {
return statusCode;
}
@Override
public Map> getHeaders() {
return resolvedHeaders;
}
@Override
public String getHeader(String headerName) {
return RsrcUtils.getHeader(headerName, resolvedHeaders);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy