net.shibboleth.utilities.java.support.xml
Class SimpleNamespaceContext

java.lang.Object
  extended by net.shibboleth.utilities.java.support.xml.SimpleNamespaceContext
All Implemented Interfaces:
NamespaceContext

@ThreadSafe
public class SimpleNamespaceContext
extends Object
implements NamespaceContext

Simple implementation of NamespaceContext based on a map from prefix values to corresponding URIs. This implementation only supports a single mapping for a given prefix, that is getPrefixes(String) will always contain at most 1 element.


Field Summary
private  com.google.common.collect.ImmutableBiMap<String,String> mappings
          Mappings between namespace prefixes and namespace URIs.
 
Constructor Summary
SimpleNamespaceContext()
          Constructor.
SimpleNamespaceContext(Map<String,String> prefixToUriMappings)
          Constructor.
 
Method Summary
private  com.google.common.collect.ImmutableBiMap.Builder<String,String> getMappingsBuilder()
          Build the initial set of mappings which contains entries for XML and XMLNS.
 String getNamespaceURI(String prefix)
          
 String getPrefix(String namespaceURI)
          
 Iterator<String> getPrefixes(String namespaceURI)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mappings

private final com.google.common.collect.ImmutableBiMap<String,String> mappings
Mappings between namespace prefixes and namespace URIs.

Constructor Detail

SimpleNamespaceContext

public SimpleNamespaceContext()
Constructor.


SimpleNamespaceContext

public SimpleNamespaceContext(@Nullable@NullableElements
                              Map<String,String> prefixToUriMappings)
Constructor.

Parameters:
prefixToUriMappings - Maps prefix values to the corresponding namespace URIs.
Method Detail

getNamespaceURI

@Nullable
public String getNamespaceURI(@Nonnull
                                       String prefix)

Specified by:
getNamespaceURI in interface NamespaceContext

getPrefix

@Nullable
public String getPrefix(@Nonnull
                                 String namespaceURI)

Specified by:
getPrefix in interface NamespaceContext

getPrefixes

@Nonnull
public Iterator<String> getPrefixes(String namespaceURI)

Specified by:
getPrefixes in interface NamespaceContext

getMappingsBuilder

@Nonnull
private com.google.common.collect.ImmutableBiMap.Builder<String,String> getMappingsBuilder()
Build the initial set of mappings which contains entries for XML and XMLNS.

Returns:
initial set of mappings


Copyright © 1999-2012. All Rights Reserved.