Package com.adobe.epubcheck.opf

Examples of com.adobe.epubcheck.opf.DocumentValidator


          Messages.get("mode_version_not_supported"), mode, version));

      throw new RuntimeException(String.format(Messages.get("mode_version_not_supported"), mode, version));
    }

    DocumentValidator check = factory.newInstance(report, path,
        resourceProvider, modeMimeTypeMap.get(opsType),
        version);
    if (check.getClass() == EpubCheck.class)
    {
      int validationResult = ((EpubCheck)check).doValidate();
      if (validationResult == 0)
      {
        outWriter.println(Messages.get("no_errors__or_warnings"));
        return 0;
      }
      else if (validationResult == 1)
      {
        System.err.println(Messages.get("there_were_warnings"));
        return failOnWarnings ? 1 : 0;
      }
      System.err.println(Messages.get("there_were_errors"));
      return 1;
    }
    else
    {
      if (check.validate())
      {
        outWriter.println(Messages.get("no_errors__or_warnings"));
        return 0;
      }
      System.err.println(Messages.get("there_were_errors"));
View Full Code Here


          Messages.get("mode_version_not_supported"), mode, version));

      throw new RuntimeException(String.format(Messages.get("mode_version_not_supported"), mode, version));
    }

    DocumentValidator check = factory.newInstance(report, path,
        resourceProvider, modeMimeTypeMap.get(opsType),
        version);

    if (check.validate())
    {
      outWriter.println(Messages.get("no_errors__or_warnings"));
      return 0;
    }
    System.err.println(Messages.get("there_were_errors"));
View Full Code Here

  }
  static ValidationReport savedReport;

  public void testValidateDocument(String fileName, List<MessageId> errors, List<MessageId> warnings, List<MessageId> fatalErrors, String resultFile, boolean verbose)
  {
    DocumentValidator epubCheck;
    outWriter.printf("Starting testValidateDocument('%s')\n", fileName);
    ValidationReport testReport;
    if (fileName.startsWith("http://") || fileName.startsWith("https://"))
    {
      GenericResourceProvider resourceProvider = new URLResourceProvider(fileName);
      try
      {
        testReport = savedReport = new ValidationReport(fileName);
        epubCheck = new EpubCheck(
            resourceProvider.getInputStream(null), testReport, fileName);
      }
      catch (IOException e)
      {
        throw new RuntimeException(e);
      }
    }
    else
    {
      File testFile;
      try
      {
        URL url = this.getClass().getResource(basepath + fileName);
        URI uri = url.toURI();
        testFile = new File(uri);
      }
      catch (URISyntaxException e)
      {
        throw new IllegalStateException("Cannot find test file", e);
      }
      if (testFile.isDirectory())
      {
        Archive epub = new Archive(testFile.getPath());
        testReport = savedReport = new ValidationReport(epub.getEpubName());
        epub.createArchive();
        epubCheck = new EpubCheck(epub.getEpubFile(), testReport);
      }
      else
      {
        testReport = savedReport = new ValidationReport(fileName);
        epubCheck = new EpubCheck(new File(testFile.getPath()), testReport);
      }
    }


    epubCheck.validate();

    if (verbose)
    {
      outWriter.println(testReport);
    }
View Full Code Here

TOP

Related Classes of com.adobe.epubcheck.opf.DocumentValidator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.