org.codehaus.enunciate
Class XmlQNameEnumUtil

java.lang.Object
  extended by org.codehaus.enunciate.XmlQNameEnumUtil

public class XmlQNameEnumUtil
extends java.lang.Object

Utilities for converting a QName to/from an QNameEnum. See QName Enums.

Author:
Ryan Heaton

Method Summary
static
<Q extends java.lang.Enum<Q>>
Q
fromQName(javax.xml.namespace.QName qname, java.lang.Class<Q> clazz)
          Convert a QName to a QName enum.
static
<Q extends java.lang.Enum<Q>>
Q
fromURI(java.net.URI uri, java.lang.Class<Q> clazz)
          Convert a URI to a QName enum.
static
<Q extends java.lang.Enum<Q>>
Q
fromURIValue(java.lang.String uriValue, java.lang.Class<Q> clazz)
          Convert a URI to a QName enum.
static
<Q extends java.lang.Enum<Q>>
Q
fromURIValue(java.lang.String uriValue, java.lang.Class<Q> clazz, java.lang.String defaultBaseUri)
          Convert a URI to a QName enum.
static java.lang.String getDefaultBaseUri()
          Get the default base uri for resolving qname URIs.
static boolean isWriteRelativeUris()
          Whether to write URI enums using relative URIs.
static void setDefaultBaseUri(java.lang.String uri)
          Set the default base uri for resolving qname URIs.
static void setWriteRelativeUris(boolean writeRelativeUris)
          Whether to write URI enums using relative URIs.
static javax.xml.namespace.QName toQName(java.lang.Enum e)
          Convert an enum to a QName.
static java.net.URI toURI(java.lang.Enum e)
          Convert an enum to a URI.
static java.lang.String toURIValue(java.lang.Enum e)
          Convert an enum to a URI.
static java.lang.String toURIValue(java.lang.Enum e, java.lang.String defaultBaseUri)
          Convert an enum to a URI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setDefaultBaseUri

public static void setDefaultBaseUri(java.lang.String uri)
Set the default base uri for resolving qname URIs.

Parameters:
uri - The default base URI.

getDefaultBaseUri

public static java.lang.String getDefaultBaseUri()
Get the default base uri for resolving qname URIs.

Returns:
The default base URI.

isWriteRelativeUris

public static boolean isWriteRelativeUris()
Whether to write URI enums using relative URIs.

Returns:
Whether to write URI enums using relative URIs.

setWriteRelativeUris

public static void setWriteRelativeUris(boolean writeRelativeUris)
Whether to write URI enums using relative URIs.

Parameters:
writeRelativeUris - Whether to write URI enums using relative URIs.

fromQName

public static <Q extends java.lang.Enum<Q>> Q fromQName(javax.xml.namespace.QName qname,
                                                        java.lang.Class<Q> clazz)
Convert a QName to a QName enum. See QName Enums.

Parameters:
qname - The qname to convert.
clazz - The enum clazz.
Returns:
The matching enum, or the unknown enum if unable to find an enum for the specified QName, or null if unable to find an enum for the specified QName and there is no unknown enum specified.
Throws:
java.lang.IllegalArgumentException - If clazz isn't a QName enum.

toQName

public static javax.xml.namespace.QName toQName(java.lang.Enum e)
Convert an enum to a QName. See QName Enums.

Parameters:
e - The enum.
Returns:
The QName.
Throws:
java.lang.IllegalArgumentException - If e isn't of a valid QName enum type, or if e is the unknown enum, or if the enum is excluded as an enum value.

fromURI

public static <Q extends java.lang.Enum<Q>> Q fromURI(java.net.URI uri,
                                                      java.lang.Class<Q> clazz)
Convert a URI to a QName enum. See QName Enums.

Parameters:
uri - The uri to convert.
clazz - The enum clazz.
Returns:
The matching enum, or the unknown enum if unable to find an enum for the specified URI, or null if unable to find an enum for the specified URI and there is no unknown enum specified.
Throws:
java.lang.IllegalArgumentException - If clazz isn't a QName enum.

fromURIValue

public static <Q extends java.lang.Enum<Q>> Q fromURIValue(java.lang.String uriValue,
                                                           java.lang.Class<Q> clazz)
Convert a URI to a QName enum. See QName Enums.

Parameters:
uriValue - The value of the uri to convert.
clazz - The enum clazz.
Returns:
The matching enum, or the unknown enum if unable to find an enum for the specified URI, or null if unable to find an enum for the specified URI and there is no unknown enum specified.
Throws:
java.lang.IllegalArgumentException - If clazz isn't a QName enum.

fromURIValue

public static <Q extends java.lang.Enum<Q>> Q fromURIValue(java.lang.String uriValue,
                                                           java.lang.Class<Q> clazz,
                                                           java.lang.String defaultBaseUri)
Convert a URI to a QName enum. See QName Enums.

Parameters:
uriValue - The value of the uri to convert.
clazz - The enum clazz.
defaultBaseUri - The default base uri, used to resolve relative URI references (null is allowed).
Returns:
The matching enum, or the unknown enum if unable to find an enum for the specified URI, or null if unable to find an enum for the specified URI and there is no unknown enum specified.
Throws:
java.lang.IllegalArgumentException - If clazz isn't a QName enum.

toURI

public static java.net.URI toURI(java.lang.Enum e)
Convert an enum to a URI. See QName Enums.

Parameters:
e - The enum.
Returns:
The URI.
Throws:
java.lang.IllegalArgumentException - If e isn't of a valid QName enum type, or if e is the unknown enum, or if the enum is excluded as an enum value.

toURIValue

public static java.lang.String toURIValue(java.lang.Enum e)
Convert an enum to a URI. See QName Enums.

Parameters:
e - The enum.
Returns:
The URI.
Throws:
java.lang.IllegalArgumentException - If e isn't of a valid QName enum type, or if e is the unknown enum, or if the enum is excluded as an enum value.

toURIValue

public static java.lang.String toURIValue(java.lang.Enum e,
                                          java.lang.String defaultBaseUri)
Convert an enum to a URI. See QName Enums.

Parameters:
e - The enum.
defaultBaseUri - The default base uri, used to resolve relative URI references (null is allowed).
Returns:
The URI.
Throws:
java.lang.IllegalArgumentException - If e isn't of a valid QName enum type, or if e is the unknown enum, or if the enum is excluded as an enum value.