Exemplo n.º 1
0
    // return the resource as a stream
    private InputStream mapResource(String publicId) {
      if (publicId == null || id2resource == null) return null;

      String resourceName = (String) id2resource.get(publicId);
      ClassLoader loader = null;

      if (resourceName == null) return null;

      if (id2loader != null) loader = (ClassLoader) id2loader.get(publicId);

      if (loader == null) return ClassLoader.getSystemResourceAsStream(resourceName);
      return loader.getResourceAsStream(resourceName);
    }
Exemplo n.º 2
0
    // This method is called whenever an external entity is accessed
    // for the first time.
    public InputSource resolveEntity(String publicId, String systemId) {
      // Map the external entity to a local file
      if (URL_PROPERTY_LIST.equals(systemId)) {
        return new InputSource(ClassLoader.getSystemResourceAsStream(FILENAME_PROPERTY_LIST));
      }

      // Returning null causes the caller to try accessing the systemid
      return null;
    }