Package com.xmlmind.w2x.processor

## Class EpubStep

- java.lang.Object
- - com.xmlmind.w2x.processor.ProcessStep
  - - com.xmlmind.w2x.processor.SplitStep
    - - com.xmlmind.w2x.processor.EpubStep

-     public class EpubStep
      extends SplitStep

  This processing step is used to convert input XHTML+CSS document (typically created using a `ConvertStep`) or input semantic XHTML document (typically created using a `EditStep` running "`w2x:xed/main.xed`") to an EPUB 2 file.

  The outline level used to split the input XHTML+CSS document is specified by parameter `step_name.split-before-level`. This outline level is an integer between 0 and 8 inclusive. Default outline level is 0.

  The save file of the EPUB document is specified by parameter `step_name.out-file`.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class com.xmlmind.w2x.processor.SplitStep

      `SplitStep.Part`

  - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected static Name` | `CASE_NAME` |
    `protected static Name` | `CONTENT_NAME` |
    `protected static String` | `COVER_HTML` |
    `protected static Namespace` | `DC_NS` |
    `protected static Namespace` | `DCTERMS_NS` |
    `protected static Name` | `DEFAULT_NAME` |
    `protected static Name` | `DOC_TITLE_NAME` |
    `protected static Name` | `GUIDE_NAME` |
    `protected static Name` | `HEAD_NAME` |
    `protected static Name` | `IDREF_NAME` |
    `protected static Name` | `ITEM_NAME` |
    `protected static Name` | `ITEMREF_NAME` |
    `protected static Name` | `LINEAR_NAME` |
    `protected static Name` | `MANIFEST_NAME` |
    `protected static Name` | `MEDIA_TYPE_NAME` |
    `protected static Name` | `META_NAME` |
    `protected static Name` | `METADATA_NAME` |
    `protected static Name` | `NAV_LABEL_NAME` |
    `protected static Name` | `NAV_MAP_NAME` |
    `protected static Name` | `NAV_POINT_NAME` |
    `protected static Name` | `NCX_NAME` |
    `protected static Namespace` | `NCX_NS` |
    `protected static PrefixEntry[]` | `NCX_PREFIX_ENTRIES` |
    `protected static Name` | `OPF_META_NAME` |
    `protected static Namespace` | `OPF_NS` |
    `protected static PrefixEntry[]` | `OPF_PREFIX_ENTRIES` |
    `protected static Namespace` | `OPS_NS` |
    `protected static Name` | `PACKAGE_NAME` |
    `protected static Name` | `PLAY_ORDER_NAME` |
    `protected static Name` | `REFERENCE_NAME` |
    `protected static Name` | `REQUIRED_NAMESPACE_NAME` |
    `protected static Name` | `SPINE_NAME` |
    `protected static Name` | `SWITCH_NAME` |
    `protected static Name` | `TEXT_NAME` |
    `protected static Name` | `TOC_NAME` |
    `protected static Name` | `UNIQUE_IDENTIFIER_NAME` |
    `protected static Name` | `VERSION_NAME` |

    - ### Fields inherited from class com.xmlmind.w2x.processor.SplitStep

      `COLS_ATTR, FRAME_ELEM, FRAMESET_ELEM, SCROLLING_ATTR, TOC_CSS`

    - ### Fields inherited from class com.xmlmind.w2x.processor.ProcessStep

      `stepName`

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `EpubStep​(String stepName)` | Constructs a EpubStep having specified name.

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addItems​(File dir, int urlPrefixLength, Map<File,​String> fileToId, Element manifest)` |
    `protected void` | `addMeta​(Document xhtmlDoc, Element metadata)` |
    `protected void` | `createEpub​(File tempDir, File outFile, ProgressMonitor monitor)` |
    `protected File` | `doProcess​(Document xhtmlDoc, File tempFile, Map<String,​String> parameters, int[] stepCounter, ProgressMonitor monitor)` |
    `protected String` | `mediaType​(String ext)` |
    `protected static Element` | `newItem​(String id, String href, String mediaType)` |
    `protected static Element` | `newItemref​(String id)` |
    `protected static Element` | `newMeta​(String name, String content)` |
    `protected static Element` | `newSimpleElement​(Namespace ns, String localPart, String text)` |
    `protected static Element` | `newText​(String textContent)` |
    `void` | `process​(Object[] state, Map<String,​String> parameters, int[] stepCounter, ProgressMonitor monitor)` | Execute this processing step.
    `protected void` | `saveContent​(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File file, ProgressMonitor monitor)` |
    `protected String` | `saveCover​(URL imageURL, File file, ProgressMonitor monitor)` |
    `protected void` | `saveDocument​(Document doc, boolean indent, String encoding, File file, ProgressMonitor monitor)` |
    `protected void` | `saveTOC​(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot, File file, ProgressMonitor monitor)` |
    `protected Document` | `toContent​(List<SplitStep.Part> parts, String coverName, String coverImageName, String epubIdent, String defaultLang, Document xhtmlDoc, File tempDir)` |
    `protected Document` | `toTOC​(List<SplitStep.Part> parts, String epubIdent, boolean omitTOCRoot)` |
    `protected static void` | `zipEpub​(File srcDir, File zipFile)` |

    - ### Methods inherited from class com.xmlmind.w2x.processor.SplitStep

      `addPart, collectCounters, collectIds, collectNotes, copyNotes, copyNotes2, createCharsetMeta, createFrameset, createPartTemplate, createTOCStyle, creatingFile, deleteNotes, findById, findCharset, findCharsetMeta, findNotes, findParentPart, findTitle, fixLinks, getAllText, getBoxFirstChildElement, getOutlineLevel, isNote, isNoteRef, isNoteSeparator, newOutFile, newOutFile, parseCounterPI, parseCounterReset, processCounters, processLinks, processNotes, processNotes2, processParts, resetCounters, saveParts, setNotes, splitDocument, toTOC, useSameChunk`

    - ### Methods inherited from class com.xmlmind.w2x.processor.ProcessStep

      `debugParameters, equals, getAllParameters, getBooleanParameter, getFileParameter, getIntParameter, getParameter, getURLParameter, hashCode, illegalState, joinAllParameters, missingParameter, parameterName, progress, toString, urlOrFile`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### OPS_NS

          protected static final Namespace OPS_NS

    - #### SWITCH_NAME

          protected static final Name SWITCH_NAME

    - #### CASE_NAME

          protected static final Name CASE_NAME

    - #### DEFAULT_NAME

          protected static final Name DEFAULT_NAME

    - #### REQUIRED_NAMESPACE_NAME

          protected static final Name REQUIRED_NAMESPACE_NAME

    - #### NCX_NS

          protected static final Namespace NCX_NS

    - #### NCX_PREFIX_ENTRIES

          protected static final PrefixEntry[] NCX_PREFIX_ENTRIES

    - #### NCX_NAME

          protected static final Name NCX_NAME

    - #### HEAD_NAME

          protected static final Name HEAD_NAME

    - #### META_NAME

          protected static final Name META_NAME

    - #### DOC_TITLE_NAME

          protected static final Name DOC_TITLE_NAME

    - #### TEXT_NAME

          protected static final Name TEXT_NAME

    - #### NAV_MAP_NAME

          protected static final Name NAV_MAP_NAME

    - #### NAV_POINT_NAME

          protected static final Name NAV_POINT_NAME

    - #### NAV_LABEL_NAME

          protected static final Name NAV_LABEL_NAME

    - #### CONTENT_NAME

          protected static final Name CONTENT_NAME

    - #### VERSION_NAME

          protected static final Name VERSION_NAME

    - #### PLAY_ORDER_NAME

          protected static final Name PLAY_ORDER_NAME

    - #### OPF_NS

          protected static final Namespace OPF_NS

    - #### DC_NS

          protected static final Namespace DC_NS

    - #### DCTERMS_NS

          protected static final Namespace DCTERMS_NS

    - #### OPF_PREFIX_ENTRIES

          protected static final PrefixEntry[] OPF_PREFIX_ENTRIES

    - #### PACKAGE_NAME

          protected static final Name PACKAGE_NAME

    - #### METADATA_NAME

          protected static final Name METADATA_NAME

    - #### OPF_META_NAME

          protected static final Name OPF_META_NAME

    - #### MANIFEST_NAME

          protected static final Name MANIFEST_NAME

    - #### ITEM_NAME

          protected static final Name ITEM_NAME

    - #### SPINE_NAME

          protected static final Name SPINE_NAME

    - #### ITEMREF_NAME

          protected static final Name ITEMREF_NAME

    - #### GUIDE_NAME

          protected static final Name GUIDE_NAME

    - #### REFERENCE_NAME

          protected static final Name REFERENCE_NAME

    - #### UNIQUE_IDENTIFIER_NAME

          protected static final Name UNIQUE_IDENTIFIER_NAME

    - #### MEDIA_TYPE_NAME

          protected static final Name MEDIA_TYPE_NAME

    - #### TOC_NAME

          protected static final Name TOC_NAME

    - #### IDREF_NAME

          protected static final Name IDREF_NAME

    - #### LINEAR_NAME

          protected static final Name LINEAR_NAME

    - #### COVER_HTML

          protected static final String COVER_HTML

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### EpubStep

          public EpubStep​(String stepName)

      Constructs a EpubStep having specified name.

  - ### Method Detail

    - #### process

          public void process​(Object[] state,
                              Map<String,​String> parameters,
                              int[] stepCounter,
                              ProgressMonitor monitor)
                       throws Exception

      Description copied from class: `SplitStep`
      Execute this processing step.

      `state[0]` contains:

      - Before this method is executed: an XHTML+CSS document (typically created using a `ConvertStep`).
      - After this method is executed: the save file containing the frameset.
      Overrides:
        `process` in class `SplitStep`
      Parameters:
        `state` - contains the current state of processing: a `Document` or a `File`.

        This object is used as the input of this step and thus, is processed by this step.

        After its execution, this method generally updates the `state` array with a new `Document` or `File` to pass the result/output of this step to the next step.

        `parameters` - all the parameters passed to the `Processor` owning and thus executing this process step.

        Parameters which are relevant to this processing step are prefixed with "``ProcessStep.stepName`.`".

        `stepCounter` - contains the rank of previously executed processing step. Must be incremented by this method.
        `monitor` - used to monitor the progress of the processing steps

        Invoking convenience method `ProcessStep.progress(java.lang.String, int[], com.xmlmind.util.ProgressMonitor)` suffices to make good use of both `monitor` and `stepCounter`.

      Throws:
        `Exception` - if for any reason, this method fails

    - #### doProcess

          protected File doProcess​(Document xhtmlDoc,
                                   File tempFile,
                                   Map<String,​String> parameters,
                                   int[] stepCounter,
                                   ProgressMonitor monitor)
                            throws Exception

      Throws:
        `Exception`

    - #### saveDocument

          protected void saveDocument​(Document doc,
                                      boolean indent,
                                      String encoding,
                                      File file,
                                      ProgressMonitor monitor)
                               throws CanceledException,
                                      IOException

      Overrides:
        `saveDocument` in class `SplitStep`
      Throws:
        `CanceledException`
        `IOException`

    - #### saveTOC

          protected void saveTOC​(List<SplitStep.Part> parts,
                                 String epubIdent,
                                 boolean omitTOCRoot,
                                 File file,
                                 ProgressMonitor monitor)
                          throws CanceledException,
                                 IOException

      Throws:
        `CanceledException`
        `IOException`

    - #### toTOC

          protected Document toTOC​(List<SplitStep.Part> parts,
                                   String epubIdent,
                                   boolean omitTOCRoot)

    - #### newMeta

          protected static final Element newMeta​(String name,
                                                 String content)

    - #### newText

          protected static final Element newText​(String textContent)

    - #### saveCover

          protected String saveCover​(URL imageURL,
                                     File file,
                                     ProgressMonitor monitor)
                              throws CanceledException,
                                     IOException

      Throws:
        `CanceledException`
        `IOException`

    - #### saveContent

          protected void saveContent​(List<SplitStep.Part> parts,
                                     String coverName,
                                     String coverImageName,
                                     String epubIdent,
                                     String defaultLang,
                                     Document xhtmlDoc,
                                     File file,
                                     ProgressMonitor monitor)
                              throws CanceledException,
                                     IOException

      Throws:
        `CanceledException`
        `IOException`

    - #### toContent

          protected Document toContent​(List<SplitStep.Part> parts,
                                       String coverName,
                                       String coverImageName,
                                       String epubIdent,
                                       String defaultLang,
                                       Document xhtmlDoc,
                                       File tempDir)
                                throws IOException

      Throws:
        `IOException`

    - #### newSimpleElement

          protected static final Element newSimpleElement​(Namespace ns,
                                                          String localPart,
                                                          String text)

    - #### addMeta

          protected void addMeta​(Document xhtmlDoc,
                                 Element metadata)

    - #### newItem

          protected static final Element newItem​(String id,
                                                 String href,
                                                 String mediaType)

    - #### addItems

          protected void addItems​(File dir,
                                  int urlPrefixLength,
                                  Map<File,​String> fileToId,
                                  Element manifest)
                           throws IOException

      Throws:
        `IOException`

    - #### mediaType

          protected String mediaType​(String ext)

    - #### newItemref

          protected static final Element newItemref​(String id)

    - #### createEpub

          protected void createEpub​(File tempDir,
                                    File outFile,
                                    ProgressMonitor monitor)
                             throws CanceledException,
                                    IOException

      Throws:
        `CanceledException`
        `IOException`

    - #### zipEpub

          protected static final void zipEpub​(File srcDir,
                                              File zipFile)
                                       throws IOException

      Throws:
        `IOException`