Top Description Fields Constructors Methods
org.glassfish.jaxb.runtime.v2.model.impl

public Class ModelBuilder<T, C, F, M>

extends Object
implements ModelBuilderI<T, C, F, M>
Class Inheritance
All Implemented Interfaces
org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI
Known Direct Subclasses
org.glassfish.jaxb.runtime.v2.model.impl.RuntimeModelBuilder
Imports
jakarta.xml.bind.JAXBElement, jakarta.xml.bind.annotation.XmlAttachmentRef, .XmlRegistry, .XmlSeeAlso, .XmlTransient, org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader, .Locatable, org.glassfish.jaxb.core.v2.model.core.ArrayInfo, .ClassInfo, .ElementInfo, .EnumLeafInfo, .ErrorHandler, .LeafInfo, .NonElement, .PropertyInfo, .PropertyKind, .Ref, .RegistryInfo, .TypeInfo, .TypeInfoSet, org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI, org.glassfish.jaxb.core.v2.model.nav.Navigator, org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException, org.glassfish.jaxb.runtime.v2.model.annotation.ClassLocatable, org.glassfish.jaxb.runtime.v2.model.runtime.RuntimePropertyInfo, javax.xml.namespace.QName, java.lang.reflect.ParameterizedType, .Type, java.util.HashMap, .Map, java.util.logging.Level, .Logger

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.

Author
Kohsuke Kawaguchi ([email protected])

Field Summary

Modifier and TypeField and Description
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.

private ErrorHandler
private boolean
public boolean
hasSwaRef

Set to true if the model includes XmlAttachmentRef.

private boolean
private static final Logger
private final ErrorHandler
public final AnnotationReader<T, C, F, M>
pack-priv final Map<String, RegistryInfoImpl<T, C, F, M>>
registries

Packages whose registries are already added.

private final Map<C, C>
pack-priv final TypeInfoSetImpl<T, C, F, M>
typeInfoSet

TypeInfos that are built will go into this set.

private final Map<QName, TypeInfo<T, C>>
typeNames

Used to detect collisions among global type names.

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
public RegistryInfo<T, C>
addRegistry(C registryClass, Locatable upstream)

Visits a class with XmlRegistry and records all the element mappings in it.

private void
addToRegistry(C
which package will be used
clazz
,
Locatable
location
p
)

Adding package's ObjectFactory methods to registry

private void
addTypeName(NonElement<T, C> r)

Checks the uniqueness of the type name.

protected ArrayInfo<T, C>
createArrayInfo(Locatable upstream, T arrayType)

protected ClassInfo<T, C>
createClassInfo(C clazz, Locatable upstream)

protected ElementInfo<T, C>
createElementInfo(RegistryInfo<T, C> registryInfo, M m)

protected EnumLeafInfo<T, C>
createEnumLeafInfo(C clazz, Locatable upstream)

protected TypeInfoSet<T, C, F, M>
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.

public NonElement<T, C>
getClassInfo(C clazz, boolean searchForSuperClass, Locatable upstream)

For limited cases where the caller needs to search for a super class.

public Navigator<T, C, F, M>
private Class<T>[]

Returns:

null - if it's not JAXBElement property, or it's not parametrized, and array of parametrized classes in other case
getParametrizedTypes
(PropertyInfo<T, C>
property which parametrized types we will try to get
p
)

Getting parametrized classes of JAXBElement<...

public AnnotationReader<T, C, F, M>
public RegistryInfo<T, C>

Returns:

null if no registry exists for the package. unlike other getXXX methods on this class, this method is side-effect free.
getRegistry
(String packageName)

Gets a RegistryInfo for the given package.

public NonElement<T, C>

Returns:

always non-null.
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.

public NonElement<T, C>
getTypeInfo(Ref<T, C> ref)

This method is used to add a root reference to a model.

public boolean
isReplaced(C sc)

public final void
public void
setErrorHandler(ErrorHandler
can be null.
errorHandler
)

Sets the error handler that receives errors discovered during the model building.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

defaultNsUriback to summary
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 "".

errorHandlerback to summary
private ErrorHandler errorHandler
See Also
setErrorHandler
hadErrorback to summary
private boolean hadError
hasSwaRefback to summary
public boolean hasSwaRef

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

linkedback to summary
private boolean linked
loggerback to summary
private static final Logger logger
proxyErrorHandlerback to summary
private final ErrorHandler proxyErrorHandler
readerback to summary
public final AnnotationReader<T, C, F, M> reader
registriesback to summary
pack-priv final Map<String, RegistryInfoImpl<T, C, F, M>> registries

Packages whose registries are already added.

subclassReplacementsback to summary
private final Map<C, C> subclassReplacements
typeInfoSetback to summary
pack-priv final TypeInfoSetImpl<T, C, F, M> typeInfoSet

TypeInfos that are built will go into this set.

typeNamesback to summary
private final Map<QName, TypeInfo<T, C>> typeNames

Used to detect collisions among global type names.

Constructor Detail

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

Method Detail

addRegistryback to summary
public RegistryInfo<T, C> addRegistry(C registryClass, Locatable upstream)

Visits a class with XmlRegistry and records all the element mappings in it.

addToRegistryback to summary
private void addToRegistry(C clazz, Locatable p)

Adding package's ObjectFactory methods to registry

Parameters
clazz:C

which package will be used

p:Locatable

location

addTypeNameback to summary
private void addTypeName(NonElement<T, C> r)

Checks the uniqueness of the type name.

createArrayInfoback to summary
protected ArrayInfo<T, C> createArrayInfo(Locatable upstream, T arrayType)
createClassInfoback to summary
protected ClassInfo<T, C> createClassInfo(C clazz, Locatable upstream)
createElementInfoback to summary
protected ElementInfo<T, C> createElementInfo(RegistryInfo<T, C> registryInfo, M m) throws IllegalAnnotationException
createEnumLeafInfoback to summary
protected EnumLeafInfo<T, C> createEnumLeafInfo(C clazz, Locatable upstream)
createTypeInfoSetback to summary
protected TypeInfoSet<T, C, F, M> createTypeInfoSet()
getClassInfoback to summary
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)

getClassInfoback to summary
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.

getNavigatorback to summary
public Navigator<T, C, F, M> getNavigator()

Implements org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI.getNavigator.

Annotations
@Override
getParametrizedTypesback to summary
private Class<T>[] getParametrizedTypes(PropertyInfo<T, C> p)

Getting parametrized classes of JAXBElement<...> property

Parameters
p:PropertyInfo<T, C>

property which parametrized types we will try to get

Returns:Class<T>[]

null - if it's not JAXBElement property, or it's not parametrized, and array of parametrized classes in other case

getReaderback to summary
public AnnotationReader<T, C, F, M> getReader()

Implements org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI.getReader.

Annotations
@Override
getRegistryback to summary
public RegistryInfo<T, C> getRegistry(String packageName)

Gets a RegistryInfo for the given package.

Returns:RegistryInfo<T, C>

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

getTypeInfoback to summary
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:NonElement<T, C>

always non-null.

getTypeInfoback to summary
public NonElement<T, C> getTypeInfo(Ref<T, C> ref)

This method is used to add a root reference to a model.

isReplacedback to summary
public boolean isReplaced(C sc)
reportErrorback to summary
public final void reportError(IllegalAnnotationException e)
setErrorHandlerback to summary
public void setErrorHandler(ErrorHandler errorHandler)

Sets the error handler that receives errors discovered during the model building.

Parameters
errorHandler:ErrorHandler

can be null.