Пример #1
0
  @Override
  public URI call() throws Exception {
    // System.out.println( "SVGLoad start"+xmlBase.toString());
    SVGLoader handler = new SVGLoader(xmlBase, univ, false);

    // Place this docment in the universe before it is completely loaded
    // so that the load process can refer to references within it's current
    // document
    univ.loadedDocs.put(xmlBase, handler.getLoadedDiagram());
    XMLReader reader = null;
    InputSource is = null;
    try {
      is = input == null ? univ.getInputSource(xmlBase) : input;
      // Parse the input
      reader = univ.getXMLReaderCached();
      reader.setEntityResolver(
          new EntityResolver() {

            @Override
            public InputSource resolveEntity(String publicId, String systemId) {
              // Ignore all DTDs
              return new InputSource(new ByteArrayInputStream(new byte[0]));
            }
          });
      reader.setContentHandler(handler);
      reader.parse(is);

      for (SVGLoaderClient eachRunnable : doAfter) {
        eachRunnable.imageLoaded(xmlBase);
      }

      //            SAXParser saxParser = factory.newSAXParser();
      //            saxParser.parse(new InputSource(new BufferedReader(is)), handler);
      // System.out.println( "SVGLoad end"+xmlBase.toString());
      return xmlBase;
    } catch (SAXParseException sex) {
      System.err.println("Error processing " + xmlBase);
      System.err.println(sex.getMessage());
      sex.printStackTrace();

      univ.loadedDocs.remove(xmlBase);
      return null;
    } catch (Throwable t) {
      System.err.println(xmlBase.toASCIIString());
      t.printStackTrace();
    } finally {

      SVGUniverse.closeStreamQuietly(is.getByteStream());
      SVGUniverse.closeReaderQuietly(is.getCharacterStream());
    }
    return null;
  }