FileDocCategorySizeDatePackage
DOMCryptoContext.javaAPI DocJava SE 6 API7114Tue Jun 10 00:27:06 BST 2008javax.xml.crypto.dom

DOMCryptoContext

public class DOMCryptoContext extends Object implements XMLCryptoContext
This class provides a DOM-specific implementation of the {@link XMLCryptoContext} interface. It also includes additional methods that are specific to a DOM-based implementation for registering and retrieving elements that contain attributes of type ID.
author
Sean Mullan
author
JSR 105 Expert Group
since
1.6

Fields Summary
private HashMap
nsMap
private HashMap
idMap
private HashMap
objMap
private String
baseURI
private KeySelector
ks
private URIDereferencer
dereferencer
private HashMap
propMap
private String
defaultPrefix
Constructors Summary
protected DOMCryptoContext()
Default constructor. (For invocation by subclass constructors).


                
      
Methods Summary
public java.lang.Objectget(java.lang.Object key)
This implementation uses an internal {@link HashMap} to get the object that the specified key maps to.

	return objMap.get(key);
    
public java.lang.StringgetBaseURI()

        return baseURI;
    
public java.lang.StringgetDefaultNamespacePrefix()

	return defaultPrefix;
    
public org.w3c.dom.ElementgetElementById(java.lang.String idValue)
Returns the Element with the specified ID attribute value.

This implementation uses an internal {@link HashMap} to get the element that the specified attribute value maps to.

param
idValue the value of the ID
return
the Element with the specified ID attribute value, or null if none.
throws
NullPointerException if idValue is null
see
#setIdAttributeNS

        if (idValue == null) {
            throw new NullPointerException("idValue is null");
        }
        return (Element) idMap.get(idValue);
    
public javax.xml.crypto.KeySelectorgetKeySelector()

        return ks;
    
public java.lang.StringgetNamespacePrefix(java.lang.String namespaceURI, java.lang.String defaultPrefix)
This implementation uses an internal {@link HashMap} to get the prefix that the specified URI maps to. It returns the defaultPrefix if it maps to null.

throws
NullPointerException {@inheritDoc}

        if (namespaceURI == null) {
            throw new NullPointerException("namespaceURI cannot be null");
        }
	String prefix = (String) nsMap.get(namespaceURI);
	return (prefix != null ? prefix : defaultPrefix);
    
public java.lang.ObjectgetProperty(java.lang.String name)
This implementation uses an internal {@link HashMap} to get the object that the specified name maps to.

throws
NullPointerException {@inheritDoc}

        if (name == null) {
            throw new NullPointerException("name is null");
        }
        return propMap.get(name);
    
public javax.xml.crypto.URIDereferencergetURIDereferencer()

        return dereferencer;
    
public java.util.Iteratoriterator()
Returns a read-only iterator over the set of Id/Element mappings of this DOMCryptoContext. Attempts to modify the set via the {@link Iterator#remove} method throw an UnsupportedOperationException. The mappings are returned in no particular order. Each element in the iteration is represented as a {@link java.util.Map.Entry}. If the DOMCryptoContext is modified while an iteration is in progress, the results of the iteration are undefined.

return
a read-only iterator over the set of mappings

	return Collections.unmodifiableMap(idMap).entrySet().iterator();
    
public java.lang.Objectput(java.lang.Object key, java.lang.Object value)
This implementation uses an internal {@link HashMap} to map the key to the specified object.

throws
IllegalArgumentException {@inheritDoc}

	return objMap.put(key, value);
    
public java.lang.StringputNamespacePrefix(java.lang.String namespaceURI, java.lang.String prefix)
This implementation uses an internal {@link HashMap} to map the URI to the specified prefix.

throws
NullPointerException {@inheritDoc}

        if (namespaceURI == null) {
            throw new NullPointerException("namespaceURI is null");
        }
        return (String) nsMap.put(namespaceURI, prefix);
    
public voidsetBaseURI(java.lang.String baseURI)

throws
IllegalArgumentException {@inheritDoc}

	if (baseURI != null) {
	    java.net.URI.create(baseURI);
	}
        this.baseURI = baseURI;
    
public voidsetDefaultNamespacePrefix(java.lang.String defaultPrefix)

	this.defaultPrefix = defaultPrefix;
    
public voidsetIdAttributeNS(org.w3c.dom.Element element, java.lang.String namespaceURI, java.lang.String localName)
Registers the element's attribute specified by the namespace URI and local name to be of type ID. The attribute must have a non-empty value.

This implementation uses an internal {@link HashMap} to map the attribute's value to the specified element.

param
element the element
param
namespaceURI the namespace URI of the attribute (specify null if not applicable)
param
localName the local name of the attribute
throws
IllegalArgumentException if localName is not an attribute of the specified element or it does not contain a specific value
throws
NullPointerException if element or localName is null
see
#getElementById

	if (element == null) {
	    throw new NullPointerException("element is null");
	}
	if (localName == null) {
	    throw new NullPointerException("localName is null");
	}
	String idValue = element.getAttributeNS(namespaceURI, localName);
	if (idValue == null || idValue.length() == 0) {
	    throw new IllegalArgumentException(localName + " is not an " +
		"attribute");
	}
	idMap.put(idValue, element);
    
public voidsetKeySelector(javax.xml.crypto.KeySelector ks)

        this.ks = ks;
    
public java.lang.ObjectsetProperty(java.lang.String name, java.lang.Object value)
This implementation uses an internal {@link HashMap} to map the name to the specified object.

throws
NullPointerException {@inheritDoc}

        if (name == null) {
            throw new NullPointerException("name is null");
        }
        return propMap.put(name, value);
    
public voidsetURIDereferencer(javax.xml.crypto.URIDereferencer dereferencer)

        this.dereferencer = dereferencer;