Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
e74df9f8f4c9d426d1af98aba2d8d5a72de30f5f
[simgrid.git] / src / java / simgrid / msg / DTDResolver.java
1 /*\r
2  * simgrid.msg.DTDResolver.java    1.00 07/05/01\r
3  *\r
4  * Copyright 2006,2007 Martin Quinson, Malek Cherier           \r
5  * All right reserved. \r
6  *\r
7  * This program is free software; you can redistribute \r
8  * it and/or modify it under the terms of the license \r
9  *(GNU LGPL) which comes with this package. \r
10  */  \r
11   \r\r\rpackage simgrid.msg;
12 \r\rimport java.io.InputStream;
13 \rimport org.xml.sax.EntityResolver;
14 \rimport org.xml.sax.InputSource;
15 \rimport org.xml.sax.SAXException;
16 \r\rpublic class DTDResolver implements EntityResolver {
17   \r\rpublic InputSource resolveEntity(String publicID, String systemID) \r
18     throws SAXException {
19     \r\r\rif (!systemID.endsWith("surfxml.dtd")) {
20       \rSystem.out.
21         println("\n MSG - Warning - the platform used seams invalid\n");
22       \rreturn null;
23     \r}
24     \r\r
25       /* try to get the DTD from the classpath */ \r
26       InputStream in = getClass().getResourceAsStream("/surfxml.dtd");
27     \r\rif (null == in)
28       \r
29         /* try to get the DTD from the surf dir in the jar */ \r
30         in = getClass().getResourceAsStream("/surf/surfxml.dtd");
31     \rif (null == in)
32       \r
33         /* try to get the DTD from the directory Simgrid */ \r
34         in = getClass().getResourceAsStream("/Simgrid/surfxml.dtd");
35     \r\rif (null == in)
36       \r
37         /* try to get the DTD from the directory Simgrid/msg */ \r
38         in = getClass().getResourceAsStream("/Simgrid/msg/surfxml.dtd");
39     \r\rif (null == in) {
40       \rSystem.err.println("\nMSG - XML DTD not found (" +
41                           systemID.toString() +
42                           ").\n\nPlease put this file in one of the following destinations :\n\n"
43                           + \r"   - classpath;\n" +
44                           \r"   - the directory Simgrid;\n" +
45                           \r"   - the directory Simgrid/msg;\n" +
46                           \r"   - the directory of you simulation.\n\n" +
47                           \r"Once the DTD puted in one of the previouse destinations, retry you simulation.\n");
48       \r\r
49         /* \r
50          * If not founded, returning null makes process continue normally (try to get \r
51          * the DTD from the current directory \r
52          */ \r
53         return null;
54     \r}
55     \r\rreturn new InputSource(in);
56   \r}
57 \r}
58
59 \r