Class PolyadicPrefixMappingImpl
- java.lang.Object
-
- org.apache.jena.shared.impl.PrefixMappingImpl
-
- org.apache.jena.graph.compose.PolyadicPrefixMappingImpl
-
- All Implemented Interfaces:
PrefixMapping
public class PolyadicPrefixMappingImpl extends PrefixMappingImpl implements PrefixMapping
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.jena.shared.PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
-
-
Field Summary
-
Fields inherited from interface org.apache.jena.shared.PrefixMapping
Extended, Standard
-
-
Constructor Summary
Constructors Constructor Description PolyadicPrefixMappingImpl(Polyadic p)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PrefixMapping
clearNsPrefixMap()
Clear this prefix mapping of all mappingsjava.lang.String
expandPrefix(java.lang.String prefixed)
Expand a prefixed URI.java.util.Map<java.lang.String,java.lang.String>
getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings.java.lang.String
getNsPrefixURI(java.lang.String prefix)
Get the URI bound to a specific prefix, null if there isn't one.java.lang.String
getNsURIPrefix(java.lang.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.int
numPrefixes()
Return the number of defined prefixes.java.lang.String
qnameFor(java.lang.String uri)
Answer the qname foruri
which uses a prefix from this mapping, or null if there isn't one.PrefixMapping
removeNsPrefix(java.lang.String prefix)
Remove any existing maplet with the given prefix name and answer this mapping.PrefixMapping
setNsPrefix(java.lang.String prefix, java.lang.String uri)
Specify the prefix name for a URI prefix string.PrefixMapping
setNsPrefixes(java.util.Map<java.lang.String,java.lang.String> other)
Add the bindings in the map to our own.PrefixMapping
setNsPrefixes(PrefixMapping other)
Add the bindings of other to our own.java.lang.String
shortForm(java.lang.String uri)
Compress the URI using the prefix mapping.java.lang.String
toString()
Answer a readable (we hope) representation of this prefix mapping.-
Methods inherited from class org.apache.jena.shared.impl.PrefixMappingImpl
isNiceURI, lock, samePrefixMappingAs, withDefaultMappings
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.apache.jena.shared.PrefixMapping
lock, samePrefixMappingAs, withDefaultMappings
-
-
-
-
Constructor Detail
-
PolyadicPrefixMappingImpl
public PolyadicPrefixMappingImpl(Polyadic p)
-
-
Method Detail
-
setNsPrefix
public PrefixMapping setNsPrefix(java.lang.String prefix, java.lang.String uri)
Description copied from interface:PrefixMapping
Specify the prefix name for a URI prefix string. Any existing use of that prefix name is overwritten. The result is this same prefixMapping. (The earlier restriction that adding second prefix for the same URI caused the earlier binding to be deleted has been withdrawn.)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.
- Specified by:
setNsPrefix
in interfacePrefixMapping
- Overrides:
setNsPrefix
in classPrefixMappingImpl
- Parameters:
prefix
- the string to be used for the prefix.uri
- the URI prefix to be named- Returns:
- this PrefixMapping
-
removeNsPrefix
public PrefixMapping removeNsPrefix(java.lang.String prefix)
Description copied from interface:PrefixMapping
Remove any existing maplet with the given prefix name and answer this mapping. If the prefix is the empty string, then this removes the default namespace. If the prefix is not a legal prefix string, or is not present in the mapping, nothing happens.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.
- Specified by:
removeNsPrefix
in interfacePrefixMapping
- Overrides:
removeNsPrefix
in classPrefixMappingImpl
- Parameters:
prefix
- the prefix string to remove- Returns:
- this PrefixMapping
-
clearNsPrefixMap
public PrefixMapping clearNsPrefixMap()
Description copied from interface:PrefixMapping
Clear this prefix mapping of all mappings- Specified by:
clearNsPrefixMap
in interfacePrefixMapping
- Overrides:
clearNsPrefixMap
in classPrefixMappingImpl
-
setNsPrefixes
public PrefixMapping setNsPrefixes(PrefixMapping other)
Add the bindings of other to our own. We defer to the general case because we have to ensure the URIs are checked.- Specified by:
setNsPrefixes
in interfacePrefixMapping
- Overrides:
setNsPrefixes
in classPrefixMappingImpl
- Parameters:
other
- the PrefixMapping whose bindings we are to add to this.- Returns:
- this PrefixMapping
-
setNsPrefixes
public PrefixMapping setNsPrefixes(java.util.Map<java.lang.String,java.lang.String> other)
Add the bindings in the map to our own. This will fail with a ClassCastException if any key or value is not a String; we make no guarantees about order or completeness if this happens. It will fail with an IllegalPrefixException if any prefix is illegal; similar provisos apply.- Specified by:
setNsPrefixes
in interfacePrefixMapping
- Overrides:
setNsPrefixes
in classPrefixMappingImpl
- Parameters:
other
- the Map whose bindings we are to add to this.- Returns:
- this PrefixMapping
-
getNsPrefixURI
public java.lang.String getNsPrefixURI(java.lang.String prefix)
Description copied from interface:PrefixMapping
Get the URI bound to a specific prefix, null if there isn't one.- Specified by:
getNsPrefixURI
in interfacePrefixMapping
- Overrides:
getNsPrefixURI
in classPrefixMappingImpl
- Parameters:
prefix
- the prefix name to be looked up- Returns:
- the most recent URI bound to that prefix name, null if none
-
getNsPrefixMap
public java.util.Map<java.lang.String,java.lang.String> getNsPrefixMap()
Description copied from interface:PrefixMapping
Return a copy of the internal mapping from names to URI strings. Updating this copy will have no effect on the PrefixMap.- Specified by:
getNsPrefixMap
in interfacePrefixMapping
- Overrides:
getNsPrefixMap
in classPrefixMappingImpl
- Returns:
- a copy of the internal String -> String mapping
-
getNsURIPrefix
public java.lang.String getNsURIPrefix(java.lang.String uri)
Description copied from interface:PrefixMapping
Answer the prefix for the given URI, or null if there isn't one. If there is more than one, one of them will be picked. If possible, it will be the most recently added prefix. (The cases where it's not possible is when a binding has been removed.)- Specified by:
getNsURIPrefix
in interfacePrefixMapping
- Overrides:
getNsURIPrefix
in classPrefixMappingImpl
- Parameters:
uri
- the uri whose prefix is to be found- Returns:
- the prefix mapped to that uri, or null if there isn't one
-
expandPrefix
public java.lang.String expandPrefix(java.lang.String prefixed)
Expand a prefixed URI. There's an assumption that any URI of the form Head:Tail is subject to mapping if Head is in the prefix mapping. So, if someone takes it into their heads to define eg "http" or "ftp" we have problems.- Specified by:
expandPrefix
in interfacePrefixMapping
- Overrides:
expandPrefix
in classPrefixMappingImpl
- Parameters:
prefixed
- a QName or URI- Returns:
- the expanded string if possible, otherwise the original string
-
toString
public java.lang.String toString()
Answer a readable (we hope) representation of this prefix mapping.- Overrides:
toString
in classPrefixMappingImpl
-
shortForm
public java.lang.String shortForm(java.lang.String uri)
Compress the URI using the prefix mapping. This version of the code looks through all the maplets and checks each candidate prefix URI for being a leading substring of the argument URI. There's probably a much more efficient algorithm available, preprocessing the prefix strings into some kind of search table, but for the moment we don't need it.- Specified by:
shortForm
in interfacePrefixMapping
- Overrides:
shortForm
in classPrefixMappingImpl
- Parameters:
uri
- the URI string to try and prefix-compress- Returns:
- the shortened form if possible, otherwise the unchanged argument
-
hasNoMappings
public boolean hasNoMappings()
Description copied from interface:PrefixMapping
Return whether the prefix mapping has any defined prefixes.- Specified by:
hasNoMappings
in interfacePrefixMapping
- Overrides:
hasNoMappings
in classPrefixMappingImpl
-
numPrefixes
public int numPrefixes()
Description copied from interface:PrefixMapping
Return the number of defined prefixes.- Specified by:
numPrefixes
in interfacePrefixMapping
- Overrides:
numPrefixes
in classPrefixMappingImpl
-
qnameFor
public java.lang.String qnameFor(java.lang.String uri)
Description copied from class:PrefixMappingImpl
Answer the qname foruri
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.- Specified by:
qnameFor
in interfacePrefixMapping
- Overrides:
qnameFor
in classPrefixMappingImpl
- See Also:
PrefixMapping.qnameFor(java.lang.String)
-
-