Class JAXBRIContext
- Direct Known Subclasses:
JAXBContextImpl
JAXBContext enhanced with JAXB RI specific functionalities.
Subject to change without notice.
- Since:
- 2.0 EA1
- Author:
- Kohsuke Kawaguchi (kohsuke.kawaguchi@sun.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)to use alternativeRuntimeAnnotationReaderimplementation.static final StringIf true and element namespace is not specified, namespace of parent element will be used.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)andMarshaller.setProperty(String, Object)to enable the c14n marshalling support in theJAXBContext.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)to reassign the default namespace URI to something else at the runtime.static final StringIf true XML security features when parsing XML documents will be disabled.static final StringMarshaller/Unmarshaller property to enable XOP processing.static final StringImproves handling of xsi:type used on leaf properties.static final StringThe maximum number of errors to report.static final StringRetains references to PropertyInfos.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)to specify specific classes that replace the reference to generic classes.static final StringSupress security warnings when trying to access fields through reflection.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)to allow unmarshaller to honorxsi:nilanywhere, even if they are not specifically allowed by the schema.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)to put additional JAXB type references into theJAXBContext.static final StringThe property that you can specify toJAXBContext.newInstance(java.lang.String)enable support of XmlAccessorFactory annotation in theJAXBContext.Fields inherited from class javax.xml.bind.JAXBContext
JAXB_CONTEXT_FACTORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract BridgeCreates a mini-marshaller/unmarshaller that can process aTypeReference.abstract BridgeContextCreates a newBridgeContextinstance.abstract voidgenerateEpisode(Result output) Generates the episode file that represents the binding known to thisJAXBContext, so that XJC can later do separate compilation.abstract voidgenerateSchema(javax.xml.bind.SchemaOutputResolver outputResolver) Generates the schema documents from the model.static TypegetBaseType(Type type, Class baseType) Gets the parameterization of the given base type.abstract StringGets the build information of the JAXB runtime.abstract QNameAllows to retrieve the element name based on Class.abstract QNameIf the given object is bound to an element in XML by JAXB, returns the element name.abstract <B,V> RawAccessor<B, V> getElementPropertyAccessor(Class<B> wrapperBean, String nsUri, String localName) Gets aRawAccessorfor the specified element property of the specified wrapper bean class.Gets the namespace URIs statically known to thisJAXBContext.abstract RuntimeTypeInfoSetAllows you to access the runtime model information of the JAXB XML/Java binding.abstract QNameReturns the name of the XML Type bound to the specified Java type.abstract booleanReturns true if this context includes a class that hasXmlAttachmentRef.static StringmangleNameToClassName(String localName) Computes a Java class name from a local name.static StringmangleNameToPropertyName(String localName) Computes a Java class name from a local name.static StringmangleNameToVariableName(String localName) Computes a Java identifier from a local name.static JAXBRIContextnewInstance(Class[] classes, Collection<TypeReference> typeRefs, String defaultNamespaceRemap, boolean c14nSupport) Deprecated.Compatibility with older versions.static JAXBRIContextnewInstance(Class[] classes, Collection<TypeReference> typeRefs, Map<Class, Class> subclassReplacements, String defaultNamespaceRemap, boolean c14nSupport, RuntimeAnnotationReader ar) Creates a newJAXBRIContext.static JAXBRIContextnewInstance(Class[] classes, Collection<TypeReference> typeRefs, Map<Class, Class> subclassReplacements, String defaultNamespaceRemap, boolean c14nSupport, RuntimeAnnotationReader ar, boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean supressAccessorWarnings) Creates a newJAXBRIContext.Methods inherited from class javax.xml.bind.JAXBContext
createBinder, createBinder, createJAXBIntrospector, createMarshaller, createUnmarshaller, createValidator, newInstance, newInstance, newInstance, newInstance, newInstance
-
Field Details
-
DEFAULT_NAMESPACE_REMAP
The property that you can specify toJAXBContext.newInstance(java.lang.String)to reassign the default namespace URI to something else at the runtime.The value of the property is
String, and it is used as the namespace URI that succeeds the default namespace URI.- Since:
- 2.0 EA1
- See Also:
-
TYPE_REFERENCES
The property that you can specify toJAXBContext.newInstance(java.lang.String)to put additional JAXB type references into theJAXBContext.The value of the property is
Collection<TypeReference>. ThoseTypeReferences can then be used to createBridges.This mechanism allows additional element declarations that were not a part of the schema into the created
JAXBContext.- Since:
- 2.0 EA1
- See Also:
-
CANONICALIZATION_SUPPORT
The property that you can specify toJAXBContext.newInstance(java.lang.String)andMarshaller.setProperty(String, Object)to enable the c14n marshalling support in theJAXBContext. Boolean- Since:
- 2.0 EA2
- See Also:
-
TREAT_EVERYTHING_NILLABLE
The property that you can specify toJAXBContext.newInstance(java.lang.String)to allow unmarshaller to honorxsi:nilanywhere, even if they are not specifically allowed by the schema. Boolean- Since:
- 2.1.3
- See Also:
-
ANNOTATION_READER
The property that you can specify toJAXBContext.newInstance(java.lang.String)to use alternativeRuntimeAnnotationReaderimplementation.- Since:
- 2.1 EA2
-
ENABLE_XOP
Marshaller/Unmarshaller property to enable XOP processing.- Since:
- 2.0 EA2
- See Also:
-
SUBCLASS_REPLACEMENTS
The property that you can specify toJAXBContext.newInstance(java.lang.String)to specify specific classes that replace the reference to generic classes.See the release notes for more details about this feature.
- Since:
- 2.1 EA2
- See Also:
-
XMLACCESSORFACTORY_SUPPORT
The property that you can specify toJAXBContext.newInstance(java.lang.String)enable support of XmlAccessorFactory annotation in theJAXBContext.- Since:
- 2.1 EA2
- See Also:
-
RETAIN_REFERENCE_TO_INFO
Retains references to PropertyInfos. Boolean- Since:
- 2.1.10
- See Also:
-
SUPRESS_ACCESSOR_WARNINGS
Supress security warnings when trying to access fields through reflection. Boolean- Since:
- 2.1.14, 2.2.2
- See Also:
-
IMPROVED_XSI_TYPE_HANDLING
Improves handling of xsi:type used on leaf properties. Boolean- Since:
- 2.2.3
- See Also:
-
DISABLE_XML_SECURITY
If true XML security features when parsing XML documents will be disabled. The default value is false. Boolean- Since:
- 2.2.6
- See Also:
-
BACKUP_WITH_PARENT_NAMESPACE
If true and element namespace is not specified, namespace of parent element will be used. The default value is false. Boolean- Since:
- 2.3.0
- See Also:
-
MAX_ERRORS
The maximum number of errors to report. Use negative value to report all errors. The default value is 10. Boolean- Since:
- 2.3.3
- See Also:
-
-
Constructor Details
-
JAXBRIContext
protected JAXBRIContext()
-
-
Method Details
-
newInstance
public static JAXBRIContext newInstance(@NotNull Class[] classes, @Nullable Collection<TypeReference> typeRefs, @Nullable Map<Class, Class> subclassReplacements, @Nullable String defaultNamespaceRemap, boolean c14nSupport, @Nullable RuntimeAnnotationReader ar) throws javax.xml.bind.JAXBExceptionCreates a newJAXBRIContext.JAXBContext.newInstance()methods may return other JAXB providers that are not compatible with the JAX-RPC RI. This method guarantees that the JAX-WS RI will finds the JAXB RI.- Parameters:
classes- Classes to be bound. SeeJAXBContext.newInstance(Class[])for the meaning.typeRefs- SeeTYPE_REFERENCESfor the meaning of this parameter. Can be null.subclassReplacements- SeeSUBCLASS_REPLACEMENTSfor the meaning of this parameter. Can be null.defaultNamespaceRemap- SeeDEFAULT_NAMESPACE_REMAPfor the meaning of this parameter. Can be null (and should be null for ordinary use of JAXB.)c14nSupport- SeeCANONICALIZATION_SUPPORTfor the meaning of this parameter.ar- SeeANNOTATION_READERfor the meaning of this parameter. Can be null.- Throws:
javax.xml.bind.JAXBException- Since:
- JAXB 2.1 EA2
-
newInstance
public static JAXBRIContext newInstance(@NotNull Class[] classes, @Nullable Collection<TypeReference> typeRefs, @Nullable Map<Class, Class> subclassReplacements, @Nullable String defaultNamespaceRemap, boolean c14nSupport, @Nullable RuntimeAnnotationReader ar, boolean xmlAccessorFactorySupport, boolean allNillable, boolean retainPropertyInfo, boolean supressAccessorWarnings) throws javax.xml.bind.JAXBExceptionCreates a newJAXBRIContext.JAXBContext.newInstance()methods may return other JAXB providers that are not compatible with the JAX-RPC RI. This method guarantees that the JAX-WS RI will finds the JAXB RI.- Parameters:
classes- Classes to be bound. SeeJAXBContext.newInstance(Class[])for the meaning.typeRefs- SeeTYPE_REFERENCESfor the meaning of this parameter. Can be null.subclassReplacements- SeeSUBCLASS_REPLACEMENTSfor the meaning of this parameter. Can be null.defaultNamespaceRemap- SeeDEFAULT_NAMESPACE_REMAPfor the meaning of this parameter. Can be null (and should be null for ordinary use of JAXB.)c14nSupport- SeeCANONICALIZATION_SUPPORTfor the meaning of this parameter.ar- SeeANNOTATION_READERfor the meaning of this parameter. Can be null.xmlAccessorFactorySupport- SeeXMLACCESSORFACTORY_SUPPORTfor the meaning of this parameter.allNillable- SeeTREAT_EVERYTHING_NILLABLEfor the meaning of this parameter.retainPropertyInfo- SeeRETAIN_REFERENCE_TO_INFOfor the meaning of this parameter.supressAccessorWarnings- SeeSUPRESS_ACCESSOR_WARNINGSfor the meaning of this parameter.- Throws:
javax.xml.bind.JAXBException
-
newInstance
public static JAXBRIContext newInstance(@NotNull Class[] classes, @Nullable Collection<TypeReference> typeRefs, @Nullable String defaultNamespaceRemap, boolean c14nSupport) throws javax.xml.bind.JAXBException Deprecated.Compatibility with older versions.- Throws:
javax.xml.bind.JAXBException
-
hasSwaRef
public abstract boolean hasSwaRef()Returns true if this context includes a class that hasXmlAttachmentRef.- Since:
- 2.1
-
getElementName
@Nullable public abstract QName getElementName(@NotNull Object o) throws javax.xml.bind.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:
javax.xml.bind.JAXBException- if the object is not known to this context.- Since:
- 2.0 EA1
-
getElementName
@Nullable public abstract QName getElementName(@NotNull Class o) throws javax.xml.bind.JAXBException Allows to retrieve the element name based on Class.- Parameters:
o-- Returns:
- Throws:
javax.xml.bind.JAXBException- Since:
- 2.1.10
-
createBridge
Creates a mini-marshaller/unmarshaller that can process aTypeReference.- Returns:
- null if the specified reference is not given to
newInstance(java.lang.Class[], java.util.Collection<com.sun.xml.bind.api.TypeReference>, java.util.Map<java.lang.Class, java.lang.Class>, java.lang.String, boolean, com.sun.xml.bind.v2.model.annotation.RuntimeAnnotationReader). - Since:
- 2.0 EA1
-
createBridgeContext
Creates a newBridgeContextinstance.- 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 javax.xml.bind.JAXBException Gets aRawAccessorfor 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
RawAccessorthat 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 beanV- type of the property of the bean- Returns:
- always return non-null valid accessor object.
- Throws:
javax.xml.bind.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
Gets the namespace URIs statically known to thisJAXBContext.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 javax.xml.bind.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.Stringthen 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:
generateSchemain classjavax.xml.bind.JAXBContext- Parameters:
outputResolver- this object controls the output to which schemas will be sent.- Throws:
IOException- ifSchemaOutputResolverthrows anIOException.
-
getTypeName
Returns the name of the XML Type bound to the specified Java type.- Parameters:
tr- must not be null. This must be one of theTypeReferences specified in thenewInstance(java.lang.Class[], java.util.Collection<com.sun.xml.bind.api.TypeReference>, java.util.Map<java.lang.Class, java.lang.Class>, java.lang.String, boolean, com.sun.xml.bind.v2.model.annotation.RuntimeAnnotationReader)method.- Returns:
- null if the referenced type is an anonymous and therefore doesn't have a name.
- Throws:
IllegalArgumentException- if the parameter is null or not a part of theTypeReferences specified in thenewInstance(java.lang.Class[], java.util.Collection<com.sun.xml.bind.api.TypeReference>, java.util.Map<java.lang.Class, java.lang.Class>, java.lang.String, boolean, com.sun.xml.bind.v2.model.annotation.RuntimeAnnotationReader)method.
-
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
Generates the episode file that represents the binding known to thisJAXBContext, 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
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
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
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
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
Gets the parameterization of the given base type.For example, given the following
This method works like this:interface Foo<T> extends List<List<T>> {} interface Bar extends Foo<String> {}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 frombaseTypebaseType- The class whose parameterization we are interested in.- Returns:
- The use of
baseTypeintype. or null if the type is not assignable to the base type. - Since:
- 2.0 FCS
-