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

org.archive.resource.warc.WARCResourceFactory Maven / Gradle / Ivy

There is a newer version: 1.1.9
Show newest version
package org.archive.resource.warc;

import java.io.IOException;
import java.io.InputStream;

import org.archive.format.http.HttpParseException;
import org.archive.format.http.HttpResponse;
import org.archive.format.http.HttpResponseParser;
import org.archive.resource.MetaData;
import org.archive.resource.ResourceConstants;
import org.archive.resource.Resource;
import org.archive.resource.ResourceContainer;
import org.archive.resource.ResourceFactory;
import org.archive.resource.ResourceParseException;

public class WARCResourceFactory implements ResourceFactory, ResourceConstants {
	private HttpResponseParser parser;
	public WARCResourceFactory() {
		parser = new HttpResponseParser();
	}

	public Resource getResource(InputStream is, MetaData parentMetaData,
			ResourceContainer container) throws ResourceParseException,
			IOException {
		try {

			HttpResponse response = parser.parse(is);
			WARCResource r = new WARCResource(parentMetaData.createChild(ENVELOPE),
					container, response);
			return r;

		} catch(HttpParseException e) {
			throw new ResourceParseException(e);
		}
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy