|
|||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
Context2SimpleXPath.java | 50% | 46,2% | 50% | 47,4% |
|
1 | /* $Id: Context2SimpleXPath.java,v 1.3 2006/10/20 20:23:07 m31 Exp $ | |
2 | * | |
3 | * This file is part of the project "Hilbert II" - http://www.qedeq.org | |
4 | * | |
5 | * Copyright 2000-2006, Michael Meyling <mime@qedeq.org>. | |
6 | * | |
7 | * "Hilbert II" is free software; you can redistribute | |
8 | * it and/or modify it under the terms of the GNU General Public | |
9 | * License as published by the Free Software Foundation; either | |
10 | * version 2 of the License, or (at your option) any later version. | |
11 | * | |
12 | * This program is distributed in the hope that it will be useful, | |
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | */ | |
17 | ||
18 | package org.qedeq.kernel.xml.mapper; | |
19 | ||
20 | import java.io.IOException; | |
21 | ||
22 | import javax.xml.parsers.ParserConfigurationException; | |
23 | ||
24 | import org.qedeq.kernel.context.ModuleContext; | |
25 | import org.qedeq.kernel.xml.tracker.SimpleXPath; | |
26 | import org.qedeq.kernel.xml.tracker.XPathLocationFinder; | |
27 | import org.xml.sax.SAXException; | |
28 | ||
29 | /** | |
30 | * Parses complete qedeq modules. | |
31 | * | |
32 | * @version $Revision: 1.3 $ | |
33 | * @author Michael Meyling | |
34 | */ | |
35 | public final class Context2SimpleXPath { | |
36 | ||
37 | /** | |
38 | * Constructor. | |
39 | */ | |
40 | 0 | private Context2SimpleXPath() { |
41 | // nothing to do | |
42 | } | |
43 | ||
44 | /** | |
45 | * Transform context information into XML specific location information. | |
46 | * | |
47 | * @param context Abstract context description. | |
48 | * @return Information where the context could be found. | |
49 | * @throws RuntimeException FIXME dont! | |
50 | */ | |
51 | 4 | public static final SimpleXPath getXPath(final ModuleContext context) { |
52 | 4 | String xpath = Context2XPath.getXPath(context); |
53 | 4 | try { |
54 | 4 | final SimpleXPath find = XPathLocationFinder.getXPathLocation( |
55 | context.getModuleLocation(), xpath); | |
56 | 4 | if (find.getStartLocation() == null) { |
57 | 0 | System.out.println(context); // FIXME mime 20070108: no System.out and no RuntimeException |
58 | 0 | throw new RuntimeException("start not found: " + find); |
59 | } | |
60 | 4 | if (find.getEndLocation() == null) { |
61 | 0 | System.out.println(context); // FIXME mime 20070108: no System.out and no RuntimeException |
62 | 0 | throw new RuntimeException("end not found: " + find); |
63 | } | |
64 | 4 | return find; |
65 | } catch (ParserConfigurationException e) { | |
66 | 0 | throw new RuntimeException(e); |
67 | } catch (SAXException e) { | |
68 | 0 | throw new RuntimeException(e); |
69 | } catch (IOException e) { | |
70 | 0 | throw new RuntimeException(e); |
71 | } | |
72 | } | |
73 | ||
74 | } |
|