use of org.ontoware.rdf2go.model.node.Literal in project stanbol by apache.
the class MetaxaCore method getText.
/**
* Returns a documents plain text if contained in the given extracted
* metadata.
*
* @param model
* a {@link Model} with the extracted metadata
* @return a {@link String} with the plain text content or {@code null} if
* no plain text was contained in the extracted metadata
*/
public static String getText(Model model) {
String result = null;
ClosableIterator<Statement> statements = null;
try {
statements = model.findStatements(Variable.ANY, NIE.plainTextContent, Variable.ANY);
StringBuilder text = new StringBuilder(10000);
while (statements.hasNext()) {
Statement statement = statements.next();
Node value = statement.getObject();
if (value instanceof Literal) {
text.append(((Literal) value).getValue());
}
}
result = text.toString().trim();
if (result.length() == 0) {
result = null;
}
} finally {
if (statements != null) {
statements.close();
}
}
return result;
}