public void execute(final QueryEngine qe, final ModelConnection mc) throws RippleException { mc.setNamespace(prefix, null, true); // Note: when a namespace is manually defined, it may both override an // existing prefix with the same name, or duplicate another namespace // with the same URI. qe.getLexicon().removeNamespace(prefix); }
public void execute(final QueryEngine qe, final ModelConnection mc) throws RippleException { qe.getLexicon().putTemporaryValue(name.getName(), value); }
private void updateCompletors() { logger.trace("updating completors"); List<Completer> completors = new ArrayList<>(); try { Lexicon lex = queryEngine.getLexicon(); synchronized (lex) { completors.add(lex.getCompletor()); } ArrayList<String> directives = new ArrayList<>(); directives.add("@help"); directives.add("@list"); directives.add("@prefix"); directives.add("@quit"); directives.add("@relist"); directives.add("@show"); directives.add("@unlist"); directives.add("@unprefix"); completors.add( new DirectiveCompletor(directives)); try { // This makes candidates from multiple completors available at once. Completer multiCompletor = new AggregateCompleter(completors); reader.addCompleter(multiCompletor); } catch (Throwable t) { throw new RippleException(t); } } catch (RippleException e) { logger.error("failed to update completors", e); } }
public void execute(final QueryEngine qe, final ModelConnection mc) throws RippleException { Value uri = mc.valueOf(java.net.URI.create(qe.getLexicon().getDefaultNamespace() + term)); //System.out.println("uri = " + uri); mc.remove(uri, null, null); mc.commit(); mc.getModel().getSpecialValues().remove(uri); }
public void evaluate(final Sink<RippleList> sink, final QueryEngine qe, final ModelConnection mc) throws RippleException { Sink<Object> uriSink = v -> sink.accept(mc.list().push(v)); qe.getLexicon().resolveKeyword(name, uriSink, mc, qe.getErrorPrintStream()); } }
public void evaluate(final Sink<RippleList> sink, final QueryEngine qe, final ModelConnection mc) throws RippleException { Sink<Object> uriSink = v -> sink.accept(mc.list().push(v)); qe.getLexicon().uriForQName(nsPrefix, localName, uriSink, mc, qe.getErrorPrintStream()); } }
public void execute(final QueryEngine qe, final ModelConnection mc) throws RippleException { Collector<RippleList> expressions = new Collector<>(); list.evaluate(expressions, qe, mc); if (expressions.size() == 0) { qe.getErrorPrintStream().println( "Warning: the given expression did not resolve to a value."); } else if (expressions.size() > 1) { qe.getErrorPrintStream().println( "Warning: the given expression resolved to multiple values."); } else { // Note: the first element of the list will also be a list RippleList expr = (RippleList) expressions.iterator().next().getFirst(); //System.out.println( "exprList = " + exprList ); Value id = mc.valueOf(java.net.URI.create(qe.getLexicon().getDefaultNamespace() + name)); expr.setRDFEquivalent(id); mc.internalize(expr); mc.commit(); qe.getLexicon().addURI((IRI) id); mc.getModel().getSpecialValues().put(id, expr); } }
public void execute(final QueryEngine qe, final ModelConnection mc) throws RippleException { Collector<RippleList> sink = new Collector<>(); uri.evaluate(sink, qe, mc); if (sink.size() == 0) { throw new RippleException("URI could not be constructed from " + uri); } else if (sink.size() > 1) { throw new RippleException("multiple values constructed from " + uri); } String ns = sink.iterator().next().getFirst().toString(); mc.setNamespace(prefix, ns, true); // Note: when a namespace is manually defined, it may both override an // existing prefix with the same name, or duplicate another namespace // with the same URI. qe.getLexicon().setNamespace(prefix, ns, mc); }
public QueryEngine(final Model model, final StackEvaluator evaluator, final PrintStream out, final PrintStream err) throws RippleException { this.model = model; this.evaluator = evaluator; lexicon = new Lexicon(model); printStream = new RipplePrintStream(out, lexicon); errorPrintStream = err; connection = model.createConnection(new LexiconUpdater(lexicon)); initializeLexicon(); // TODO: the default value is a temporary fix for version conflicts due to property renaming String defaultNamespace = Ripple.getConfiguration().getString( Ripple.DEFAULT_NAMESPACE, "http://example.org/ns/"); // Set the default namespace. //mc.setNamespace( "", defaultNamespace, false ); // FIXME: these should not be hard-coded getLexicon().addCommonNamespaces(connection); getLexicon().setNamespace("", defaultNamespace, connection); connection.commit(); }
QueryEngine qe = new QueryEngine(model, null, System.out, System.err); ByteArrayOutputStream bos = new ByteArrayOutputStream(); RipplePrintStream ps = new RipplePrintStream(new PrintStream(bos), qe.getLexicon());
ListAST foobar2 = new ListAST( new StringLiteralAST("foo2"), new ListAST(new StringLiteralAST("bar2"), new ListAST())); IRI foobarUri = sail.getValueFactory().createIRI(qe.getLexicon().getDefaultNamespace() + "foobar"); Literal foo = sail.getValueFactory().createLiteral("foo", XMLSchema.STRING); Literal foo2 = sail.getValueFactory().createLiteral("foo2", XMLSchema.STRING);