com.sun.xml.bind.v2.model.impl

Class ModelBuilder<T,C,F,M>

public class ModelBuilder<T,C,F,M> extends Object

Builds a TypeInfoSet (a set of JAXB properties) by using ElementInfoImpl and ClassInfoImpl. from annotated Java classes.

This class uses Navigator and AnnotationReader to work with arbitrary annotation source and arbitrary Java model. For this purpose this class is parameterized.

Field Summary
StringdefaultNsUri
JAXB doesn't want to use namespaces unless we are told to, but WS-I BP conformace requires JAX-RPC to always use a non-empty namespace URI. (see http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#WSDLTYPES R2105)

To work around this issue, we allow the use of the empty namespaces to be replaced by a particular designated namespace URI.

booleanhasSwaRef
Set to true if the model includes XmlAttachmentRef.
Navigator<T,C,F,M>nav
AnnotationReader<T,C,F,M>reader
Map<String,RegistryInfoImpl<T,C,F,M>>registries
Packages whose registries are already added.
TypeInfoSetImpl<T,C,F,M>typeInfoSet
TypeInfos that are built will go into this set.
Constructor Summary
ModelBuilder(AnnotationReader<T,C,F,M> reader, Navigator<T,C,F,M> navigator, Map<C,C> subclassReplacements, String defaultNamespaceRemap)
Method Summary
RegistryInfo<T,C>addRegistry(C registryClass, Locatable upstream)
Visits a class with XmlRegistry and records all the element mappings in it.
protected ArrayInfoImpl<T,C,F,M>createArrayInfo(Locatable upstream, T arrayType)
protected ClassInfoImpl<T,C,F,M>createClassInfo(C clazz, Locatable upstream)
protected ElementInfoImpl<T,C,F,M>createElementInfo(RegistryInfoImpl<T,C,F,M> registryInfo, M m)
protected EnumLeafInfoImpl<T,C,F,M>createEnumLeafInfo(C clazz, Locatable upstream)
protected TypeInfoSetImpl<T,C,F,M>createTypeInfoSet()
Makes sure that we don't have conflicting 1.0 runtime, and report an error if we do.
NonElement<T,C>getClassInfo(C clazz, Locatable upstream)
Builds a JAXB ClassInfo model from a given class declaration and adds that to this model owner.
NonElement<T,C>getClassInfo(C clazz, boolean searchForSuperClass, Locatable upstream)
For limited cases where the caller needs to search for a super class.
RegistryInfo<T,C>getRegistry(String packageName)
Gets a RegistryInfo for the given package.
NonElement<T,C>getTypeInfo(T t, Locatable upstream)
Have the builder recognize the type (if it hasn't done so yet), and returns a NonElement that represents it.
NonElement<T,C>getTypeInfo(Ref<T,C> ref)
This method is used to add a root reference to a model.
booleanisReplaced(C sc)
TypeInfoSet<T,C,F,M>link()
Called after all the classes are added to the type set to "link" them together.
voidreportError(IllegalAnnotationException e)
voidsetErrorHandler(ErrorHandler errorHandler)
Sets the error handler that receives errors discovered during the model building.

Field Detail

defaultNsUri

public final String defaultNsUri
JAXB doesn't want to use namespaces unless we are told to, but WS-I BP conformace requires JAX-RPC to always use a non-empty namespace URI. (see http://www.ws-i.org/Profiles/BasicProfile-1.0-2004-04-16.html#WSDLTYPES R2105)

To work around this issue, we allow the use of the empty namespaces to be replaced by a particular designated namespace URI.

This field keeps the value of that replacing namespace URI. When there's no replacement, this field is set to "".

hasSwaRef

public boolean hasSwaRef
Set to true if the model includes XmlAttachmentRef. JAX-WS needs to know this information.

nav

public final Navigator<T,C,F,M> nav

reader

public final AnnotationReader<T,C,F,M> reader

registries

final Map<String,RegistryInfoImpl<T,C,F,M>> registries
Packages whose registries are already added.

typeInfoSet

final TypeInfoSetImpl<T,C,F,M> typeInfoSet
TypeInfos that are built will go into this set.

Constructor Detail

ModelBuilder

public ModelBuilder(AnnotationReader<T,C,F,M> reader, Navigator<T,C,F,M> navigator, Map<C,C> subclassReplacements, String defaultNamespaceRemap)

Method Detail

addRegistry

public RegistryInfo<T,C> addRegistry(C registryClass, Locatable upstream)
Visits a class with XmlRegistry and records all the element mappings in it.

createArrayInfo

protected ArrayInfoImpl<T,C,F,M> createArrayInfo(Locatable upstream, T arrayType)

createClassInfo

protected ClassInfoImpl<T,C,F,M> createClassInfo(C clazz, Locatable upstream)

createElementInfo

protected ElementInfoImpl<T,C,F,M> createElementInfo(RegistryInfoImpl<T,C,F,M> registryInfo, M m)

createEnumLeafInfo

protected EnumLeafInfoImpl<T,C,F,M> createEnumLeafInfo(C clazz, Locatable upstream)

createTypeInfoSet

protected TypeInfoSetImpl<T,C,F,M> createTypeInfoSet()
Makes sure that we don't have conflicting 1.0 runtime, and report an error if we do.

getClassInfo

public NonElement<T,C> getClassInfo(C clazz, Locatable upstream)
Builds a JAXB ClassInfo model from a given class declaration and adds that to this model owner.

Return type is either ClassInfo or LeafInfo (for types like String or Enum-derived ones)

getClassInfo

public NonElement<T,C> getClassInfo(C clazz, boolean searchForSuperClass, Locatable upstream)
For limited cases where the caller needs to search for a super class. This is necessary because we don't want subclassReplacements to kick in for the super class search, which will cause infinite recursion.

getRegistry

public RegistryInfo<T,C> getRegistry(String packageName)
Gets a RegistryInfo for the given package.

Returns: null if no registry exists for the package. unlike other getXXX methods on this class, this method is side-effect free.

getTypeInfo

public NonElement<T,C> getTypeInfo(T t, Locatable upstream)
Have the builder recognize the type (if it hasn't done so yet), and returns a NonElement that represents it.

Returns: always non-null.

getTypeInfo

public NonElement<T,C> getTypeInfo(Ref<T,C> ref)
This method is used to add a root reference to a model.

isReplaced

public boolean isReplaced(C sc)

link

public TypeInfoSet<T,C,F,M> link()
Called after all the classes are added to the type set to "link" them together.

Don't expose implementation classes in the signature.

Returns: fully built TypeInfoSet that represents the model, or null if there was an error.

reportError

public final void reportError(IllegalAnnotationException e)

setErrorHandler

public void setErrorHandler(ErrorHandler errorHandler)
Sets the error handler that receives errors discovered during the model building.

Parameters: errorHandler can be null.