use of org.apache.jena.query.text.TextDocProducer in project jena by apache.
the class TextDatasetAssembler method open.
/*
<#text_dataset> rdf:type text:Dataset ;
text:dataset <#dataset> ;
text:index <#index> ;
.
*/
@Override
public Dataset open(Assembler a, Resource root, Mode mode) {
Resource dataset = GraphUtils.getResourceValue(root, pDataset);
Resource index = GraphUtils.getResourceValue(root, pIndex);
Resource textDocProducerNode = GraphUtils.getResourceValue(root, pTextDocProducer);
Dataset ds = (Dataset) a.open(dataset);
TextIndex textIndex = (TextIndex) a.open(index);
// Null will use the default producer
TextDocProducer textDocProducer = null;
if (null != textDocProducerNode) {
Class<?> c = Loader.loadClass(textDocProducerNode.getURI(), TextDocProducer.class);
String className = textDocProducerNode.getURI().substring(ARQConstants.javaClassURIScheme.length());
Constructor<?> dyadic = getConstructor(c, DatasetGraph.class, TextIndex.class);
Constructor<?> monadic = getConstructor(c, TextIndex.class);
try {
if (dyadic != null) {
textDocProducer = (TextDocProducer) dyadic.newInstance(ds.asDatasetGraph(), textIndex);
} else if (monadic != null) {
textDocProducer = (TextDocProducer) monadic.newInstance(textIndex);
} else {
Log.warn(Loader.class, "Exception during instantiation '" + className + "' no TextIndex or DatasetGraph,Index constructor");
}
} catch (Exception ex) {
Log.warn(Loader.class, "Exception during instantiation '" + className + "': " + ex.getMessage());
return null;
}
}
Dataset dst = TextDatasetFactory.create(ds, textIndex, true, textDocProducer);
return dst;
}
Aggregations