public interface PrefixMapping
Note that a Model *is* a PrefixMapping, so all the PrefixMapping operations apply to Models, and a Model can be used to supply the PrefixMapping argument to setNsPrefixes.
Modifier and Type | Interface and Description |
---|---|
static class |
PrefixMapping.Factory
Factory class to create an unspecified kind of PrefixMapping.
|
static class |
PrefixMapping.IllegalPrefixException
Exception to throw when the prefix argument to setNsPrefix is
illegal for some reason.
|
static class |
PrefixMapping.JenaLockedException
Exception to throw when trying to update a locked PrefixMapping.
|
Modifier and Type | Field and Description |
---|---|
static PrefixMapping |
Extended
A PrefixMapping built on Standard with some extras
|
static PrefixMapping |
Standard
A PrefixMapping that contains the "standard" prefixes we know about,
viz rdf, rdfs, dc, rss, vcard, and owl.
|
Modifier and Type | Method and Description |
---|---|
String |
expandPrefix(String prefixed)
Expand the uri using the prefix mappings if possible.
|
Map<String,String> |
getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings.
|
String |
getNsPrefixURI(String prefix)
Get the URI bound to a specific prefix, null if there isn't one.
|
String |
getNsURIPrefix(String uri)
Answer the prefix for the given URI, or null if there isn't one.
|
PrefixMapping |
lock()
Lock the PrefixMapping so that changes can no longer be made to it.
|
String |
qnameFor(String uri)
Answer a qname with the expansion of the given uri, or null if no such qname
can be constructed using the mapping's prefixes.
|
PrefixMapping |
removeNsPrefix(String prefix)
Remove any existing maplet with the given prefix name and answer this
mapping.
|
boolean |
samePrefixMappingAs(PrefixMapping other)
Answer true iff this prefix-mappings are equal, that is, map the same
prefixes to the same URIs; same as
this.getNsPrefixMap().equals( other.getNsPrefixMap() )
except that it may avoid unnecessary Map creations.
|
PrefixMapping |
setNsPrefix(String prefix,
String uri)
Specify the prefix name for a URI prefix string.
|
PrefixMapping |
setNsPrefixes(Map<String,String> map)
Copies the prefix mapping from other into this.
|
PrefixMapping |
setNsPrefixes(PrefixMapping other)
Copies the prefixes from other into this.
|
String |
shortForm(String uri)
Compress the URI using the prefix mappings if possible.
|
PrefixMapping |
withDefaultMappings(PrefixMapping map)
Update this PrefixMapping with the bindings in
map , only
adding those (p, u) pairs for which neither p nor u appears in this mapping. |
static final PrefixMapping Standard
static final PrefixMapping Extended
PrefixMapping setNsPrefix(String prefix, String uri)
A prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".
Need not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good. The earlier restriction that the URI should end with a non-NCName character has been removed.
Note, in particular, that the a prefix mapping can only be used if it includes the URI up to any '#' character because '#' is not legal in the local part of an NCName.
prefix
- the string to be used for the prefix.uri
- the URI prefix to be namedPrefixMapping.IllegalPrefixException
- if the prefix is not an XML NCNamePrefixMapping removeNsPrefix(String prefix)
The reverse URI-to-prefix mapping is updated, but if there are multiple prefixes for the removed URI it is unspecified which of them will be chosen.
prefix
- the prefix string to removePrefixMapping setNsPrefixes(PrefixMapping other)
other
- the PrefixMapping to addPrefixMapping setNsPrefixes(Map<String,String> map)
map
- the Map whose maplets are to be addedPrefixMapping withDefaultMappings(PrefixMapping map)
map
, only
adding those (p, u) pairs for which neither p nor u appears in this mapping.
Answer this PrefixMapping.String getNsPrefixURI(String prefix)
prefix
- the prefix name to be looked upString getNsURIPrefix(String uri)
uri
- the uri whose prefix is to be foundMap<String,String> getNsPrefixMap()
String expandPrefix(String prefixed)
prefixed
- a QName or URIString shortForm(String uri)
The result is primarily intended for human convenience: it is not necessarily a legal QName, as Tail need not be a legal NCName; and there's no way to tell a shortened name from a URI with an unusual scheme.
uri
- the URI string to try and prefix-compressString qnameFor(String uri)
PrefixMapping lock()
boolean samePrefixMappingAs(PrefixMapping other)
this.getNsPrefixMap().equals( other.getNsPrefixMap() )except that it may avoid unnecessary Map creations.
Licenced under the Apache License, Version 2.0