de.vc.jfo

## Class Document

- java.lang.Object
- - de.vc.xml.AbstractNode
  - - de.vc.xml.AbstractNodeWithAttributes
    - - de.vc.jfo.FormattingObject
      - - de.vc.jfo.Document

- All Implemented Interfaces:
    Node, NodeElement, java.io.Serializable, java.lang.Cloneable

      public class Document
      extends FormattingObject

  This is the top node/object of the formatting object tree. It holds an fo:layout-master-set formatting object (which holds all masters used in the document), an optional fo:declarations, and one or more fo:page-sequence objects. Each fo:page-sequence represents a sequence of pages that result from formatting the content children of the fo:page-sequence.
  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Document.Factory`

  - ### Field Summary

    - ### Fields inherited from class de.vc.jfo.FormattingObject

      `EMPTY_ARRAY`

    - ### Fields inherited from class de.vc.xml.AbstractNodeWithAttributes

      `MAP_TYPE_FLYWEIGHT, MAP_TYPE_HASH`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Document()` Creates a new empty document.
    `Document(PageMaster pageMaster)` Creates a new document, adds a PageMaster and a empty PageSequence.
    `Document(SimplePageMaster.PageDescription pageDesc)` Creates a new document, adds a SimplePageMaster and a empty PageSequence.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(PageSequence ps)` Adds a PageSequence to this document.
    `boolean` | `addUnsafe(java.lang.Object child)` Adds a NodeElement to this FormattingObject.
    `void` | `append(Document doc)` Appends another document to this document.
    `void` | `append(Document doc, boolean pageNumberingRestart)` Appends another document to this document.
    `void` | `appendContent(Document doc)` Appends the content of the given document to this document.
    `java.lang.Object` | `clone()` Clones this document.
    `Document` | `copy()` Similar to clone(), but throws no CloneNotSupportedException.
    `java.lang.String` | `getBaseURL()` Gets the base URL that is used to resolve relative URLs.
    `Declarations` | `getDeclarations()` Gets declarations of this document.
    `java.util.List` | `getElements()` Gets childreen of this node.
    `PageSequence` | `getFirstPageSequence()` Gets the first PageSequence.
    `PageSequence` | `getLastPageSequence()` Gets the last PageSequence.
    `LayoutMasterSet` | `getLayoutMasterSet()` Gets the LayoutMasterSet of this FO-Document.
    `java.util.List<PageSequence>` | `getPageSequences()` Gets the list of all contained PageSequences.
    `boolean` | `removeElement(java.lang.Object o)` Removes an element from the list of page-sequences.
    `boolean` | `render(OutputFormat outputFormat, java.io.File out)` Renders this document into given output format into a file.
    `boolean` | `render(OutputFormat outputFormat, java.io.OutputStream out)` Renders this document into given output format into a stream.
    `boolean` | `render(Renderer renderer, OutputFormat outputFormat, java.io.File out)` Renders this document into given output format to a file.
    `boolean` | `render(Renderer renderer, OutputFormat outputFormat, java.io.OutputStream os)` Renders this document into given output format.
    `boolean` | `replaceElement(java.lang.Object oldElement, java.lang.Object newElement)` Replaces an element in the list of page-sequences.
    `void` | `setBaseURL(java.lang.String baseURL)` Sets the base URL that is used to resolve relative URLs.
    `void` | `setDeclaration(Declarations declarations)` Sets some declarations of this document.
    `void` | `writeTo(java.io.OutputStream os)` Writes full XML-tree into give OutputStream as XML.
    `void` | `writeTo(XMLWriter writer)` Writes this node through an XML-Writer.

    - ### Methods inherited from class de.vc.jfo.FormattingObject

      `addElement, addElement, addUnsafe, cloned, clonedList, createUniqueID, doGetAttribute, doSetAttribute, elementCount, get, getAbsolutePosition, getAccessibility, getAttributeMap, getBackground, getBorder, getDefinedAttributes, getDocument, getFont, getID, getLanguage, getLogger, getMargin, getMeasureValue, getObjectValue, getObjectValue, getObjectValue, getObjectValue, getOrphans, getPadding, getParentFO, getRelativePosition, getWidows, hasBorder, hasID, hasPadding, isEmpty, isHyphenation, removeElement, setAbsolutePosition, setAccessibility, setAttribute, setAttribute, setAttribute, setAttribute, setAttribute, setBackground, setBorder, setElement, setFont, setHyphenation, setID, setLanguage, setLanguage, setMargin, setOrphans, setPadding, setRelativePosition, setWidows`

    - ### Methods inherited from class de.vc.xml.AbstractNodeWithAttributes

      `getDefaultMapType, setDefaultMapType`

    - ### Methods inherited from class de.vc.xml.AbstractNode

      `addAttributeChangeListener, addElements, addElements, clearEqualAttributes, clearInheratedAttribute, clearInheratedAttributes, clearValue, contains, contains, copyAttributes, createID, findFirstNodeWithText, findNode, findNodesWithText, fire, fireSaxEvents, firstElement, getAttrAsBoolean, getAttrAsInteger, getAttrAsString, getAttrAsString, getAttribute, getAttribute, getAttributeMap, getContentText, getContentText, getDefinedAttributes, getElements, getElements, getElements, getFirstElement, getIndex, getLocalName, getNamespacePrefix, getNamespacePrefixes, getNamespaceURI, getParent, getParent, getParent, getParentOrThis, getQName, getRoot, hasEqualAttrs, indexOf, lastElement, liftInheritedAttribute, removeAttributeChangeListener, setAttribute, setAttributes, setAttrIfNotNull, setEnableAttributeChangeEvent, setNamespace, setParent, setQName, setUndefinedAttributes, writeTo, writeTo`

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

      `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Document

          public Document()

      Creates a new empty document.

    - #### Document

          public Document(SimplePageMaster.PageDescription pageDesc)

      Creates a new document, adds a SimplePageMaster and a empty PageSequence.
      Parameters:
        `pageDesc` - PageDescription of pages.

    - #### Document

          public Document(PageMaster pageMaster)

      Creates a new document, adds a PageMaster and a empty PageSequence.
      Parameters:
        `pageMaster` - PageMaster.

  - ### Method Detail

    - #### clone

          public java.lang.Object clone()
                                 throws java.lang.CloneNotSupportedException

      Clones this document.
      Specified by:
        `clone` in interface `NodeElement`
      Overrides:
        `clone` in class `FormattingObject`
      Returns:
        Clone of this document.
      Throws:
        `java.lang.CloneNotSupportedException` - Should never be thrown.

    - #### copy

          public Document copy()

      Similar to clone(), but throws no CloneNotSupportedException.
      Returns:
        Copy of this document.

    - #### getLayoutMasterSet

          public LayoutMasterSet getLayoutMasterSet()

      Gets the LayoutMasterSet of this FO-Document.
      Returns:
        LayoutMasterSet.

    - #### getPageSequences

          public java.util.List<PageSequence> getPageSequences()

      Gets the list of all contained PageSequences.
      Returns:
        Unmodifiable list of PageSequences.

    - #### getElements

          public java.util.List getElements()

      Description copied from class: `AbstractNode`
      Gets childreen of this node. A child is typical an instance of `NodeElement` or `String`.
      Specified by:
        `getElements` in interface `Node`
      Specified by:
        `getElements` in class `AbstractNode`
      Returns:
        Childreen.

    - #### add

          public void add(PageSequence ps)

      Adds a PageSequence to this document. If PageSequence references a not registered PageMaster, PageMaster will be added to LayoutMasterSet.
      Parameters:
        `ps` - PageSequence.

    - #### removeElement

          public boolean removeElement(java.lang.Object o)

      Removes an element from the list of page-sequences.
      Specified by:
        `removeElement` in interface `Node`
      Overrides:
        `removeElement` in class `FormattingObject`
      Parameters:
        `o` - NodeElement
      Returns:
        `true` if this node contained the specified element.

    - #### replaceElement

          public boolean replaceElement(java.lang.Object oldElement,
                               java.lang.Object newElement)

      Replaces an element in the list of page-sequences.
      Specified by:
        `replaceElement` in interface `Node`
      Overrides:
        `replaceElement` in class `FormattingObject`
      Parameters:
        `oldElement` - Old element.
        `newElement` - New element.
      Returns:
        `true` if this node contained `oldElement`

    - #### setDeclaration

          public void setDeclaration(Declarations declarations)

      Sets some declarations of this document.
      Parameters:
        `declarations` - Declarations.

    - #### getDeclarations

          public Declarations getDeclarations()

      Gets declarations of this document. May be NULL.
      Returns:
        Declarations.

    - #### getLastPageSequence

          public PageSequence getLastPageSequence()

      Gets the last PageSequence. If there is no PageSequence, a new PageSequence will be added.
      Returns:
        Last PageSequence (never NULL).

    - #### getFirstPageSequence

          public PageSequence getFirstPageSequence()

      Gets the first PageSequence. If there is no PageSequence, a new PageSequence will be added.
      Returns:
        First PageSequence (never NULL).

    - #### append

          public void append(Document doc)

      Appends another document to this document. Don't use the appended document any longer. If you want to add a document multiple times you have to clone it. Note: IDs and master-names of appended document might be changed if there are collusion with this document.
      Parameters:
        `doc` - A document.

    - #### append

          public void append(Document doc,
                    boolean pageNumberingRestart)

      Appends another document to this document. Don't use the appended document any longer. If you want to add a document multiple times you have to clone it. Note: IDs and master-names of appended document might be changed if there are collusion with this document.
      Parameters:
        `doc` - A document.
        `pageNumberingRestart` - true, if page-numbering should restart at first page of appended document.

    - #### appendContent

          public void appendContent(Document doc)

      Appends the content of the given document to this document. Don't use the appended document any longer. If you want to add a document multiple times you must clone it. Note: IDs and master-names of appended document might be changed if there are collusion with this document.
      Parameters:
        `doc` - A document.

    - #### render

          public boolean render(Renderer renderer,
                       OutputFormat outputFormat,
                       java.io.OutputStream os)

      Renders this document into given output format. Note that the stream is not closed.
      For detailled exception handling you might use the `Rendered.render()` methodes that throws exceptions.
      Parameters:
        `renderer` - Used renderer. (See package de.vc.jfo.renderer)
        `outputFormat` - Output format. (Must be supported by renderer)
        `os` - Output stream where rendered document is written into.
      Returns:
        `true` if document was rendered without an exception.

    - #### render

          public boolean render(Renderer renderer,
                       OutputFormat outputFormat,
                       java.io.File out)

      Renders this document into given output format to a file.
      For detailled exception handling you might use the `Rendered.render()` methodes that throws exceptions.
      Parameters:
        `renderer` - Used renderer. (See package de.vc.jfo.renderer)
        `outputFormat` - Output format. (Must be supported by renderer)
        `out` - Output file.
      Returns:
        `true` if document was rendered without an exception.

    - #### render

          public boolean render(OutputFormat outputFormat,
                       java.io.File out)

      Renders this document into given output format into a file. The concret Renderer is created by RendererFactory.
      For detailled exception handling you might use the `Rendered.render()` methodes that throws exceptions.
      Parameters:
        `outputFormat` - Output format.
        `out` - Output file.
      Returns:
        `true` if document was rendered without an exception.

    - #### render

          public boolean render(OutputFormat outputFormat,
                       java.io.OutputStream out)

      Renders this document into given output format into a stream. The concret Renderer is created by RendererFactory.
      For detailled exception handling you might use the `Rendered.render()` methodes that throws exceptions.
      Parameters:
        `outputFormat` - Output format.
        `out` - Output file.
      Returns:
        `true` if document was rendered without an exception.

    - #### writeTo

          public void writeTo(XMLWriter writer)

      Description copied from class: `AbstractNode`
      Writes this node through an XML-Writer.
      Specified by:
        `writeTo` in interface `NodeElement`
      Overrides:
        `writeTo` in class `AbstractNode`
      Parameters:
        `writer` - Writer.

    - #### setBaseURL

          public void setBaseURL(java.lang.String baseURL)

      Sets the base URL that is used to resolve relative URLs.
      Parameters:
        `baseURL` - URL

    - #### getBaseURL

          public java.lang.String getBaseURL()

      Gets the base URL that is used to resolve relative URLs.
      Returns:
        base URL.

    - #### writeTo

          public void writeTo(java.io.OutputStream os)
                       throws java.io.IOException

      Description copied from class: `AbstractNode`
      Writes full XML-tree into give OutputStream as XML. OutputStream is closed after writing.
      Overrides:
        `writeTo` in class `AbstractNode`
      Parameters:
        `os` - OutputStream
      Throws:
        `java.io.IOException`

    - #### addUnsafe

          public boolean addUnsafe(java.lang.Object child)

      Description copied from class: `FormattingObject`
      Adds a NodeElement to this FormattingObject. You must ensure, that this FormattingObject can contain given element.
      Overrides:
        `addUnsafe` in class `FormattingObject`
      Parameters:
        `child` - Element.
      Returns:
        `false` if this FO is unable to add object.

© 2003-2011 by Sascha Schmidt (vision-cloud.de). All Rights Reserved.