org.gedcomx.rt
Class GedcomNamespaceManager

java.lang.Object
  extended by com.sun.xml.bind.marshaller.NamespacePrefixMapper
      extended by org.gedcomx.rt.GedcomNamespaceManager

public class GedcomNamespaceManager
extends com.sun.xml.bind.marshaller.NamespacePrefixMapper

A nice namespace prefix mapper that can be used to make XML and JSON output as pretty as it can be.

Author:
Ryan Heaton

Constructor Summary
GedcomNamespaceManager()
           
GedcomNamespaceManager(Class<?> rootClass)
           
GedcomNamespaceManager(Map<String,String> overrides)
           
GedcomNamespaceManager(Map<String,String> overrides, String defaultns)
           
GedcomNamespaceManager(String defaultns)
           
 
Method Summary
static QName findWrapperNameForJsonName(String jsonName)
          Get the wrapper name for the specified json name.
static String getJsonName(Class<?> type)
          Get the JSON name for the specified type.
static String getJsonNameForWrapperName(QName wrapperName)
          Get the json wrapper name for the specified XML element name.
static Class<?> getKnownJsonType(String jsonName)
          Get the known type for the given JSON name.
static Map<String,String> getKnownPrefixes()
          The known set of namespace-to-prefix mappings.
static Class<?> getKnownTypeById(String typeId)
          Get the known type for the given data type.
 String getPreferredPrefix(String namespaceUri, String suggestion, boolean requirePrefix)
           
static String getRuntimeVersion(String namespace)
          Get the version of the runtime java library that defines the model for the given namespace.
static String getTypeIdName(Class<?> type)
          Get the id for the specified type.
static Class<?> getWrappedTypeForJsonName(String jsonName)
          Get the type of the wrapped object for the specified json name.
protected static void init(ClassLoader loader)
           
static String nameFromQName(String namespaceUri, String localPart)
           
static void registerKnownJsonType(Class<?> type)
          Register a known JSON type.
 
Methods inherited from class com.sun.xml.bind.marshaller.NamespacePrefixMapper
getContextualNamespaceDecls, getPreDeclaredNamespaceUris, getPreDeclaredNamespaceUris2
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GedcomNamespaceManager

public GedcomNamespaceManager(Class<?> rootClass)

GedcomNamespaceManager

public GedcomNamespaceManager(Map<String,String> overrides,
                              String defaultns)

GedcomNamespaceManager

public GedcomNamespaceManager(String defaultns)

GedcomNamespaceManager

public GedcomNamespaceManager(Map<String,String> overrides)

GedcomNamespaceManager

public GedcomNamespaceManager()
Method Detail

getKnownPrefixes

public static Map<String,String> getKnownPrefixes()
The known set of namespace-to-prefix mappings.

Returns:
The known set of namespace-to-prefix mappings.

init

protected static void init(ClassLoader loader)

nameFromQName

public static String nameFromQName(String namespaceUri,
                                   String localPart)

getPreferredPrefix

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

getJsonNameForWrapperName

public static String getJsonNameForWrapperName(QName wrapperName)
Get the json wrapper name for the specified XML element name.

Parameters:
wrapperName - The identifier for the wrapper name.
Returns:
The json wrapper name, or null if none.

findWrapperNameForJsonName

public static QName findWrapperNameForJsonName(String jsonName)
Get the wrapper name for the specified json name.

Parameters:
jsonName - The json name.
Returns:
The wrapper qname.

getWrappedTypeForJsonName

public static Class<?> getWrappedTypeForJsonName(String jsonName)
Get the type of the wrapped object for the specified json name.

Parameters:
jsonName - The json name.
Returns:
The wrapped type.

registerKnownJsonType

public static void registerKnownJsonType(Class<?> type)
Register a known JSON type. It must be annotated with either @JsonElementWrapper or @XmlRootElement.

Parameters:
type - the type to register.

getJsonName

public static String getJsonName(Class<?> type)
Get the JSON name for the specified type.

Parameters:
type - The type.
Returns:
The json name.

getTypeIdName

public static String getTypeIdName(Class<?> type)
Get the id for the specified type.

Parameters:
type - The type.
Returns:
The type id.

getKnownJsonType

public static Class<?> getKnownJsonType(String jsonName)
Get the known type for the given JSON name.

Parameters:
jsonName - The json name.
Returns:
The known type, or null if not known.

getKnownTypeById

public static Class<?> getKnownTypeById(String typeId)
Get the known type for the given data type.

Parameters:
typeId - The type id.
Returns:
The known type, or null if not known.

getRuntimeVersion

public static String getRuntimeVersion(String namespace)
Get the version of the runtime java library that defines the model for the given namespace.

Parameters:
namespace - The model namespace.
Returns:
The runtime version.


Copyright © 2016. All rights reserved.