Exemplo n.º 1
0
  /**
   * This method loads a List of Request objects from xml file
   *
   * @param importFile file object to load the object from
   * @return List of Requests
   */
  public List<Request> unmarshal(File importFile) throws StiebelHeatPumpException {
    Requests requests = new Requests();

    JAXBContext context;
    try {
      context = JAXBContext.newInstance(Requests.class);
      Unmarshaller um = context.createUnmarshaller();
      requests = (Requests) um.unmarshal(importFile);
    } catch (JAXBException e) {
      throw new StiebelHeatPumpException(e.toString(), e);
    }

    return requests.getRequests();
  }
Exemplo n.º 2
0
 /**
  * This method loads a List of Request objects from xml file
  *
  * @param fileName file object to load the object from
  * @return List of Requests
  */
 public List<Request> parseConfig(String fileName) {
   logger.debug("Parsing  heat pump configuration file {}.", fileName);
   try {
     JAXBContext context = JAXBContext.newInstance(Requests.class);
     Unmarshaller unmarshaller = context.createUnmarshaller();
     InputStream stream =
         Thread.currentThread().getContextClassLoader().getResourceAsStream(fileName);
     Requests configuration = (Requests) unmarshaller.unmarshal(stream);
     List<Request> requests = configuration.getRequests();
     return requests;
   } catch (JAXBException e) {
     logger.debug("Parsing  failed {}. " + e.toString(), fileName);
     throw new RuntimeException(e);
   }
 }