|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.xml.bind.api.ClassResolver
public abstract class ClassResolver
Dynamically locates classes to represent elements discovered during the unmarshalling.
THIS INTERFACE IS SUBJECT TO CHANGE WITHOUT NOTICE.
JAXBContext.newInstance(Class...) requires that application informs JAXB
about all the classes that it may see in the instance document. While this allows
JAXB to take time to optimize the unmarshalling, it is sometimes inconvenient
for applications.
This is where ClassResolver comes to resucue.
A ClassResolver instance can be specified on Unmarshaller via
Unmarshaller.setProperty(String, Object) as follows:
unmarshaller.setProperty( ClassResolver.class.getName(), new MyClassResolverImpl() );
When an Unmarshaller encounters (i) an unknown root element or (ii) unknown
elements where unmarshaller is trying to unmarshal into XmlAnyElement with
lax=true, unmarshaller calls resolveElementName(String, String)
method to see if the application may be able to supply a class that corresponds
to that class.
When a Class is returned, a new JAXBContext is created with
all the classes known to it so far, plus a new class returned. This operation
may fail (for example because of some conflicting annotations.) This failure
is handled just like Exceptions thrown from
resolveElementName(String, String).
| Constructor Summary | |
|---|---|
ClassResolver()
|
|
| Method Summary | |
|---|---|
abstract java.lang.Class<?> |
resolveElementName(java.lang.String nsUri,
java.lang.String localName)
JAXB calls this method when it sees an unknown element. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ClassResolver()
| Method Detail |
|---|
@Nullable
public abstract java.lang.Class<?> resolveElementName(@NotNull
java.lang.String nsUri,
@NotNull
java.lang.String localName)
throws java.lang.Exception
See the class javadoc for details.
nsUri - Namespace URI of the unknown element. Can be empty but never null.localName - Local name of the unknown element. Never be empty nor null.
ClassResolver
to begin with (that is, to report it to ValidationEventHandler,
then move on.)
java.lang.Exception - Throwing any RuntimeException causes the unmarshaller to stop
immediately. The exception will be propagated up the call stack.
Throwing any other checked Exception results in the error
reproted to ValidationEventHandler (just like any other error
during the unmarshalling.)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||