1 package com.proalpha.pds.templates.jaxb;
5 import javax.xml.bind.JAXBContext;
6 import javax.xml.bind.JAXBException;
7 import javax.xml.bind.Unmarshaller;
11 private final Class<T> clazz;
18 @SuppressWarnings(
"unchecked")
19 public T readXMLFile(String filePath)
throws JAXBException {
21 final JAXBContext context = JAXBContext.newInstance(clazz);
22 Unmarshaller unmarshaller = context.createUnmarshaller();
24 return (T) unmarshaller.unmarshal(
new File(filePath));
27 @SuppressWarnings(
"unchecked")
28 public T readXMLFile(File xmlFile)
throws JAXBException {
30 final JAXBContext context = JAXBContext.newInstance(clazz);
31 Unmarshaller unmarshaller = context.createUnmarshaller();
33 return (T) unmarshaller.unmarshal(xmlFile);