use of javax.xml.bind.DataBindingException in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesManagerImpl method convertProjectPropertiesFromString.
public ProjectPropertiesTO convertProjectPropertiesFromString(String properties) {
try {
Source source = new StreamSource(new StringReader(properties));
JAXBElement<ProjectPropertiesTO> element = JAXB_CONTEXT.createUnmarshaller().unmarshal(source, ProjectPropertiesTO.class);
return element.getValue();
} catch (JAXBException e) {
throw new DataBindingException(e);
}
}
use of javax.xml.bind.DataBindingException in project pmd-eclipse-plugin by pmd.
the class ProjectPropertiesManagerImpl method convertProjectPropertiesToString.
public String convertProjectPropertiesToString(ProjectPropertiesTO projectProperties) {
try {
Marshaller marshaller = JAXB_CONTEXT.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING, "UTF-8");
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, true);
StringWriter writer = new StringWriter();
writer.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
marshaller.marshal(projectProperties, writer);
writer.write("\n");
return writer.toString();
} catch (JAXBException e) {
throw new DataBindingException(e);
}
}
Aggregations