@Override public IRI createIRI(String s) { try { return base.createIRI(s); } catch (IllegalArgumentException e) { return GOOD_IRI; } }
private boolean isValidIRI(final String iri) { try { // TODO: replace this with a more formal criterion based on the IRI spec valueFactory.createIRI(iri); return true; } catch (IllegalArgumentException e) { return false; } }
@Override public IRI createIRI(String s, String s1) { try { return base.createIRI(s, s1); } catch (IllegalArgumentException e) { return GOOD_IRI; } }
public IRI rewrite(final IRI original) { if (null == original) { return null; } else { String s = original.stringValue(); return s.startsWith(internalBaseURI) ? vf.createIRI(s.replace(internalBaseURI, externalBaseURI)) : original; } } };
private IRI createURIOrNull(Repository repository, String graphURI) { if ("null".equals(graphURI)) return null; return repository.getValueFactory().createIRI(graphURI); }
public IRI getURI(String name) { IRI iri = stringToUri.get(name); if (iri == null && functionRegistry.has(name)) { iri = valueFactory.createIRI(name); } return iri; }
private Value toValue(FunctionCall node) { String funcName = node.getURI(); IRI funcUri = wellKnownFunctions.apply(funcName); if (funcUri == null) { funcUri = valueFactory.createIRI(funcName); } return funcUri; }
public IRI rewrite(final IRI original) { if (null == original) { return null; } else { String s = original.stringValue(); return s.startsWith(externalBaseURI) ? vf.createIRI(s.replace(externalBaseURI, internalBaseURI)) : original; } } };
public IRI evaluate(ValueFactory valueFactory, Value... args) throws ValueExprEvaluationException { if (args.length > 0) { throw new ValueExprEvaluationException("UUID requires 0 arguments, got " + args.length); } IRI uri = valueFactory.createIRI("urn:uuid:" + java.util.UUID.randomUUID().toString()); return uri; }
private IRI createURIOrNull(Repository repository, String graphURI) { if ("null".equals(graphURI)) return null; return repository.getValueFactory().createIRI(graphURI); } }
public SpinMagicPropertyInterpreter(SpinParser parser, TripleSource tripleSource, TupleFunctionRegistry tupleFunctionRegistry, AbstractFederatedServiceResolver serviceResolver) { this.parser = parser; this.tripleSource = tripleSource; this.tupleFunctionRegistry = tupleFunctionRegistry; this.serviceResolver = serviceResolver; this.spinServiceUri = tripleSource.getValueFactory().createIRI(SPIN_SERVICE); }
@Override public IRI valueOf(final java.net.URI s) throws RippleException { try { // Note: do NOT automatically canonicalize values. Sometimes one needs the original IRI (e.g. so as to // remove statements), and not the native object it maps to. return valueFactory.createIRI(s.toString()); } catch (Throwable t) { reset(true); throw new RippleException(t); } }
public IRI getURI() { final ValueFactory f = SimpleValueFactory.getInstance(); return f.createIRI(SESAME.NAMESPACE, this.name()); } }
@Override public ValueConstant visit(ASTURI node, Object data) throws VisitorException { return new ValueConstant(valueFactory.createIRI(node.getValue())); }
private Representation representInformationResource() { try { preprocessingHook(); IRI subject = sail.getValueFactory().createIRI(subjectResourceURI); Representation result = getRDFRepresentation(subject, format.get()); postProcessingHook(); return result; } catch (Throwable t) { t.printStackTrace(); return null; } }
private Function getFunction(String name, TripleSource tripleSource, FunctionRegistry functionRegistry) throws OpenRDFException { Function func = functionRegistry.get(name).orElse(null); if (func == null) { IRI funcUri = tripleSource.getValueFactory().createIRI(name); func = parser.parseFunction(funcUri, tripleSource); functionRegistry.add(func); } return func; } }
/** * Finds whether any URI has already been dereferenced which redirects to the given document URI * @param documentUri the URI of a possible Linked Data document * @return whether any URI has already been dereferenced which redirects to the given document URI */ public boolean existsRedirectTo(final String documentUri) throws SailException { IRI hashedDocumentUri = valueFactory.createIRI(RDFUtils.hashedUri(documentUri)); try (CloseableIteration<? extends Statement, SailException> iter = connection.getStatements(null, LinkedDataCache.CACHE_REDIRECTSTO, hashedDocumentUri, false)) { return iter.hasNext(); } }
@Override public Resource export(Model m) { Resource implNode = super.export(m); if (getQueryEndpointUrl() != null) { m.add(implNode, QUERY_ENDPOINT, vf.createIRI(getQueryEndpointUrl())); } if (getUpdateEndpointUrl() != null) { m.add(implNode, UPDATE_ENDPOINT, vf.createIRI(getUpdateEndpointUrl())); } return implNode; }
private Resource toResource(AbsTerm term, ACLMessage message) throws MessageNotUnderstoodException { String iri = term.getAbsObject(RDFAgentsOntology.RESOURCE_IRI).toString(); if (!isValidIRI(iri)) { throw new MessageNotUnderstoodException( "invalid IRI reference '" + iri + "' in query: " + message.getContent()); } try { return valueFactory.createIRI(iri); } catch (IllegalArgumentException e) { throw new MessageNotUnderstoodException("illegal IRI in query: " + message.getContent()); } }
public Value evaluate(Namespace node, BindingSet bindings) throws ValueExprEvaluationException, QueryEvaluationException { Value argValue = evaluate(node.getArg(), bindings); if (argValue instanceof IRI) { IRI uri = (IRI)argValue; return tripleSource.getValueFactory().createIRI(uri.getNamespace()); } else { throw new ValueExprEvaluationException(); } }