Oxygen XML Editor 11.2 Author API

ro.sync.xml
Class ProxyNamespaceMapping

java.lang.Object
  extended by ro.sync.xml.ProxyNamespaceMapping

public class ProxyNamespaceMapping
extends Object

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(Node node)
          Constructor.
 
Method Summary
 void addMapping(String prefix, String namespace)
          Adds a prefix-namespace mapping.
 void clear()
          Clear all mappings.
 Object clone()
          Clones the prefix namespace mapping.
 ProxyNamespaceMapping getMappingsFromAncestor(ProxyNamespaceMapping prefixNamespaceMapping)
          Get mapping from ancestor, by removing from the current one the given mappings.
 String getNamespaceForAttributePrefix(String prefix)
          Gets the URI namespace for the specified attribute prefix.
 String getNamespaceForPrefix(String prefix)
          Gets the URI namespace for the specified prefix.
 Set<String> getNamespaces()
          Get all the namespaces encountered so far.
 String getPrefixForAttributeNamespace(String namespace)
          Gets the prefix namespace for the specified namespace URI ignoring the default namespaces as they do not apply for attributes.
 String getPrefixForNamespace(String namespace)
          Gets the prefix namespace for the specified namespace URI.
protected  String getPrefixForNamespace(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.
 List<String> getProxies()
          Get the prefixes from the mapping.
 void removeByNamespace(String namespace)
          Removes a mapping by indicating the namespace.
 void removeByPrefix(String prefix)
          Removes a mapping by indicating the prefix.
 void removeLastMapping()
          Removes the last mapping.
 String toString()
           
 void update(Node node)
          Updates the content of the prefix namespace mapping based on a node and its parents.
 void updateNamespaceProxyMapping(String namespace, 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(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(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(String prefix,
                       String namespace)
Adds a prefix-namespace mapping.

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

getNamespaceForAttributePrefix

public String getNamespaceForAttributePrefix(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 String getNamespaceForPrefix(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 String getPrefixForNamespace(String namespace)
Gets the prefix namespace for the specified namespace URI.

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

getPrefixForAttributeNamespace

public String getPrefixForAttributeNamespace(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 String getPrefixForNamespace(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(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(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 String toString()
Overrides:
toString in class Object
Returns:
the prefix to namespace associations as a string.

removeLastMapping

public void removeLastMapping()
Removes the last mapping.


getNamespaces

public Set<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 Object clone()
Clones the prefix namespace mapping.

Overrides:
clone in class Object

getProxies

public List<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(String namespace,
                                        String prefix)
Update a currently available namespace prefix mapping.

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

Oxygen XML Editor 11.2 Author API

© Copyright SyncRO Soft SRL 2002 - 2010.