use of org.brackit.xquery.atomic.Atomic in project sirix by sirixdb.
the class FindNameIndex method execute.
@Override
public Sequence execute(StaticContext sctx, QueryContext ctx, Sequence[] args) throws QueryException {
final DBNode doc = (DBNode) args[0];
final XdmNodeReadTrx rtx = doc.getTrx();
final IndexController controller = rtx.getResourceManager().getRtxIndexController(rtx.getRevisionNumber());
if (controller == null) {
throw new QueryException(new QNm("Document not found: " + ((Str) args[1]).stringValue()));
}
final QNm qnm = (QNm) Cast.cast(sctx, (Atomic) args[1], Type.QNM, false);
final Optional<IndexDef> indexDef = controller.getIndexes().findNameIndex(qnm);
if (indexDef.isPresent())
return new Int32(indexDef.get().getID());
return new Int32(-1);
}
Aggregations