package info.bukova.isspst.services.fulltext;

import org.odftoolkit.simple.Document;
import org.odftoolkit.simple.common.TextExtractor;

import java.io.InputStream;

/**
 * @author Pepa Rokos
 */
public class OdfExtractor extends AbstractExtractor implements Extractor {

	@Override
	public String extract(InputStream is) throws ExtractorException {
		try {
			Document odfDocument = Document.loadDocument(is);
			TextExtractor extractor = TextExtractor.newOdfTextExtractor(odfDocument.getContentRoot());

			return extractor.getText();
		} catch (Exception e) {
			throw new ExtractorException(e);
		}
	}
}
