public void addURI(final IRI uri) { // If possible, add a qualified name as well. String prefix = uriToPrefix.get(uri.getNamespace()); if (null != prefix) { String qName = prefix + ":" + uri.getLocalName(); allQNames.add(qName); } }
public String getName(IRI IRI) { String name = uriToString.get(IRI); if (name == null && SPIN.NAMESPACE.equals(IRI.getNamespace()) && IRI.getLocalName().startsWith("_arg")) { String lname = IRI.getLocalName(); try { Integer.parseInt(lname.substring("_arg".length())); name = lname.substring(1); } catch (NumberFormatException nfe) { // ignore - not a well-known argN variable } } return name; } }
public String findSymbol(final IRI uri) { // Does it have a keyword? String symbol = uriToKeyword.get(uri); // If not, does it have a namespace prefix? if (null == symbol) { String nsPrefix = uriToPrefix.get(uri.getNamespace()); // Namespace prefix may be empty but non-null. if (null != nsPrefix) { String localName = uri.getLocalName(); // Note: assumes that the local name is never null (although it // may be empty). symbol = (isValidPrefix(nsPrefix) && isValidLocalName(localName)) ? nsPrefix + ":" + uri.getLocalName() : null; } } return symbol; }
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(); } }
try { if (file != null) { String ns = funcUri.getNamespace(); try { Reader reader = new InputStreamReader(
@Override public void parse(Model graph, Resource implNode) throws SailConfigException { super.parse(graph, implNode); Literal indexDirLit = Models.objectLiteral(graph.filter(implNode, INDEX_DIR, null)).orElseThrow( () -> new SailConfigException("no value found for " + INDEX_DIR)); setIndexDir(indexDirLit.getLabel()); for (Statement stmt : graph.filter(implNode, null, null)) { if (stmt.getPredicate().getNamespace().equals(LuceneSailConfigSchema.NAMESPACE)) { if (stmt.getObject() instanceof Literal) { String key = stmt.getPredicate().getLocalName(); setParameter(key, stmt.getObject().stringValue()); } } } } }
private void namespaceTest(final String uri, final String ns, final String localName, final ModelConnection mc) throws Exception { IRI uriCreated = createIRI(uri, mc); String nsCreated = uriCreated.getNamespace(); String localNameCreated = uriCreated.getLocalName(); assertEquals(uriCreated.toString(), uri); assertEquals(nsCreated, ns); assertEquals(localNameCreated, localName); }
namespace = uri.getNamespace(); assertEquals(localName, "bar"); assertEquals(namespace, "http://example.org/foo#"); namespace = uri.getNamespace(); assertEquals(localName, ""); assertEquals(namespace, "http://example.org/foo#"); namespace = uri.getNamespace(); assertEquals(localName, "bar"); assertEquals(namespace, "http://example.org/ns/foo/#"); namespace = uri.getNamespace(); assertEquals(localName, ""); assertEquals(namespace, "http://example.org/ns/foo/#"); namespace = uri.getNamespace(); assertEquals(localName, "bar"); assertEquals(namespace, "http://example.org/ns/foo/"); namespace = uri.getNamespace(); assertEquals(localName, ""); assertEquals(namespace, "http://example.org/ns/foo/");
String baseUri = uri.getNamespace();
String baseUri = uri.getNamespace();