/** * Convert the given prefixed name string to an IRI if possible. * * @param prefixedName * a prefixed name string, e.g. "rdf:type" * @return the IRI corresponding to the prefixed name, or {@code null} if the supplied string couldn't be * converted. */ private IRI convertPrefixedName(String prefixedName) { if (prefixedName.indexOf(':') < 0) { return null; } final String prefix = prefixedName.substring(0, prefixedName.indexOf(':')); final ValueFactory vf = SimpleValueFactory.getInstance(); for (Namespace ns : model.getNamespaces()) { if (prefix.equals(ns.getPrefix())) { return vf.createIRI(ns.getName(), prefixedName.substring(prefixedName.indexOf(':') + 1)); } } // try mapping using some of the default / well-known namespaces for (Namespace ns : getDefaultNamespaces()) { if (prefix.equals(ns.getPrefix())) { model.setNamespace(ns); return vf.createIRI(ns.getName(), prefixedName.substring(prefixedName.indexOf(':') + 1)); } } return null; }
/** * Convert the given prefixed name string to an IRI if possible. * * @param prefixedName * a prefixed name string, e.g. "rdf:type" * @return the IRI corresponding to the prefixed name, or {@code null} if the supplied string couldn't be * converted. */ private IRI convertPrefixedName(String prefixedName) { if (prefixedName.indexOf(':') < 0) { return null; } final String prefix = prefixedName.substring(0, prefixedName.indexOf(':')); final ValueFactory vf = SimpleValueFactory.getInstance(); for (Namespace ns : model.getNamespaces()) { if (prefix.equals(ns.getPrefix())) { return vf.createIRI(ns.getName(), prefixedName.substring(prefixedName.indexOf(':') + 1)); } } // try mapping using some of the default / well-known namespaces for (Namespace ns : getDefaultNamespaces()) { if (prefix.equals(ns.getPrefix())) { model.setNamespace(ns); return vf.createIRI(ns.getName(), prefixedName.substring(prefixedName.indexOf(':') + 1)); } } return null; }