public Document[] parse(final MultiProtocolURI location, final String mimeType,
final String charset, final InputStream source)
throws Parser.Failure, InterruptedException {
final WordExtractor extractor;
try {
extractor = new WordExtractor(source);
} catch (Exception e) {
throw new Parser.Failure("error in docParser, WordTextExtractorFactory: " + e.getMessage(), location);
}
final StringBuilder contents = new StringBuilder(80);
try {
contents.append(extractor.getText().trim());
contents.append(' ');
contents.append(extractor.getHeaderText());
contents.append(' ');
contents.append(extractor.getFooterText());
} catch (Exception e) {
throw new Parser.Failure("error in docParser, getText: " + e.getMessage(), location);
}
String title = (contents.length() > 240) ? contents.substring(0,240) : contents.toString().trim();
title.replaceAll("\r"," ").replaceAll("\n"," ").replaceAll("\t"," ").trim();
if (title.length() > 80) title = title.substring(0, 80);
int l = title.length();
while (true) {
title = title.replaceAll(" ", " ");
if (title.length() == l) break;
l = title.length();
}
Document[] docs;
docs = new Document[]{new Document(
location,
mimeType,
"UTF-8",
this,
null,
null,
title,
"", // TODO: AUTHOR
extractor.getDocSummaryInformation().getCompany(), // publisher
null,
null,
0.0f, 0.0f,
UTF8.getBytes(contents.toString()),
null,