com.evolveum.midpoint.prism.xml
Class GlobalDynamicNamespacePrefixMapper

java.lang.Object
  extended by com.sun.xml.bind.marshaller.NamespacePrefixMapper
      extended by com.evolveum.midpoint.prism.xml.GlobalDynamicNamespacePrefixMapper
All Implemented Interfaces:
DynamicNamespacePrefixMapper, Dumpable

public class GlobalDynamicNamespacePrefixMapper
extends com.sun.xml.bind.marshaller.NamespacePrefixMapper
implements DynamicNamespacePrefixMapper, Dumpable

Maps namespaces to preferred prefixes. Should be used through the code to avoid generation of prefixes. Although this is usually used as singleton (static), it can also be instantiated to locally override some namespace mappings. This is useful for prefixes like "tns" (schema) or "ri" (resource schema).

Author:
Igor Farinic, Radovan Semancik
See Also:
MID-349

Constructor Summary
GlobalDynamicNamespacePrefixMapper()
           
 
Method Summary
 GlobalDynamicNamespacePrefixMapper clone()
           
 String dump()
          Show the content of the object intended for diagnostics by developer.
 String getDefaultNamespace()
           
static String getPreferredPrefix(String namespace)
           
static String getPreferredPrefix(String namespace, String hintPrefix)
           
 String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix)
           
 String getPrefix(String namespace)
           
 String getPrefixExplicit(String namespace)
           
 boolean isAlwaysExplicit()
           
 void registerPrefix(String namespace, String prefix, boolean isDefaultNamespace)
           
static void registerPrefixGlobal(String namespace, String prefix)
           
 void registerPrefixLocal(String namespace, String prefix)
           
 void setAlwaysExplicit(boolean alwaysExplicit)
           
 void setDefaultNamespace(String defaultNamespace)
           
 QName setQNamePrefix(QName qname)
           
 QName setQNamePrefixExplicit(QName qname)
          Makes sure that there is explicit prefix and not a default namespace prefix.
 
Methods inherited from class com.sun.xml.bind.marshaller.NamespacePrefixMapper
getContextualNamespaceDecls, getPreDeclaredNamespaceUris, getPreDeclaredNamespaceUris2
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalDynamicNamespacePrefixMapper

public GlobalDynamicNamespacePrefixMapper()
Method Detail

getDefaultNamespace

public String getDefaultNamespace()

setDefaultNamespace

public void setDefaultNamespace(String defaultNamespace)

isAlwaysExplicit

public boolean isAlwaysExplicit()
Specified by:
isAlwaysExplicit in interface DynamicNamespacePrefixMapper

setAlwaysExplicit

public void setAlwaysExplicit(boolean alwaysExplicit)
Specified by:
setAlwaysExplicit in interface DynamicNamespacePrefixMapper

registerPrefix

public void registerPrefix(String namespace,
                           String prefix,
                           boolean isDefaultNamespace)
Specified by:
registerPrefix in interface DynamicNamespacePrefixMapper

registerPrefixGlobal

public static void registerPrefixGlobal(String namespace,
                                        String prefix)

registerPrefixLocal

public void registerPrefixLocal(String namespace,
                                String prefix)
Specified by:
registerPrefixLocal in interface DynamicNamespacePrefixMapper

getPrefix

public String getPrefix(String namespace)
Specified by:
getPrefix in interface DynamicNamespacePrefixMapper

getPrefixExplicit

public String getPrefixExplicit(String namespace)

setQNamePrefix

public QName setQNamePrefix(QName qname)
Specified by:
setQNamePrefix in interface DynamicNamespacePrefixMapper

setQNamePrefixExplicit

public QName setQNamePrefixExplicit(QName qname)
Description copied from interface: DynamicNamespacePrefixMapper
Makes sure that there is explicit prefix and not a default namespace prefix.

Specified by:
setQNamePrefixExplicit in interface DynamicNamespacePrefixMapper

getPreferredPrefix

public String getPreferredPrefix(String namespaceUri,
                                 String suggestion,
                                 boolean requirePrefix)
Specified by:
getPreferredPrefix in class com.sun.xml.bind.marshaller.NamespacePrefixMapper

getPreferredPrefix

public static String getPreferredPrefix(String namespace)
Parameters:
namespace -
Returns:
preferred prefix for the namespace, if no prefix is assigned yet, then it will assign a prefix and return it.

getPreferredPrefix

public static String getPreferredPrefix(String namespace,
                                        String hintPrefix)
Parameters:
namespace -
hintPrefix -
Returns:
preferred prefix for the namespace, if no prefix is assigned yet, then it assign hint prefix (if it is not assigned yet) or assign a new prefix and return it (if hint prefix is already assigned to other namespace).

clone

public GlobalDynamicNamespacePrefixMapper clone()
Specified by:
clone in interface DynamicNamespacePrefixMapper
Overrides:
clone in class Object

dump

public String dump()
Description copied from interface: Dumpable
Show the content of the object intended for diagnostics by developer. The content may be multi-line, in case of hierarchical objects it may be intended. The use of this method may not be efficient. It is not supposed to be used in normal operation. However, it is very useful in tests or in case of dumping objects in severe error situations.

Specified by:
dump in interface Dumpable
Returns:
content of the object intended for diagnostics.


Copyright © 2013 evolveum. All Rights Reserved.