List of usage examples for javax.xml.bind Validator validate
public boolean validate(Object subrootObj) throws JAXBException;
From source file:de.thorstenberger.taskmodel.complex.complextaskdef.impl.ComplexTaskDefDAOImpl.java
public void save(ComplexTaskDefRoot ctdr, OutputStream os) throws TaskApiException { BufferedOutputStream bos = new BufferedOutputStream(os); Marshaller marshaller = null; try {//from www . ja v a 2 s.c o m JAXBContext jc = createJAXBContext(); marshaller = JAXBUtils.getJAXBMarshaller(jc); Validator validator = jc.createValidator(); ComplexTaskDef ctd = ((ComplexTaskDefRootImpl) ctdr).getJAXBContent(); validator.validate(ctd); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, new Boolean(true)); marshaller.marshal(ctd, bos); } catch (JAXBException e) { throw new TaskModelPersistenceException(e); } finally { try { bos.close(); } catch (IOException e) { throw new TaskModelPersistenceException(e); } if (marshaller != null) JAXBUtils.releaseJAXBMarshaller(jc, marshaller); } }