Exemplo n.º 1
0
    @Override
    public void SetOperationResult(final int arg0) throws IOException {
      if (arg0 != IInArchive.NExtract_NOperationResult_kOK) {
        this.NumErrors++;
        switch (arg0) {
          case IInArchive.NExtract_NOperationResult_kUnSupportedMethod:
            throw new IOException("Unsupported Method");
          case IInArchive.NExtract_NOperationResult_kCRCError:
            throw new IOException("CRC Failed");
          case IInArchive.NExtract_NOperationResult_kDataError:
            throw new IOException("Data Error");
          default:
            // throw new IOException("Unknown Error");
        }
      } else
        try {

          if (this.cfos != null) {
            // parse the file
            Document[] theDocs;
            // workaround for relative links in file, normally '#' shall be used behind the
            // location, see
            // below for reversion of the effects
            final MultiProtocolURI url =
                MultiProtocolURI.newURL(doc.dc_source(), this.prefix + "/" + super.filePath);
            final String mime =
                TextParser.mimeOf(super.filePath.substring(super.filePath.lastIndexOf('.') + 1));
            theDocs = TextParser.parseSource(url, mime, null, this.cfos.toByteArray());

            this.doc.addSubDocuments(theDocs);
          }
        } catch (final Exception e) {
          final IOException ex =
              new IOException(
                  "error parsing extracted content of " + super.filePath + ": " + e.getMessage());
          ex.initCause(e);
          throw ex;
        }
    }