}
@Override
public Parse parse(ContentEntity entity, Link link) throws IOException, DroidsException {
// Init Tika objects
org.apache.tika.parser.Parser parser = new AutoDetectParser();
Metadata metadata = new Metadata();
String charset = entity.getCharset();
if (charset == null) {
charset = "UTF-8";
}
EchoHandler data = new EchoHandler(charset);
LinkExtractor extractor = new LinkExtractor(link, elements);
TeeContentHandler parallelHandler = new TeeContentHandler(data, extractor);
InputStream instream = entity.obtainContent();
try {
parser.parse(instream, parallelHandler, metadata);
return new ParseImpl(data.toString(), extractor.getLinks());
} catch (SAXException ex) {
throw new DroidsException("Failure parsing document " + link.getId(), ex);
} catch (TikaException ex) {