org.apache.cxf.aegis.type
Class TypeUtil

java.lang.Object
  extended by org.apache.cxf.aegis.type.TypeUtil

public final class TypeUtil
extends Object

Static methods/constants for Aegis.

Author:
Dan Diephouse

Field Summary
static Logger LOG
           
 
Method Summary
static AegisType getReadType(javax.xml.stream.XMLStreamReader xsr, AegisContext context, AegisType baseType)
           
static AegisType getReadTypeStandalone(javax.xml.stream.XMLStreamReader xsr, AegisContext context, AegisType baseType)
          getReadType cannot just look up the xsi:type in the mapping.
static Type getSingleTypeParameter(Type type)
          Insist that a Type is a parameterized type of one parameter.
static Type getSingleTypeParameter(Type type, int index)
          Insist that a Type is a parameterized type of one parameter.
static Class<?> getTypeClass(Type type, boolean throwForNonClass)
          Utility function to cast a Type to a Class.
static Class<?> getTypeRelatedClass(Type type)
          If a Type is a class, return it as a class.
static AegisType getWriteType(AegisContext globalContext, Object value, AegisType type)
           
static AegisType getWriteTypeStandalone(AegisContext globalContext, Object value, AegisType type)
           
static AegisType getWriteTypeStandalone(AegisContext globalContext, Object value, Type reflectType)
          Allow writing of collections when the type of the collection object is known via an Type object.
static void setAttributeAttributes(QName name, AegisType type, org.apache.ws.commons.schema.XmlSchema root)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

public static final Logger LOG
Method Detail

getReadType

public static AegisType getReadType(javax.xml.stream.XMLStreamReader xsr,
                                    AegisContext context,
                                    AegisType baseType)

getReadTypeStandalone

public static AegisType getReadTypeStandalone(javax.xml.stream.XMLStreamReader xsr,
                                              AegisContext context,
                                              AegisType baseType)
getReadType cannot just look up the xsi:type in the mapping. This function must be called instead at the root where there is no initial mapping to start from, as from a part or an element of some containing item.

Parameters:
xsr -
context -
Returns:

getWriteType

public static AegisType getWriteType(AegisContext globalContext,
                                     Object value,
                                     AegisType type)

getWriteTypeStandalone

public static AegisType getWriteTypeStandalone(AegisContext globalContext,
                                               Object value,
                                               AegisType type)

getWriteTypeStandalone

public static AegisType getWriteTypeStandalone(AegisContext globalContext,
                                               Object value,
                                               Type reflectType)
Allow writing of collections when the type of the collection object is known via an Type object.

Parameters:
globalContext - the context
value - the object to write.
reflectType - the type to use in writing the object.
Returns:

setAttributeAttributes

public static void setAttributeAttributes(QName name,
                                          AegisType type,
                                          org.apache.ws.commons.schema.XmlSchema root)

getTypeClass

public static Class<?> getTypeClass(Type type,
                                    boolean throwForNonClass)
Utility function to cast a Type to a Class. This throws an unchecked exception if the Type is not a Class. The idea here is that these Type references should have been checked for reasonableness before the point of calls to this function.

Parameters:
type - Reflection type.
throwForNonClass - whether to throw (true) or return null (false) if the Type is not a class.
Returns:
the Class

getSingleTypeParameter

public static Type getSingleTypeParameter(Type type)
Insist that a Type is a parameterized type of one parameter. This is used to decompose Holders, for example.

Parameters:
type - the type
Returns:
the parameter, or null if the type is not what we want.

getSingleTypeParameter

public static Type getSingleTypeParameter(Type type,
                                          int index)
Insist that a Type is a parameterized type of one parameter. This is used to decompose Holders, for example.

Parameters:
type - the type
index - which parameter
Returns:
the parameter, or null if the type is not what we want.

getTypeRelatedClass

public static Class<?> getTypeRelatedClass(Type type)
If a Type is a class, return it as a class. If it is a ParameterizedType, return the raw type as a class. Otherwise return null.

Parameters:
type -
Returns:


Apache CXF