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

  • All Implemented Interfaces:
    org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI<T,​C,​F,​M>
    Direct Known Subclasses:
    RuntimeModelBuilder

    public class ModelBuilder<T,​C,​F,​M>
    extends Object
    implements org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI<T,​C,​F,​M>
    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 (kohsuke.kawaguchi@sun.com)
    • Field Summary

      Fields 
      Modifier and Type Field Description
      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.
      boolean hasSwaRef
      Set to true if the model includes XmlAttachmentRef.
      org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> nav  
      org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> reader  
    • Constructor Summary

      Constructors 
      Constructor Description
      ModelBuilder​(org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> reader, org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> navigator, Map<C,​C> subclassReplacements, String defaultNamespaceRemap)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.glassfish.jaxb.core.v2.model.core.RegistryInfo<T,​C> addRegistry​(C registryClass, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      Visits a class with XmlRegistry and records all the element mappings in it.
      protected org.glassfish.jaxb.core.v2.model.core.ArrayInfo<T,​C> createArrayInfo​(org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream, T arrayType)  
      protected org.glassfish.jaxb.core.v2.model.core.ClassInfo<T,​C> createClassInfo​(C clazz, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)  
      protected org.glassfish.jaxb.core.v2.model.core.ElementInfo<T,​C> createElementInfo​(org.glassfish.jaxb.core.v2.model.core.RegistryInfo<T,​C> registryInfo, M m)  
      protected org.glassfish.jaxb.core.v2.model.core.EnumLeafInfo<T,​C> createEnumLeafInfo​(C clazz, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)  
      protected org.glassfish.jaxb.core.v2.model.core.TypeInfoSet<T,​C,​F,​M> createTypeInfoSet()  
      org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getClassInfo​(C clazz, boolean searchForSuperClass, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      For limited cases where the caller needs to search for a super class.
      org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getClassInfo​(C clazz, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      Builds a JAXB ClassInfo model from a given class declaration and adds that to this model owner.
      org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> getNavigator()  
      org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> getReader()  
      org.glassfish.jaxb.core.v2.model.core.RegistryInfo<T,​C> getRegistry​(String packageName)
      Gets a RegistryInfo for the given package.
      org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getTypeInfo​(org.glassfish.jaxb.core.v2.model.core.Ref<T,​C> ref)
      This method is used to add a root reference to a model.
      org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getTypeInfo​(T t, org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      Have the builder recognize the type (if it hasn't done so yet), and returns a NonElement that represents it.
      boolean isReplaced​(C sc)  
      org.glassfish.jaxb.core.v2.model.core.TypeInfoSet<T,​C,​F,​M> link()
      Called after all the classes are added to the type set to "link" them together.
      void reportError​(org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException e)  
      void setErrorHandler​(org.glassfish.jaxb.core.v2.model.core.ErrorHandler errorHandler)
      Sets the error handler that receives errors discovered during the model building.
    • Field Detail

      • reader

        public final org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> reader
      • nav

        public final org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> nav
      • 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.
    • Constructor Detail

      • ModelBuilder

        public ModelBuilder​(org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> reader,
                            org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> navigator,
                            Map<C,​C> subclassReplacements,
                            String defaultNamespaceRemap)
    • Method Detail

      • createTypeInfoSet

        protected org.glassfish.jaxb.core.v2.model.core.TypeInfoSet<T,​C,​F,​M> createTypeInfoSet()
      • getClassInfo

        public org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getClassInfo​(C clazz,
                                                                                        org.glassfish.jaxb.core.v2.model.annotation.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 org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getClassInfo​(C clazz,
                                                                                        boolean searchForSuperClass,
                                                                                        org.glassfish.jaxb.core.v2.model.annotation.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.
      • getTypeInfo

        public org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getTypeInfo​(T t,
                                                                                       org.glassfish.jaxb.core.v2.model.annotation.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 org.glassfish.jaxb.core.v2.model.core.NonElement<T,​C> getTypeInfo​(org.glassfish.jaxb.core.v2.model.core.Ref<T,​C> ref)
        This method is used to add a root reference to a model.
      • createEnumLeafInfo

        protected org.glassfish.jaxb.core.v2.model.core.EnumLeafInfo<T,​C> createEnumLeafInfo​(C clazz,
                                                                                                   org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      • createClassInfo

        protected org.glassfish.jaxb.core.v2.model.core.ClassInfo<T,​C> createClassInfo​(C clazz,
                                                                                             org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
      • createElementInfo

        protected org.glassfish.jaxb.core.v2.model.core.ElementInfo<T,​C> createElementInfo​(org.glassfish.jaxb.core.v2.model.core.RegistryInfo<T,​C> registryInfo,
                                                                                                 M m)
                                                                                          throws org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException
        Throws:
        org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException
      • createArrayInfo

        protected org.glassfish.jaxb.core.v2.model.core.ArrayInfo<T,​C> createArrayInfo​(org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream,
                                                                                             T arrayType)
      • addRegistry

        public org.glassfish.jaxb.core.v2.model.core.RegistryInfo<T,​C> addRegistry​(C registryClass,
                                                                                         org.glassfish.jaxb.core.v2.model.annotation.Locatable upstream)
        Visits a class with XmlRegistry and records all the element mappings in it.
      • getRegistry

        public org.glassfish.jaxb.core.v2.model.core.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.
      • link

        public org.glassfish.jaxb.core.v2.model.core.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.
      • setErrorHandler

        public void setErrorHandler​(org.glassfish.jaxb.core.v2.model.core.ErrorHandler errorHandler)
        Sets the error handler that receives errors discovered during the model building.
        Parameters:
        errorHandler - can be null.
      • reportError

        public final void reportError​(org.glassfish.jaxb.core.v2.runtime.IllegalAnnotationException e)
      • isReplaced

        public boolean isReplaced​(C sc)
      • getNavigator

        public org.glassfish.jaxb.core.v2.model.nav.Navigator<T,​C,​F,​M> getNavigator()
        Specified by:
        getNavigator in interface org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI<T,​C,​F,​M>
      • getReader

        public org.glassfish.jaxb.core.v2.model.annotation.AnnotationReader<T,​C,​F,​M> getReader()
        Specified by:
        getReader in interface org.glassfish.jaxb.core.v2.model.impl.ModelBuilderI<T,​C,​F,​M>