01: /*
02: * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.harness;
07:
08: import java.io.InputStreamReader;
09: import java.io.Reader;
10:
11: import org.xml.sax.EntityResolver;
12: import org.xml.sax.InputSource;
13:
14: public class ParEntryEntityResolver implements EntityResolver {
15: //
16: private static final String myProtocol = "parEntry:";
17:
18: public InputSource resolveEntity(String publicId, String systemId) {
19: //
20: String method = "resolveEntity: ";
21: System.out.println(method + "PublicId = " + publicId
22: + ", SystemId = " + systemId);
23:
24: InputSource is = null;
25:
26: //
27: if (systemId.startsWith(myProtocol)) {
28: String dtdResourceName = systemId.substring(myProtocol
29: .length());
30: System.out.println(method + "dtdResourceName = "
31: + dtdResourceName);
32: Reader reader = new InputStreamReader(getClass()
33: .getResourceAsStream(dtdResourceName));
34:
35: // reader can be null if running through desktop/src/com/sun/portal/desktop/deployment code.
36: // This will give error when running deployment code.
37: // reader cannot be null if running through dtdevtools/src/com/sun/portal/harness code.
38: if (reader != null)
39: is = new InputSource(reader);
40: }
41:
42: return is;
43: }
44: }
|