Oxygen XML Editor 12.2 Author API

ro.sync.xml
Class ProxyNamespaceMapping

java.lang.Object
  extended by ro.sync.xml.ProxyNamespaceMapping
All Implemented Interfaces:
java.lang.Cloneable

public class ProxyNamespaceMapping
extends java.lang.Object
implements java.lang.Cloneable

Stores the mappings between the namespace prefixes and the URI's. It is mainly used in the content completion process. The implementation consists in two lists. The modifying operations are performed at the end of the lists. Note that duplicates can exist in the mappings.


Constructor Summary
ProxyNamespaceMapping()
          Constructor.
ProxyNamespaceMapping(org.w3c.dom.Node node)
          Constructor.
 
Method Summary
 void addMapping(java.lang.String prefix, java.lang.String namespace)
          Adds a prefix-namespace mapping.
 void clear()
          Clear all mappings.
 java.lang.Object clone()
          Clones the prefix namespace mapping.
 ProxyNamespaceMapping getMappingsFromAncestor(ProxyNamespaceMapping prefixNamespaceMapping)
          Get mapping from ancestor, by removing from the current one the given mappings.
 java.lang.String getNamespaceForAttributePrefix(java.lang.String prefix)
          Gets the URI namespace for the specified attribute prefix.
 java.lang.String getNamespaceForPrefix(java.lang.String prefix)
          Gets the URI namespace for the specified prefix.
 java.util.Set<java.lang.String> getNamespaces()
          Get all the namespaces encountered so far.
 java.lang.String getPrefixForAttributeNamespace(java.lang.String namespace)
          Gets the prefix namespace for the specified namespace URI ignoring the default namespaces as they do not apply for attributes.
 java.lang.String getPrefixForNamespace(java.lang.String namespace)
          Gets the prefix namespace for the specified namespace URI.
protected  java.lang.String getPrefixForNamespace(java.lang.String namespace, boolean allowDefault)
          Gets the prefix namespace for the specified namespace URI ignoring or not the default namespaces as depending on the allowDefault value.
 java.util.List<java.lang.String> getProxies()
          Get the prefixes from the mapping.
 void removeByNamespace(java.lang.String namespace)
          Removes a mapping by indicating the namespace.
 void removeByPrefix(java.lang.String prefix)
          Removes a mapping by indicating the prefix.
 void removeLastMapping()
          Removes the last mapping.
 java.lang.String toString()
           
 void update(org.w3c.dom.Node node)
          Updates the content of the prefix namespace mapping based on a node and its parents.
 void updateNamespaceProxyMapping(java.lang.String namespace, java.lang.String prefix)
          Update a currently available namespace prefix mapping.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProxyNamespaceMapping

public ProxyNamespaceMapping(org.w3c.dom.Node node)
Constructor. Adds the default namespace mapping.

Parameters:
node - The context node, DOM Level 1, the prefix namespace mapping will be populated based on the xmlns attributes, starting with the root element.

ProxyNamespaceMapping

public ProxyNamespaceMapping()
Constructor. Adds the default namespace.

Method Detail

update

public void update(org.w3c.dom.Node node)
Updates the content of the prefix namespace mapping based on a node and its parents. All previous content is lost.

Parameters:
node - The node, must be DOM Level 1.

addMapping

public void addMapping(java.lang.String prefix,
                       java.lang.String namespace)
Adds a prefix-namespace mapping.

Parameters:
prefix - The prefix string.
namespace - The namespace string.

getNamespaceForAttributePrefix

public java.lang.String getNamespaceForAttributePrefix(java.lang.String prefix)
Gets the URI namespace for the specified attribute prefix. It handles specially the case when we have no prefix (that means no namespace in case of attributes)and delegates to the getNamespaceForPrefix(String) otherwise.

Parameters:
prefix - The prefix string.
Returns:
The namespace URI or null.

getNamespaceForPrefix

public java.lang.String getNamespaceForPrefix(java.lang.String prefix)
Gets the URI namespace for the specified prefix. If the prefix is null, the URI will be the empty string.

Parameters:
prefix - The prefix string.
Returns:
The namespace URI or null.

getPrefixForNamespace

public java.lang.String getPrefixForNamespace(java.lang.String namespace)
Gets the prefix namespace for the specified namespace URI.

Parameters:
namespace - The namespace URI.
Returns:
The prefix or null.

getPrefixForAttributeNamespace

public java.lang.String getPrefixForAttributeNamespace(java.lang.String namespace)
Gets the prefix namespace for the specified namespace URI ignoring the default namespaces as they do not apply for attributes.

Parameters:
namespace - The namespace URI of an attribute.
Returns:
The prefix or null.

getPrefixForNamespace

protected final java.lang.String getPrefixForNamespace(java.lang.String namespace,
                                                       boolean allowDefault)
Gets the prefix namespace for the specified namespace URI ignoring or not the default namespaces as depending on the allowDefault value.

Parameters:
namespace - The namespace URI of an attribute.
allowDefault - True if default namespace should be allowed.
Returns:
The prefix or null.

removeByPrefix

public void removeByPrefix(java.lang.String prefix)
Removes a mapping by indicating the prefix. In fact it removes the last mapping pair having the same prefix.

Parameters:
prefix - The prefix string (not null).

removeByNamespace

public void removeByNamespace(java.lang.String namespace)
Removes a mapping by indicating the namespace.

Parameters:
namespace - The namespace URI(not null).

clear

public void clear()
Clear all mappings.


toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the prefix to namespace associations as a string.

removeLastMapping

public void removeLastMapping()
Removes the last mapping.


getNamespaces

public java.util.Set<java.lang.String> getNamespaces()
Get all the namespaces encountered so far. EXM-8111 Make this a linked hash set because the order may count.

Returns:
A set containing all the namespaces we encountered.

clone

public java.lang.Object clone()
Clones the prefix namespace mapping.

Overrides:
clone in class java.lang.Object

getProxies

public java.util.List<java.lang.String> getProxies()
Get the prefixes from the mapping.

Returns:
The list of prefixes, including the "" mapping.

getMappingsFromAncestor

public ProxyNamespaceMapping getMappingsFromAncestor(ProxyNamespaceMapping prefixNamespaceMapping)
Get mapping from ancestor, by removing from the current one the given mappings.

Parameters:
prefixNamespaceMapping - The prefix namespace mapping that must be removed from the current one.
Returns:
A new prefix namespace mapping as difference between the current and the given mappings (the entries are distinct).

updateNamespaceProxyMapping

public void updateNamespaceProxyMapping(java.lang.String namespace,
                                        java.lang.String prefix)
Update a currently available namespace prefix mapping.

Parameters:
namespace - The namespace.
prefix - New prefix.

Oxygen XML Editor 12.2 Author API

© Copyright SyncRO Soft SRL 2002 - 2010.