All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.xmlresolver.sources.ResolverSAXSource Maven / Gradle / Ivy

There is a newer version: 6.0.11
Show newest version
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