*/
package org.opendaylight.controller.netconf.monitoring.xml;
-import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Marshaller;
import javax.xml.transform.dom.DOMResult;
+import org.opendaylight.controller.netconf.monitoring.xml.model.NetconfState;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
public class JaxBSerializer {
- public Element toXml(NetconfState monitoringModel) {
- DOMResult res = null;
+ public Element toXml(final NetconfState monitoringModel) {
+ final DOMResult res;
try {
- JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
- Marshaller marshaller = jaxbContext.createMarshaller();
+ final JAXBContext jaxbContext = JAXBContext.newInstance(NetconfState.class);
+ final Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
res = new DOMResult();
marshaller.marshal(monitoringModel, res);
- } catch (JAXBException e) {
- throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
+ } catch (final JAXBException e) {
+ throw new RuntimeException("Unable to serialize netconf state " + monitoringModel, e);
}
return ((Document)res.getNode()).getDocumentElement();
}