public final class Namespaces extends AbstractSet<org.openrdf.model.Namespace>
Namespace set.
A Namespaces object is an immutable container of prefix -> namespace URI
bindings, where multiple prefixes can map to the same namespace URI but there is at most a
binding for any given prefix.
Data in this class can be primarily accessed using lookup methods uriFor(String),
prefixFor(String) and prefixesFor(String). In addition, the following views
are offered:
set<Namespace object> view, directly implemented by class instances;prefix -> namespace URI map view, produced by uriMap;namespace URI -> prefix map view, produced by prefixMap();set<prefix string> view, produced by prefixes();set<URI string> view, produced by uris();Instances of this class can be created from:
Namespace iterable, by forIterable(Iterable, boolean);prefix -> namespace URI map, by forURIMap(Map);namespace URI -> prefix map, by forPrefixMap(Map, boolean);URLs, by load(Iterable, boolean);This class is immutable and thus thread-safe.
| Modifier and Type | Field and Description |
|---|---|
static Namespaces |
DEFAULT |
| Modifier and Type | Method and Description |
|---|---|
boolean |
contains(Object object) |
static Namespaces |
forIterable(Iterable<? extends org.openrdf.model.Namespace> iterable,
boolean resolveClashes)
Returns a
Namespaces set for the Namespace Iterable supplied. |
static Namespaces |
forPrefixMap(Map<String,String> map,
boolean resolveClashes)
Returns a
Namespaces set for the namespace URI -> prefix map supplied. |
static Namespaces |
forURIMap(Map<String,String> map)
Returns a
Namespaces set for the prefix -> namespace URI map supplied. |
boolean |
isEmpty() |
Iterator<org.openrdf.model.Namespace> |
iterator() |
static Namespaces |
load(Iterable<URL> urls,
boolean resolveClashes)
Creates a
Namespaces set by loading the namespace declarations in the files at the
URLs specified. |
Set<String> |
prefixes()
Returns a
Set view of the prefixes in this Namespace set. |
List<String> |
prefixesFor(String uri)
Returns all the prefixes bound to the namespace URI specified.
|
String |
prefixFor(String uri)
Returns the first prefix bound to the namespace URI specified, or null if it does not
exist.
|
Map<String,String> |
prefixMap()
Returns a
namespace URI -> prefix map view. |
int |
size() |
org.openrdf.model.Namespace[] |
toArray() |
String |
uriFor(String prefix)
Returns the namespace URI for the prefix specified, or null if it does not exist.
|
Map<String,String> |
uriMap()
Returns a
prefix -> namespace URI map view. |
Set<String> |
uris()
Returns a
Set view of the namespace URIs in this Namespace set. |
equals, hashCode, removeAlladd, addAll, clear, containsAll, remove, retainAll, toArray, toStringclone, finalize, getClass, notify, notifyAll, wait, wait, waitadd, addAll, clear, containsAll, remove, retainAll, spliterator, toArrayparallelStream, removeIf, streampublic static final Namespaces DEFAULT
public static Namespaces load(Iterable<URL> urls, boolean resolveClashes) throws IOException
Namespaces set by loading the namespace declarations in the files at the
URLs specified. The text files must be encoded in UTF-8. Each line has the format
namespace_URI prefix_1 ... prefix_N, where components are separated by whitespaces.urls - the URLs identifying the files to load, not nullresolveClashes - true in case a clash caused by the same prefix being mapped to different
namespace URIs should be silently resolved by keeping only the first mapping in
the supplied iterableNamespaces objectIOException - on IO errorIllegalArgumentException - in case resolveClashes is false and the Iterable associates the
same prefix to different namespace URIspublic static Namespaces forIterable(Iterable<? extends org.openrdf.model.Namespace> iterable, boolean resolveClashes) throws IllegalArgumentException
Namespaces set for the Namespace Iterable supplied. In
case the Iterable is itself a Namespaces object, it will be directly
returned.iterable - the Iterable where to load namespaces from, not nullresolveClashes - true in case a clash caused by the same prefix being mapped to different
namespace URIs should be silently resolved by keeping only the first mapping in
the supplied iterableNamespaces objectIllegalArgumentException - in case resolveClashes is false and the Iterable associates the
same prefix to different namespace URIspublic static Namespaces forURIMap(Map<String,String> map)
Namespaces set for the prefix -> namespace URI map supplied. In
case the map is the uriMap() of another Namespaces object, that object
will be directly returned.map - the prefix -> namespace URI map, not nullNamespaces objectpublic static Namespaces forPrefixMap(Map<String,String> map, boolean resolveClashes) throws IllegalArgumentException
Namespaces set for the namespace URI -> prefix map supplied. In
case the map is the prefixMap() of another Namespaces object, that object
will be directly returned.map - the namespace URI -> prefix map, not nullresolveClashes - true in case a clash caused by the same prefix being mapped to different
namespace URIs should be silently resolved by keeping only the first mapping in
the supplied iterableNamespaces objectIllegalArgumentException - in case resolveClashes is false and the Iterable associates the
same prefix to different namespace URIspublic int size()
size in interface Collection<org.openrdf.model.Namespace>size in interface Set<org.openrdf.model.Namespace>size in class AbstractCollection<org.openrdf.model.Namespace>public boolean isEmpty()
isEmpty in interface Collection<org.openrdf.model.Namespace>isEmpty in interface Set<org.openrdf.model.Namespace>isEmpty in class AbstractCollection<org.openrdf.model.Namespace>public boolean contains(@Nullable Object object)
contains in interface Collection<org.openrdf.model.Namespace>contains in interface Set<org.openrdf.model.Namespace>contains in class AbstractCollection<org.openrdf.model.Namespace>public Set<String> prefixes()
Set view of the prefixes in this Namespace set.Set view of prefixespublic List<String> prefixesFor(String uri)
uri - the namespace URI, not null@Nullable public String prefixFor(String uri)
uri - the namespace URI, not nullpublic Map<String,String> prefixMap()
namespace URI -> prefix map view. Note that the map will report only the
first prefix bound to a namespace URI, in case multiple prefixes are defined for that URI.namespace URI -> prefix map viewpublic Set<String> uris()
Set view of the namespace URIs in this Namespace set.Set view of namespace URIs@Nullable public String uriFor(String prefix)
prefix - the prefix, not nullpublic Map<String,String> uriMap()
prefix -> namespace URI map view.prefix -> namespace URI map viewpublic Iterator<org.openrdf.model.Namespace> iterator()
iterator in interface Iterable<org.openrdf.model.Namespace>iterator in interface Collection<org.openrdf.model.Namespace>iterator in interface Set<org.openrdf.model.Namespace>iterator in class AbstractCollection<org.openrdf.model.Namespace>public org.openrdf.model.Namespace[] toArray()
toArray in interface Collection<org.openrdf.model.Namespace>toArray in interface Set<org.openrdf.model.Namespace>toArray in class AbstractCollection<org.openrdf.model.Namespace>Copyright © 2015–2016 FBK-irst. All rights reserved.