KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > j2ee > blueprints > docoriented > client > stringposervice > POEntityResolver


1 /* Copyright 2005 Sun Microsystems, Inc. All rights reserved. You may not modify, use, reproduce, or distribute this software except in compliance with the terms of the License at:
2  http://developer.sun.com/berkeley_license.html
3  $Id: POEntityResolver.java,v 1.2 2005/08/10 20:28:03 smitha Exp $ */

4
5 package com.sun.j2ee.blueprints.docoriented.client.stringposervice;
6
7 import org.xml.sax.*;
8 import java.io.*;
9
10 public class POEntityResolver implements EntityResolver {
11     
12     private static String JavaDoc RESOURCE_LOCATION = "/resources/";
13     private static String JavaDoc BLUEPRINTS_NS = "http://java.sun.com/blueprints/schemas/";
14     
15     public InputSource resolveEntity(String JavaDoc publicId, String JavaDoc systemId) {
16         if (systemId.equals(BLUEPRINTS_NS + "PurchaseOrder.xsd")) {
17             return getClassPathSource("PurchaseOrder.xsd");
18         } else{
19             return null;
20         }
21     }
22     
23     private InputSource getClassPathSource(String JavaDoc name) {
24         InputStream is = null;
25         try {
26             is = getClass().getResourceAsStream(RESOURCE_LOCATION + name);
27             return new InputSource(is);
28         } catch (Exception JavaDoc exe) {
29             System.err.println("POEntityResolver error resolving: " + name);
30             exe.printStackTrace();
31         }
32         return null;
33     }
34 }
35
36
Popular Tags