com.hp.hpl.jena.graph.compose
Class PolyadicPrefixMappingImpl

java.lang.Object
  extended bycom.hp.hpl.jena.shared.impl.PrefixMappingImpl
      extended bycom.hp.hpl.jena.graph.compose.PolyadicPrefixMappingImpl
All Implemented Interfaces:
PrefixMapping

public class PolyadicPrefixMappingImpl
extends com.hp.hpl.jena.shared.impl.PrefixMappingImpl
implements PrefixMapping


Nested Class Summary
 
Nested classes inherited from class com.hp.hpl.jena.shared.PrefixMapping
PrefixMapping.Factory, PrefixMapping.IllegalPrefixException, PrefixMapping.JenaLockedException
 
Field Summary
 
Fields inherited from interface com.hp.hpl.jena.shared.PrefixMapping
Standard
 
Constructor Summary
PolyadicPrefixMappingImpl(Polyadic p)
           
 
Method Summary
 java.lang.String expandPrefix(java.lang.String prefixed)
          Expand a prefixed URI.
 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 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 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 toString()
          Answer a readable (we hope) representation of this prefix mapping.
 java.lang.String usePrefix(java.lang.String uri)
          Compress the URI using the prefix mapping.
 
Methods inherited from class com.hp.hpl.jena.shared.impl.PrefixMappingImpl
isNiceURI, lock
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface com.hp.hpl.jena.shared.PrefixMapping
lock
 

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. Any existing prefix for the same URI is removed, unless either prefix is the empty string. (We still have to decide what happens if there are overlapping* URIs.) The result is this same prefixMapping.

A prefix name must be a valid NCName, or the empty string. The empty string is reserved to mean "the default namespace".

Any URI may be ignored; for example URIs that end in an NCName char may be discarded.

Does not check the RFC2396 validity of the URI. Bad URIs are either silently ignored or behave as if they were good.

Specified by:
setNsPrefix in interface 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.

Specified by:
removeNsPrefix in interface PrefixMapping

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 interface PrefixMapping
Parameters:
other - the PrefixMapping whose bindings we are to add to this.

setNsPrefixes

public PrefixMapping setNsPrefixes(java.util.Map 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 interface PrefixMapping
Parameters:
other - the Map whose bindings we are to add to this.

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 interface PrefixMapping

getNsPrefixMap

public java.util.Map 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 interface PrefixMapping

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.

Specified by:
getNsURIPrefix in interface PrefixMapping

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 interface PrefixMapping

toString

public java.lang.String toString()
Answer a readable (we hope) representation of this prefix mapping.


usePrefix

public java.lang.String usePrefix(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:
usePrefix in interface PrefixMapping


Copyright © 2000-2003 Hewlett-Packard. All Rights Reserved.