Top Description Fields Constructors Methods
com.sun.tools.xjc.reader

public final Class TypeUtil

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Collection, .Collections, .Comparator, .Iterator, .List, .Set, .TreeSet, com.sun.codemodel.JClass, .JCodeModel, .JDefinedClass, .JType, com.sun.tools.xjc.ErrorReceiver, org.xml.sax.Locator

Type-related utility methods.
Author
Kohsuke KAWAGUCHI

Field Summary

Modifier and TypeField and Description
private static final Comparator<JType>
typeComparator

Compares JType objects by their names.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static Set<JClass>
private static void
getAssignableTypes(JClass t, Set<JClass> s)

Returns the set of all classes/interfaces that a given type implements/extends, including itself.

public static JType
getCommonBaseType(JCodeModel codeModel, Collection<? extends JType>
set of JType objects.
types
)

Computes the common base type of two types.

public static JType
getCommonBaseType(JCodeModel codeModel, JType... t)

Computes the common base type of types.

public static JType
getType(JCodeModel codeModel, String typeName, ErrorReceiver errorHandler, Locator errorSource)

Obtains a JType object for the string representation of a type.

private static JClass
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

typeComparatorback to summary
private static final Comparator<JType> typeComparator

Compares JType objects by their names.

Constructor Detail

TypeUtilback to summary
private TypeUtil()

Method Detail

getAssignableTypesback to summary
private static Set<JClass> getAssignableTypes(JClass t)
getAssignableTypesback to summary
private static void getAssignableTypes(JClass t, Set<JClass> s)

Returns the set of all classes/interfaces that a given type implements/extends, including itself. For example, if you pass java.io.FilterInputStream, then the returned set will contain java.lang.Object, java.lang.InputStream, and java.lang.FilterInputStream.

getCommonBaseTypeback to summary
public static JType getCommonBaseType(JCodeModel codeModel, Collection<? extends JType> types)

Computes the common base type of two types.

Parameters
types:Collection<? extends JType>

set of JType objects.

getCommonBaseTypeback to summary
public static JType getCommonBaseType(JCodeModel codeModel, JType... t)

Computes the common base type of types.

Todo

this is a very interesting problem. Since one type has possibly multiple base types, it's not an easy problem. The current implementation is very naive. To make the result deterministic across differente JVMs, we have to use a Set whose ordering is deterministic.

getTypeback to summary
public static JType getType(JCodeModel codeModel, String typeName, ErrorReceiver errorHandler, Locator errorSource)

Obtains a JType object for the string representation of a type.

pickOneback to summary
private static JClass pickOne(Set<JClass> s)