public class PrefixMappingImpl extends Object implements PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
Extended, Standard
Constructor and Description |
---|
PrefixMappingImpl() |
Modifier and Type | Method and Description |
---|---|
PrefixMapping |
clearNsPrefixMap()
Clear this prefix mapping of all mappings
|
String |
expandPrefix(String prefixed)
Expand a prefixed URI.
|
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.
|
boolean |
hasNoMappings()
Return whether the prefix mapping has any defined prefixes.
|
static boolean |
isNiceURI(String uri) |
PrefixMapping |
lock()
Lock the PrefixMapping so that changes can no longer be made to it.
|
int |
numPrefixes()
Return the number of defined prefixes.
|
String |
qnameFor(String uri)
Answer the qname for
uri which uses a prefix from this
mapping, or null if there isn't one. |
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> other)
Add the bindings in the prefixToURI to our own.
|
PrefixMapping |
setNsPrefixes(PrefixMapping other)
Add the bindings of other to our own.
|
String |
shortForm(String uri)
Compress the URI using the prefix mapping.
|
String |
toString()
Answer a readable (we hope) representation of this prefix mapping.
|
PrefixMapping |
withDefaultMappings(PrefixMapping other)
Answer this PrefixMapping after updating it with the
(p, u)
mappings in other where neither p nor
u appear in this mapping. |
public PrefixMapping lock()
PrefixMapping
lock
in interface PrefixMapping
public PrefixMapping setNsPrefix(String prefix, String uri)
PrefixMapping
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 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.
setNsPrefix
in interface PrefixMapping
prefix
- the string to be used for the prefix.uri
- the URI prefix to be namedpublic PrefixMapping removeNsPrefix(String prefix)
PrefixMapping
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.
removeNsPrefix
in interface PrefixMapping
prefix
- the prefix string to removepublic PrefixMapping clearNsPrefixMap()
PrefixMapping
clearNsPrefixMap
in interface PrefixMapping
public static boolean isNiceURI(String uri)
public PrefixMapping setNsPrefixes(PrefixMapping other)
setNsPrefixes
in interface PrefixMapping
other
- the PrefixMapping whose bindings we are to add to this.public PrefixMapping withDefaultMappings(PrefixMapping other)
(p, u)
mappings in other
where neither p
nor
u
appear in this mapping.withDefaultMappings
in interface PrefixMapping
public PrefixMapping setNsPrefixes(Map<String,String> other)
setNsPrefixes
in interface PrefixMapping
other
- the Map whose bindings we are to add to this.public String getNsPrefixURI(String prefix)
PrefixMapping
getNsPrefixURI
in interface PrefixMapping
prefix
- the prefix name to be looked uppublic Map<String,String> getNsPrefixMap()
PrefixMapping
getNsPrefixMap
in interface PrefixMapping
public String getNsURIPrefix(String uri)
PrefixMapping
getNsURIPrefix
in interface PrefixMapping
uri
- the uri whose prefix is to be foundpublic String expandPrefix(String prefixed)
expandPrefix
in interface PrefixMapping
prefixed
- a QName or URIpublic String toString()
public String qnameFor(String uri)
uri
which uses a prefix from this
mapping, or null if there isn't one.
Relies on splitNamespace
to carve uri into namespace and
localname components; this ensures that the localname is legal and we just
have to (reverse-)lookup the namespace in the prefix table.
qnameFor
in interface PrefixMapping
PrefixMapping.qnameFor(java.lang.String)
public String shortForm(String uri)
shortForm
in interface PrefixMapping
uri
- the URI string to try and prefix-compresspublic boolean samePrefixMappingAs(PrefixMapping other)
PrefixMapping
this.getNsPrefixMap().equals( other.getNsPrefixMap() )except that it may avoid unnecessary Map creations.
samePrefixMappingAs
in interface PrefixMapping
public boolean hasNoMappings()
PrefixMapping
hasNoMappings
in interface PrefixMapping
public int numPrefixes()
PrefixMapping
numPrefixes
in interface PrefixMapping
Licenced under the Apache License, Version 2.0