1 package com.proalpha.pds.paconnector.utils;
4 import java.util.Locale;
6 import javax.xml.bind.JAXBContext;
7 import javax.xml.bind.JAXBException;
8 import javax.xml.bind.Unmarshaller;
12 private final Class<T> clazz;
19 @SuppressWarnings(
"unchecked")
20 public T readXMLFile(File xmlFile) {
22 Locale defaultLocale = Locale.getDefault();
24 final JAXBContext context = JAXBContext.newInstance(clazz);
25 Unmarshaller unmarshaller = context.createUnmarshaller();
26 return (T) unmarshaller.unmarshal(xmlFile);
28 }
catch (JAXBException e) {
30 Locale.setDefault(Locale.ENGLISH);
31 throw new IllegalStateException(e);
34 Locale.setDefault(defaultLocale);