01: /*
02: * $Id: ProcessLoader.java 476 2005-07-11 17:25:19Z hengels $
03: * (c) Copyright 2004 con:cern development team.
04: *
05: * This file is part of con:cern (http://concern.org).
06: *
07: * con:cern is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU Lesser General Public License
09: * as published by the Free Software Foundation; either version 2.1
10: * of the License, or (at your option) any later version.
11: *
12: * Please see COPYING for the complete licence.
13: */
14: package org.concern.model.cpd;
15:
16: import javax.xml.parsers.SAXParser;
17: import javax.xml.parsers.SAXParserFactory;
18: import java.io.*;
19:
20: public class ProcessLoader {
21: public static org.concern.model.Process load(File file) {
22: InputStream in = null;
23: try {
24: in = new FileInputStream(file);
25: SAXParserFactory factory = SAXParserFactory.newInstance();
26: SAXParser saxParser = factory.newSAXParser();
27: ProcessHandler processHandler = new ProcessHandler();
28: Dispatcher dispatcher = new Dispatcher(processHandler);
29: saxParser.parse(in, dispatcher);
30: return processHandler.getProcess();
31: } catch (Exception e) {
32: throw new RuntimeException(e);
33: } finally {
34: try {
35: if (in != null)
36: in.close();
37: } catch (IOException ignore) {
38: }
39: }
40: }
41: }
|