@Nonnull public final IMPLTYPE setReadSecure (final boolean bReadSecure) { m_bReadSecure = bReadSecure; return thisAsT (); }
@Nullable public JAXBTYPE read (@Nonnull final IJAXBUnmarshaller <JAXBTYPE> aHandler) { ValueEnforcer.notNull (aHandler, "Handler"); // as we don't have a node, we need to trust the implementation class final Schema aSchema = getSchema (); if (aSchema == null && isUseSchema ()) LOGGER.warn ("Don't know how to read JAXB document of type " + m_aImplClass.getName ()); JAXBTYPE ret = null; try { // Create unmarshaller final Unmarshaller aUnmarshaller = createUnmarshaller (); // Customize on demand if (m_aUnmarshallerCustomizer != null) m_aUnmarshallerCustomizer.accept (aUnmarshaller); // main unmarshalling final JAXBElement <JAXBTYPE> aElement = aHandler.doUnmarshal (aUnmarshaller, m_aImplClass); ret = aElement.getValue (); if (ret == null) throw new IllegalStateException ("Failed to read JAXB document of class " + m_aImplClass.getName () + " - without exception!"); } catch (final JAXBException ex) { exceptionCallbacks ().forEach (x -> x.onException (ex)); } return ret; }
@Nonnull protected Unmarshaller createUnmarshaller () throws JAXBException { final JAXBContext aJAXBContext = getJAXBContext (); // create an Unmarshaller final Unmarshaller aUnmarshaller = aJAXBContext.createUnmarshaller (); if (m_aEventHandler != null) aUnmarshaller.setEventHandler (m_aEventHandler); else aUnmarshaller.setEventHandler (new LoggingValidationEventHandler ().andThen (aUnmarshaller.getEventHandler ())); // Validating (if possible) final Schema aSchema = getSchema (); if (aSchema != null) aUnmarshaller.setSchema (aSchema); return aUnmarshaller; }
public JAXBReaderBuilder (@Nonnull final IJAXBDocumentType aDocType, @Nonnull final Class <JAXBTYPE> aImplClass) { super (aDocType); m_aImplClass = ValueEnforcer.notNull (aImplClass, "ImplClass"); exceptionCallbacks ().add (new LoggingJAXBReadExceptionHandler ()); }
@Nonnull public final IMPLTYPE setUnmarshallerCustomizer (@Nullable final Consumer <? super Unmarshaller> aUnmarshallerCustomizer) { m_aUnmarshallerCustomizer = aUnmarshallerCustomizer; return thisAsT (); }
/** * Set the JAXB validation event handler to be used. May be <code>null</code>. * * @param aEventHandler * The event handler to be used. May be <code>null</code>. * @return this */ @Nonnull public final IMPLTYPE setValidationEventHandler (@Nullable final ValidationEventHandler aEventHandler) { m_aEventHandler = aEventHandler; return thisAsT (); }