Class PrefixMappingBase

All Implemented Interfaces:
Direct Known Subclasses:
PrefixMappingAdapter, PrefixMappingMem, PrefixMappingSink

public abstract class PrefixMappingBase extends Object implements org.apache.jena.shared.PrefixMapping
Framework for implementing PrefixMapping. It is stateless (unlike PrefixMappingImpl) and implements the contract of PrefixMapping, providing the key algorithm and delegating storage to the subclasses.

Reverse mapping, looking up a URI to find a prefix is complex because there may be several possibilities. Applications should not rely on every implementation being consistent when there is a choice of which prefix to use to shorten a URI.

  • Method Details

    • setNsPrefix

      public org.apache.jena.shared.PrefixMapping setNsPrefix(String prefix, String uri)
      Specified by:
      setNsPrefix in interface org.apache.jena.shared.PrefixMapping
    • removeNsPrefix

      public org.apache.jena.shared.PrefixMapping removeNsPrefix(String prefix)
      Specified by:
      removeNsPrefix in interface org.apache.jena.shared.PrefixMapping
    • clearNsPrefixMap

      public org.apache.jena.shared.PrefixMapping clearNsPrefixMap()
      Specified by:
      clearNsPrefixMap in interface org.apache.jena.shared.PrefixMapping
    • checkLegalPrefix

      public static void checkLegalPrefix(String prefix)
      Checks that a prefix is "legal" - it must be a valid XML NCName or "". XML rules for RDF/XML output.

      This is a recurring user question - why does Resource.getNamespace, Resource.getLocalname not abbreviate when it is legal Turtle.

      Answer - legacy for RDF/XML.

      See also qnameFor(java.lang.String).

    • setNsPrefixes

      public org.apache.jena.shared.PrefixMapping setNsPrefixes(org.apache.jena.shared.PrefixMapping pmap)
      Specified by:
      setNsPrefixes in interface org.apache.jena.shared.PrefixMapping
    • setNsPrefixes

      public org.apache.jena.shared.PrefixMapping setNsPrefixes(Map<String,String> map)
      Specified by:
      setNsPrefixes in interface org.apache.jena.shared.PrefixMapping
    • withDefaultMappings

      public org.apache.jena.shared.PrefixMapping withDefaultMappings(org.apache.jena.shared.PrefixMapping pmap)
      Specified by:
      withDefaultMappings in interface org.apache.jena.shared.PrefixMapping
    • getNsPrefixURI

      public String getNsPrefixURI(String prefix)
      Specified by:
      getNsPrefixURI in interface org.apache.jena.shared.PrefixMapping
    • getNsURIPrefix

      public String getNsURIPrefix(String uri)
      Specified by:
      getNsURIPrefix in interface org.apache.jena.shared.PrefixMapping
    • getNsPrefixMap

      public Map<String,String> getNsPrefixMap()
      Specified by:
      getNsPrefixMap in interface org.apache.jena.shared.PrefixMapping
    • expandPrefix

      public String expandPrefix(String prefixed)
      Specified by:
      expandPrefix in interface org.apache.jena.shared.PrefixMapping
    • qnameFor

      public String qnameFor(String uri)
      Specified by:
      qnameFor in interface org.apache.jena.shared.PrefixMapping
    • shortForm

      public String shortForm(String uri)
      Specified by:
      shortForm in interface org.apache.jena.shared.PrefixMapping
    • samePrefixMappingAs

      public boolean samePrefixMappingAs(org.apache.jena.shared.PrefixMapping other)
      Specified by:
      samePrefixMappingAs in interface org.apache.jena.shared.PrefixMapping
    • lock

      public org.apache.jena.shared.PrefixMapping lock()
      Specified by:
      lock in interface org.apache.jena.shared.PrefixMapping
    • hasNoMappings

      public boolean hasNoMappings()
      Specified by:
      hasNoMappings in interface org.apache.jena.shared.PrefixMapping
    • numPrefixes

      public int numPrefixes()
      Specified by:
      numPrefixes in interface org.apache.jena.shared.PrefixMapping
    • toString

      public String toString()
      toString in class Object