@Override public void setEventHandler(ValidationEventHandler handler) throws JAXBException { jaxbMarshaller.setEventHandler(handler); }
/** * Template method that can be overridden by concrete JAXB marshallers for custom initialization behavior. * Gets called after creation of JAXB {@code Marshaller}, and after the respective properties have been set. * <p>The default implementation sets the {@link #setMarshallerProperties(Map) defined properties}, the {@link * #setValidationEventHandler(ValidationEventHandler) validation event handler}, the {@link #setSchemas(Resource[]) * schemas}, {@link #setMarshallerListener(javax.xml.bind.Marshaller.Listener) listener}, and * {@link #setAdapters(XmlAdapter[]) adapters}. */ protected void initJaxbMarshaller(Marshaller marshaller) throws JAXBException { if (this.marshallerProperties != null) { for (String name : this.marshallerProperties.keySet()) { marshaller.setProperty(name, this.marshallerProperties.get(name)); } } if (this.marshallerListener != null) { marshaller.setListener(this.marshallerListener); } if (this.validationEventHandler != null) { marshaller.setEventHandler(this.validationEventHandler); } if (this.adapters != null) { for (XmlAdapter<?, ?> adapter : this.adapters) { marshaller.setAdapter(adapter); } } if (this.schema != null) { marshaller.setSchema(this.schema); } }
public void setEventHandler(ValidationEventHandler validationEventHandler) throws JAXBException { marshaller.setEventHandler(validationEventHandler); }
public void setEventHandler(ValidationEventHandler handler) throws JAXBException { jaxbMarshaller.setEventHandler(handler); }
public void setEventHandler(ValidationEventHandler validationEventHandler) throws JAXBException { marshaller.setEventHandler(validationEventHandler); }
public void setEventHandler(ValidationEventHandler validationEventHandler) throws JAXBException { marshaller.setEventHandler(validationEventHandler); }
public void setEventHandler(ValidationEventHandler validationEventHandler) throws JAXBException { marshaller.setEventHandler(validationEventHandler); }
/** * {@inheritDoc} */ @Override public void setEventHandler( final ValidationEventHandler handler ) throws JAXBException { marshaller.setEventHandler( handler ); }
@Override public void setEventHandler(ValidationEventHandler handler) throws JAXBException { marshaller.setEventHandler(handler); }
@Override public void setEventHandler(ValidationEventHandler handler) throws JAXBException { jaxbMarshaller.setEventHandler(handler); }
@Override public void setEventHandler(ValidationEventHandler handler) throws JAXBException { jaxbMarshaller.setEventHandler(handler); }
/** * Delegates to the wrapped marshaller. The initial state will be saved * if it was not already done, for future restoration by {@link #reset(Pooled)}. */ @Override public void setEventHandler(final ValidationEventHandler handler) throws JAXBException { super.setEventHandler(handler); marshaller.setEventHandler(handler); }
private Marshaller createMarshaller() { try { Marshaller marshaller = _jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setEventHandler(new JaxbValidationEventHandler()); return marshaller; } catch (JAXBException e) { throw new IllegalArgumentException(e); } }
/** * Delegates to the wrapped marshaller. The initial state will be saved * if it was not already done, for future restoration by {@link #reset(Pooled)}. */ @Override public void setEventHandler(final ValidationEventHandler handler) throws JAXBException { super.setEventHandler(handler); marshaller.setEventHandler(handler); }
public void setEventHandler(ValidationEventHandler handler) throws JAXBException { getMarshaller().setEventHandler(handler); }
public static void serialize(Object o, OutputStream os, Boolean format) throws JAXBException { String pkg = o.getClass().getPackage().getName(); JAXBContext jc = getCachedContext(pkg); Marshaller m = jc.createMarshaller(); m.setEventHandler(new DefaultValidationEventHandler()); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, format); m.setProperty(Marshaller.JAXB_ENCODING, "UTF-8"); m.marshal(o, os); } }
protected Marshaller createMarshaller() { try { final Marshaller marshaller = _jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setEventHandler(new JaxbValidationEventHandler()); return marshaller; } catch (JAXBException e) { throw new JaxbException(e); } }
@Override public void write(final AnalysisJob analysisJob, final OutputStream outputStream) { logger.debug("write({},{}}", analysisJob, outputStream); final Job job = new Job(); configureJobType(analysisJob, job, true); try { final Marshaller marshaller = _jaxbContext.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.setEventHandler(new JaxbValidationEventHandler()); marshaller.marshal(job, outputStream); } catch (final JAXBException e) { throw new IllegalStateException(e); } }
protected Marshaller createMarshaller() throws JAXBException { Marshaller marshaller = getContext().createMarshaller(); if (schema != null) { marshaller.setSchema(cachedSchema); marshaller.setEventHandler(new ValidationEventHandler() { public boolean handleEvent(ValidationEvent event) { // continue if the severity is lower than the configured level return event.getSeverity() < getSchemaSeverityLevel(); } }); } return marshaller; }
protected void validateObjectIfNeeded(Marshaller marshaller, Class<?> cls, Object obj) throws JAXBException { if (validateOutputIfPossible) { Schema theSchema = getSchema(cls); if (theSchema != null) { marshaller.setEventHandler(eventHandler); marshaller.setSchema(theSchema); if (validateBeforeWrite) { marshaller.marshal(obj, new DefaultHandler()); marshaller.setSchema(null); } } } }