com.sun.xml.bind.api
Class JAXBRIContext

java.lang.Object
  extended by javax.xml.bind.JAXBContext
      extended by com.sun.xml.bind.api.JAXBRIContext
Direct Known Subclasses:
JAXBContextImpl

public abstract class JAXBRIContext
extends javax.xml.bind.JAXBContext

JAXBContext enhanced with JAXB RI specific functionalities.

Subject to change without notice.

Since:
2.0 EA1

Field Summary
static java.lang.String CANONICALIZATION_SUPPORT
          The property that you can specify to JAXBContext.newInstance(java.lang.String) and Marshaller.setProperty(String, Object) to enable the c14n marshalling support in the JAXBContext.
static java.lang.String DEFAULT_NAMESPACE_REMAP
          The property that you can specify to JAXBContext.newInstance(java.lang.String) to reassign the default namespace URI to something else at the runtime.
static java.lang.String ENABLE_XOP
          Marshaller/Unmarshaller property to enable XOP processing.
static java.lang.String TYPE_REFERENCES
          The property that you can specify to JAXBContext.newInstance(java.lang.String) to put additional JAXB type references into the JAXBContext.
 
Fields inherited from class javax.xml.bind.JAXBContext
JAXB_CONTEXT_FACTORY
 
Constructor Summary
protected JAXBRIContext()
           
 
Method Summary
abstract  Bridge createBridge(TypeReference ref)
          Creates a mini-marshaller/unmarshaller that can process a TypeReference.
abstract  BridgeContext createBridgeContext()
          Creates a new BridgeContext instance.
abstract  void generateSchema(javax.xml.bind.SchemaOutputResolver outputResolver)
          Generates the schema documents from the model.
abstract  java.lang.String getBuildId()
          Gets the build information of the JAXB runtime.
abstract  javax.xml.namespace.QName getElementName(java.lang.Object o)
          If the given object is bound to an element in XML by JAXB, returns the element name.
abstract
<B,V> RawAccessor<B,V>
getElementPropertyAccessor(java.lang.Class<B> wrapperBean, java.lang.String nsUri, java.lang.String localName)
          Gets a RawAccessor for the specified element property of the specified wrapper bean class.
abstract  java.util.List<java.lang.String> getKnownNamespaceURIs()
          Gets the namespace URIs statically known to this JAXBContext.
abstract  javax.xml.namespace.QName getTypeName(TypeReference tr)
          Returns the name of the XML Type bound to the specified Java type.
static java.lang.String mangleNameToClassName(java.lang.String localName)
          Computes a Java class name from a local name.
static java.lang.String mangleNameToVariableName(java.lang.String localName)
          Computes a Java identifier from a local name.
static JAXBRIContext newInstance(java.lang.Class[] classes, java.util.Collection<TypeReference> typeRefs, java.lang.String defaultNamespaceRemap, boolean c14nSupport)
          Creates a new JAXBRIContext.
 
Methods inherited from class javax.xml.bind.JAXBContext
createBinder, createBinder, createJAXBIntrospector, createMarshaller, createUnmarshaller, createValidator, newInstance, newInstance, newInstance, newInstance, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_NAMESPACE_REMAP

public static final java.lang.String DEFAULT_NAMESPACE_REMAP
The property that you can specify to JAXBContext.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:
Constant Field Values

TYPE_REFERENCES

public static final java.lang.String TYPE_REFERENCES
The property that you can specify to JAXBContext.newInstance(java.lang.String) to put additional JAXB type references into the JAXBContext.

The value of the property is Collection<TypeReference>. Those TypeReferences can then be used to create Bridges.

This mechanism allows additional element declarations that were not a part of the schema into the created JAXBContext.

Since:
2.0 EA1
See Also:
Constant Field Values

CANONICALIZATION_SUPPORT

public static final java.lang.String CANONICALIZATION_SUPPORT
The property that you can specify to JAXBContext.newInstance(java.lang.String) and Marshaller.setProperty(String, Object) to enable the c14n marshalling support in the JAXBContext.

Since:
2.0 EA2
See Also:
C14nSupport_ArchitectureDocument, Constant Field Values

ENABLE_XOP

public static final java.lang.String ENABLE_XOP
Marshaller/Unmarshaller property to enable XOP processing.

Since:
2.0 EA2
See Also:
Constant Field Values
Constructor Detail

JAXBRIContext

protected JAXBRIContext()
Method Detail

newInstance

public static final JAXBRIContext newInstance(java.lang.Class[] classes,
                                              java.util.Collection<TypeReference> typeRefs,
                                              java.lang.String defaultNamespaceRemap,
                                              boolean c14nSupport)
                                       throws javax.xml.bind.JAXBException
Creates a new JAXBRIContext.

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. See JAXBContext.newInstance(Class[]) for the meaning.
typeRefs - See TYPE_REFERENCES for the meaning of this parameter. Can be null.
defaultNamespaceRemap - See DEFAULT_NAMESPACE_REMAP for the meaning of this parameter. Can be null (and should be null for ordinary use of JAXB.)
c14nSupport - See CANONICALIZATION_SUPPORT for the meaning of this parameter.
Throws:
javax.xml.bind.JAXBException

getElementName

public abstract javax.xml.namespace.QName getElementName(java.lang.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

createBridge

public abstract Bridge createBridge(TypeReference ref)
Creates a mini-marshaller/unmarshaller that can process a TypeReference.

Returns:
null if the specified reference is not given to newInstance(java.lang.Class[], java.util.Collection, java.lang.String, boolean).
Since:
2.0 EA1

createBridgeContext

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(java.lang.Class<B> wrapperBean,
                                                                  java.lang.String nsUri,
                                                                  java.lang.String localName)
                                                     throws javax.xml.bind.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:
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

public abstract java.util.List<java.lang.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(javax.xml.bind.SchemaOutputResolver outputResolver)
                             throws java.io.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 javax.xml.bind.JAXBContext
Parameters:
outputResolver - this object controls the output to which schemas will be sent.
Throws:
java.io.IOException - if SchemaOutputResolver throws an IOException.

getTypeName

public abstract javax.xml.namespace.QName getTypeName(TypeReference tr)
Returns the name of the XML Type bound to the specified Java type.

Parameters:
tr - must not be null. This must be one of the TypeReferences specified in the newInstance(java.lang.Class[], java.util.Collection, java.lang.String, boolean) method.
Returns:
null if the referenced type is an anonymous and therefore doesn't have a name.
Throws:
java.lang.IllegalArgumentException - if the parameter is null or not a part of the TypeReferences specified in the newInstance(java.lang.Class[], java.util.Collection, java.lang.String, boolean) method.

getBuildId

public abstract java.lang.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.

mangleNameToVariableName

public static java.lang.String mangleNameToVariableName(java.lang.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".
See Also:
JJavaName#isJavaIdentifier(String)

mangleNameToClassName

public static java.lang.String mangleNameToClassName(java.lang.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".