Performs conversions of XML element or attribute values encountered during XML (un)marshalling. Each method in this class is a converter and can be invoked at (un)marshalling time. The default implementation is straightforward and documented in the javadoc of each method.
This class provides a way to handle the errors which may exist in some XML documents. For example a URL in the document may be malformed, causing a {@link MalformedURLException}to be thrown. If this error is not handled, it will cause the (un)marshalling of the entire document to fail. An application may want to change this behavior by replacing URLs that are known to be erroneous by fixed versions of those URLs. Example:
{@preformat java}class URLFixer extends ValueConverter @Override public URL toURL(MarshalContext context, URI uri) throws MalformedURLException { try { return super.toURL(context, uri); } catch (MalformedURLException e) { if (uri.equals(KNOWN_ERRONEOUS_URI) { return FIXED_URL; } else { throw e; } } } } } See the {@link XML#CONVERTER} javadoc for an example of registering a custom{@code ValueConverter} to a (un)marshaller.
@author Martin Desruisseaux (Geomatys)
@since 0.3 (derived from geotk-3.07)
@version 0.3
@module