Class JAXBRIContext

  • Direct Known Subclasses:
    JAXBContextImpl

    public abstract class JAXBRIContext
    extends JAXBContext
    JAXBContext enhanced with JAXB RI specific functionalities.

    Subject to change without notice.

    Since:
    2.0 EA1
    Author:
    Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
    • Constructor Detail

      • JAXBRIContext

        protected JAXBRIContext()
    • Method Detail

      • hasSwaRef

        public abstract boolean hasSwaRef()
        Returns true if this context includes a class that has XmlAttachmentRef.
        Since:
        2.1
      • getElementName

        @Nullable
        public abstract QName getElementName​(@NotNull
                                             Object o)
                                      throws JAXBException
        If the given object is bound to an element in XML by JAXB, returns the element name.
        Returns:
        null if the object is not bound to an element.
        Throws:
        JAXBException - if the object is not known to this context.
        Since:
        2.0 EA1
      • getElementName

        @Nullable
        public abstract QName getElementName​(@NotNull
                                             Class o)
                                      throws JAXBException
        Allows to retrieve the element name based on Class.
        Parameters:
        o -
        Returns:
        Throws:
        JAXBException
        Since:
        2.1.10
      • createBridgeContext

        @NotNull
        public abstract BridgeContext createBridgeContext()
        Creates a new BridgeContext instance.
        Returns:
        always a valid non-null instance.
        Since:
        2.0 EA1
      • getElementPropertyAccessor

        public abstract <B,​V> RawAccessor<B,​V> getElementPropertyAccessor​(Class<B> wrapperBean,
                                                                                      String nsUri,
                                                                                      String localName)
                                                                               throws JAXBException
        Gets a RawAccessor for the specified element property of the specified wrapper bean class.

        This method is designed to assist the JAX-RPC RI fill in a wrapper bean (in the doc/lit/wrap mode.) In the said mode, a wrapper bean is supposed to only have properties that match elements, and for each element that appear in the content model there's one property.

        Therefore, this method takes a wrapper bean and a tag name that identifies a property on the given wrapper bean, then returns a RawAccessor that allows the caller to set/get a value from the property of the bean.

        This method is not designed for a performance. The caller is expected to cache the result.

        Type Parameters:
        B - type of the wrapper bean
        V - type of the property of the bean
        Returns:
        always return non-null valid accessor object.
        Throws:
        JAXBException - if the specified wrapper bean is not bound by JAXB, or if it doesn't have an element property of the given name.
        Since:
        2.0 EA1
      • getKnownNamespaceURIs

        @NotNull
        public abstract List<String> getKnownNamespaceURIs()
        Gets the namespace URIs statically known to this JAXBContext.

        When JAXB is used to marshal into sub-trees, it declares these namespace URIs at each top-level element that it marshals. To avoid repeated namespace declarations at sub-elements, the application may declare those namespaces at a higher level.

        Returns:
        always non-null.
        Since:
        2.0 EA2
      • generateSchema

        public abstract void generateSchema​(@NotNull
                                            SchemaOutputResolver outputResolver)
                                     throws IOException
        Generates the schema documents from the model.

        The caller can use the additionalElementDecls parameter to add element declarations to the generate schema. For example, if the JAX-RPC passes in the following entry: {foo}bar -> DeclaredType for java.lang.String then JAXB generates the following element declaration (in the schema document for the namespace "foo")" <xs:element name="bar" type="xs:string" /> This can be used for generating schema components necessary for WSDL.

        Overrides:
        generateSchema in class JAXBContext
        Parameters:
        outputResolver - this object controls the output to which schemas will be sent.
        Throws:
        IOException - if SchemaOutputResolver throws an IOException.
      • getBuildId

        @NotNull
        public abstract String getBuildId()
        Gets the build information of the JAXB runtime.
        Returns:
        may be null, if the runtime is loaded by a class loader that doesn't support the access to the manifest informatino.
      • generateEpisode

        public abstract void generateEpisode​(Result output)
        Generates the episode file that represents the binding known to this JAXBContext, so that XJC can later do separate compilation.

        Episode file is really just a JAXB customization file, except that currently we use the RI-specific SCD to refer to schema components.

        Parameters:
        output - This receives the generated episode file.
        Since:
        2.1
      • getRuntimeTypeInfoSet

        public abstract RuntimeTypeInfoSet getRuntimeTypeInfoSet()
        Allows you to access the runtime model information of the JAXB XML/Java binding.

        This is useful for doing a deeper integration with the JAXB RI. For more information about the model, see https://jaxb2-reflection.dev.java.net/

        Since:
        2.1.10
      • mangleNameToVariableName

        @NotNull
        public static String mangleNameToVariableName​(@NotNull
                                                      String localName)
        Computes a Java identifier from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec.

        In JAXB, a collision with a Java reserved word (such as "return") never happens. Accordingly, this method may return an identifier that collides with reserved words.

        Use JJavaName.isJavaIdentifier(String) to check for such collision.

        Returns:
        Typically, this method returns "nameLikeThis".
      • mangleNameToClassName

        @NotNull
        public static String mangleNameToClassName​(@NotNull
                                                   String localName)
        Computes a Java class name from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec.

        Returns:
        Typically, this method returns "NameLikeThis".
      • mangleNameToPropertyName

        @NotNull
        public static String mangleNameToPropertyName​(@NotNull
                                                      String localName)
        Computes a Java class name from a local name.

        This method faithfully implements the name mangling rule as specified in the JAXB spec. This method works like mangleNameToClassName(String) except that it looks for "getClass" and returns something else.

        Returns:
        Typically, this method returns "NameLikeThis".
      • getBaseType

        @Nullable
        public static Type getBaseType​(@NotNull
                                       Type type,
                                       @NotNull
                                       Class baseType)
        Gets the parameterization of the given base type.

        For example, given the following

        
         interface Foo<T> extends List<List<T>> {}
         interface Bar extends Foo<String> {}
         
        This method works like this:
        
         getBaseClass( Bar, List ) = List<List<String>
         getBaseClass( Bar, Foo  ) = Foo<String>
         getBaseClass( Foo<? extends Number>, Collection ) = Collection<List<? extends Number>>
         getBaseClass( ArrayList<? extends BigInteger>, List ) = List<? extends BigInteger>
         
        Parameters:
        type - The type that derives from baseType
        baseType - The class whose parameterization we are interested in.
        Returns:
        The use of baseType in type. or null if the type is not assignable to the base type.
        Since:
        2.0 FCS