public class PrefixMappingImpl extends Object implements PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedExceptionExtended, 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()
PrefixMappinglock in interface PrefixMappingpublic PrefixMapping setNsPrefix(String prefix, String uri)
PrefixMappingA 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 PrefixMappingprefix - the string to be used for the prefix.uri - the URI prefix to be namedpublic PrefixMapping removeNsPrefix(String prefix)
PrefixMappingThe 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 PrefixMappingprefix - the prefix string to removepublic PrefixMapping clearNsPrefixMap()
PrefixMappingclearNsPrefixMap in interface PrefixMappingpublic static boolean isNiceURI(String uri)
public PrefixMapping setNsPrefixes(PrefixMapping other)
setNsPrefixes in interface PrefixMappingother - 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 PrefixMappingpublic PrefixMapping setNsPrefixes(Map<String,String> other)
setNsPrefixes in interface PrefixMappingother - the Map whose bindings we are to add to this.public String getNsPrefixURI(String prefix)
PrefixMappinggetNsPrefixURI in interface PrefixMappingprefix - the prefix name to be looked uppublic Map<String,String> getNsPrefixMap()
PrefixMappinggetNsPrefixMap in interface PrefixMappingpublic String getNsURIPrefix(String uri)
PrefixMappinggetNsURIPrefix in interface PrefixMappinguri - the uri whose prefix is to be foundpublic String expandPrefix(String prefixed)
expandPrefix in interface PrefixMappingprefixed - 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 PrefixMappingPrefixMapping.qnameFor(java.lang.String)public String shortForm(String uri)
shortForm in interface PrefixMappinguri - the URI string to try and prefix-compresspublic boolean samePrefixMappingAs(PrefixMapping other)
PrefixMappingthis.getNsPrefixMap().equals( other.getNsPrefixMap() )except that it may avoid unnecessary Map creations.
samePrefixMappingAs in interface PrefixMappingpublic boolean hasNoMappings()
PrefixMappinghasNoMappings in interface PrefixMappingpublic int numPrefixes()
PrefixMappingnumPrefixes in interface PrefixMappingLicenced under the Apache License, Version 2.0