Package com.adobe.epubcheck.ctc

Source Code of com.adobe.epubcheck.ctc.CheckManager

package com.adobe.epubcheck.ctc;

import com.adobe.epubcheck.api.Report;
import com.adobe.epubcheck.ctc.ContentValidator.ValidationType;
import com.adobe.epubcheck.ctc.epubpackage.EpubPackage;
import com.adobe.epubcheck.messages.MessageId;
import com.adobe.epubcheck.messages.MessageLocation;
import com.adobe.epubcheck.util.EPUBVersion;
import com.adobe.epubcheck.util.outWriter;
import com.adobe.epubcheck.util.Messages;

import java.util.zip.ZipFile;

public class CheckManager
{
  private final EpubPackage epack;
  private final EpubCheckContentFactory factory;
  private Report report;

  public CheckManager(ZipFile zip, Report report)
  {
    setReport(report);
    PackageReader pr = new PackageReader(zip, report);
    epack = pr.readPackageData();
    factory = EpubCheckContentFactory.getInstance();
  }

  private void setReport(Report report)
  {
    this.report = report;
  }

  public void checkPackage()
  {
    if (epack == null)
    {
      return;
    }

    EPUBVersion version = epack.getVersion();
    outWriter.println(String.format(Messages.get("validating_against_epub_version"), version));

    if (version != null && version.equals(EPUBVersion.VERSION_3))
    {
      factory.newInstance(report, ValidationType.RENDITION, epack).validate();
      factory.newInstance(report, ValidationType.CFI, epack).validate();
      factory.newInstance(report, ValidationType.METADATA_V3, epack).validate();
      factory.newInstance(report, ValidationType.NAV, epack).validate();
    }
    else if (version != null && EPUBVersion.VERSION_2.equals(version))
    {
      factory.newInstance(report, ValidationType.EPUB3_STRUCTURE, epack).validate();
      factory.newInstance(report, ValidationType.METADATA_V2, epack).validate();
    }
    else
    {
      report.message(MessageId.OPF_024, new MessageLocation(epack.getFileName(), -1, -1), version);
    }

    factory.newInstance(report, ValidationType.NCX, epack).validate();
    factory.newInstance(report, ValidationType.MULTIPLE_CSS, epack).validate();
    factory.newInstance(report, ValidationType.HTML_STRUCTURE, epack).validate();
    factory.newInstance(report, ValidationType.LINK, epack).validate();
    factory.newInstance(report, ValidationType.CSS_SEARCH, epack).validate();
    factory.newInstance(report, ValidationType.TOC, epack).validate();
    factory.newInstance(report, ValidationType.LANG, epack).validate();
    factory.newInstance(report, ValidationType.SPINE, epack).validate();
    factory.newInstance(report, ValidationType.TEXT, epack).validate();
    factory.newInstance(report, ValidationType.SCRIPT, epack).validate();
    factory.newInstance(report, ValidationType.SPAN, epack).validate();
    factory.newInstance(report, ValidationType.SVG, epack).validate();
  }
}
TOP

Related Classes of com.adobe.epubcheck.ctc.CheckManager

TOP
Copyright © 2018 www.massapi.com. 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.