package lux.functions;
import lux.Evaluator;
import lux.xpath.FunCall;
import net.sf.saxon.expr.XPathContext;
import net.sf.saxon.lib.ExtensionFunctionCall;
import net.sf.saxon.lib.ExtensionFunctionDefinition;
import net.sf.saxon.om.Sequence;
import net.sf.saxon.om.StructuredQName;
import net.sf.saxon.trans.XPathException;
import net.sf.saxon.value.EmptySequence;
import net.sf.saxon.value.SequenceType;
/**
* <code>function lux:commit() as empty-sequence()</code>
* <p>Commits pending updates to the index and blocks until the operation is complete.</p>
*/
public class Commit extends ExtensionFunctionDefinition {
@Override
public StructuredQName getFunctionQName() {
return new StructuredQName("lux", FunCall.LUX_NAMESPACE, "commit");
}
@Override
public SequenceType[] getArgumentTypes() {
return new SequenceType[] { };
}
@Override
public SequenceType getResultType(SequenceType[] suppliedArgumentTypes) {
return SequenceType.EMPTY_SEQUENCE;
}
@Override
public boolean hasSideEffects () {
return true;
}
@Override
public boolean trustResultType () {
return true;
}
@Override
public ExtensionFunctionCall makeCallExpression() {
return new CommitCall ();
}
class CommitCall extends ExtensionFunctionCall {
@Override
public Sequence call(XPathContext context, Sequence[] arguments)
throws XPathException {
Evaluator eval = SearchBase.getEvaluator(context);
eval.getDocWriter().commit(eval);
return EmptySequence.getInstance();
}
}
}
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */