Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.hp.hpl.jena.shared
Interface PrefixMapping  view PrefixMapping download PrefixMapping.java


public interface PrefixMapping

Methods for recording namepsace prefix mappings and applying and unapplying them to URIs.

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.


Nested Class Summary
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.
 
Field Summary
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.
 
Method Summary
 java.lang.String expandPrefix(java.lang.String prefixed)
          Expand the uri using the prefix mappings if possible.
 java.util.Map 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.
 PrefixMapping lock()
          Lock the PrefixMapping so that changes can no longer be made to it.
 java.lang.String qnameFor(java.lang.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(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 map)
          Copies the prefix mapping from other into this.
 PrefixMapping setNsPrefixes(PrefixMapping other)
          Copies the prefixes from other into this.
 java.lang.String shortForm(java.lang.String uri)
          Compress the URI using the prefix mappings if possible.
 java.lang.String usePrefix(java.lang.String uri)
          Deprecated. - use shortForm
 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.
 

Field Detail

Standard

public static final PrefixMapping Standard
A PrefixMapping that contains the "standard" prefixes we know about, viz rdf, rdfs, dc, rss, vcard, and owl.


Extended

public static final PrefixMapping Extended
A PrefixMapping built on Standard with some extras

Method Detail

setNsPrefix

public PrefixMapping setNsPrefix(java.lang.String prefix,
                                 java.lang.String uri)
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.


removeNsPrefix

public PrefixMapping removeNsPrefix(java.lang.String prefix)
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.


setNsPrefixes

public PrefixMapping setNsPrefixes(PrefixMapping other)
Copies the prefixes from other into this. Any existing binding of the same prefix is lost. The result is this same prefixMapping.


setNsPrefixes

public PrefixMapping setNsPrefixes(java.util.Map map)
Copies the prefix mapping from other into this. Illegal prefix mappings are detected. Existing binds of the same prefix are lost. The result is this same prefixMapping.


withDefaultMappings

public 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. Answer this PrefixMapping.


getNsPrefixURI

public java.lang.String getNsPrefixURI(java.lang.String prefix)
Get the URI bound to a specific prefix, null if there isn't one.


getNsURIPrefix

public java.lang.String getNsURIPrefix(java.lang.String uri)
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.)


getNsPrefixMap

public java.util.Map getNsPrefixMap()
Return a copy of the internal mapping from names to URI strings. Updating this copy will have no effect on the PrefixMap.


expandPrefix

public java.lang.String expandPrefix(java.lang.String prefixed)
Expand the uri using the prefix mappings if possible. If prefixed has the form Foo:Bar, and Foo is a prefix bound to FooURI, return FooURI+Bar. Otherwise return prefixed unchanged.


shortForm

public java.lang.String shortForm(java.lang.String uri)
Compress the URI using the prefix mappings if possible. If there is a prefix mapping Name -> URIStart, and uri is URIStart+Tail, return Name:Tail; otherwise return uri unchanged. If there are multiple applicable mappings available, the "most recent" is chosen if that is possible, otherwise one is picked "at random".

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.


usePrefix

public java.lang.String usePrefix(java.lang.String uri)
Deprecated. - use shortForm

Old name for shortForm.


qnameFor

public java.lang.String qnameFor(java.lang.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.


lock

public PrefixMapping lock()
Lock the PrefixMapping so that changes can no longer be made to it. Primarily intended to lock Standard against mutation.