org.xmlresolver.sources.ResolverInputSource 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 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