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

org.xmlresolver.sources.ResolverInputSource 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 java.io.InputStream;
import java.net.URI;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/** A {@link InputSource} with a resolvedURI.
 *
 */
public class ResolverInputSource extends InputSource implements ResolverResourceInfo {
    private ResourceResponse response;
    private final URI resolvedURI;
    private final int statusCode;
    private final Map> resolvedHeaders;

    /** Construct the @link org.xml.sax.InputSource} directly from a ResolvedResource
     *
     * @param rsrc the resolved resource
     * */
    public ResolverInputSource(ResourceResponse rsrc) {
        super(rsrc.getInputStream());
        setSystemId(rsrc.getURI().toString());
        setPublicId(rsrc.request.getPublicId());
        this.response = rsrc;
        resolvedURI = rsrc.getResolvedURI();
        statusCode = rsrc.getStatusCode();
        resolvedHeaders = rsrc.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