Package org.jfree.layouting.normalizer.content

## Class ContentNormalizer

- java.lang.Object
- - org.jfree.layouting.normalizer.content.ContentNormalizer

- All Implemented Interfaces:
    `Normalizer`, `StatefullComponent`

      public class ContentNormalizer
      extends java.lang.Object
      implements Normalizer

  This class is responsible for normalizing content from the 'content' style property and for hiding content that has 'display:none' set. The ContentNormalizer also resolves all styles for elements.

  Pagebreaks are determined in the model-builder or the layouter. A pagebreak is only activated if it affects a line-box; the normalizer has no information about lineboxes and therefore cannot perform any pagebreak computation at all.

  Todo: Content that has been ignored because there was no 'content:contents' definition for it, should have this content moved into the '::alternate' pseudo-element. This one can be used to build footnotes and other fancy stuff.

  More todo: Quote-Level cannot be resolved, until the content has been processed by the renderer. The Quote-Tokens need to be passed down to the renderer unchanged; they need the defined quotes for the current element when being printed.

  The language is currently unresolved. It needs to be takes from the parent context or the xml:lang attribute. Resolving the language using stylesheets does not work, as there is a language-matching rule which depends on that value.

  Todo: DisplayNone does not remove the element from the document tree. Quote:

  The element is not rendered. The rendering is the same as if the element had been removed from the document tree, except for possible effects on counters (see [generated] or [paged]).

  [generated]: An element that is not displayed ('display' set to 'none') cannot increment or reset a counter.

  Note that :before and :after pseudo elements of this element are also not rendered, see [generated].)
  Author:
    Thomas Morgner

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class | Description
    --- | --- | ---
    `protected static class` | `ContentNormalizer.ContentNormalizerState` |

  - ### Constructor Summary

    Constructors
    Modifier | Constructor | Description
    --- | --- | ---
    `` | `ContentNormalizer​(LayoutProcess layoutProcess)` |
    `protected` | `ContentNormalizer​(LayoutProcess layoutProcess, boolean init)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `addText​(java.lang.String text)` | Adds text content to the current element.
    `protected ContentNormalizer.ContentNormalizerState` | `createSaveState​()` |
    `void` | `endDocument​()` | Ends the document.
    `void` | `endElement​()` | Ends the current element.
    `protected void` | `fillState​(ContentNormalizer.ContentNormalizerState state)` |
    `protected void` | `generateAfterPseudoElements​(LayoutElement element)` |
    `protected boolean` | `generateBeforePseudoElements​(LayoutElement element)` |
    `protected void` | `generateContentAfter​(LayoutElement element)` |
    `protected boolean` | `generateContentBefore​(LayoutElement element)` |
    `protected void` | `generateStrings​(LayoutElement element)` |
    `Renderer` | `getRenderer​()` | Returns the renderer.
    `StyleResolver` | `getStyleResolver​()` |
    `void` | `handlePageBreak​(CSSValue pageName, PseudoPage[] pseudoPages)` |
    `protected void` | `restore​(ContentNormalizer.ContentNormalizerState state)` |
    `State` | `saveState​()` |
    `void` | `startDocument​()` | Start document is the first call to the normalizer.
    `void` | `startElement​(java.lang.String namespace, java.lang.String tag, AttributeMap attributes)` | Starts a new element.
    `protected void` | `startElementInternal​(java.lang.String namespace, java.lang.String tag, java.lang.String pseudo, AttributeMap attributes)` |

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

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

- - ### Constructor Detail

    - #### ContentNormalizer

          public ContentNormalizer​(LayoutProcess layoutProcess)

    - #### ContentNormalizer

          protected ContentNormalizer​(LayoutProcess layoutProcess,
                                      boolean init)

  - ### Method Detail

    - #### startDocument

          public void startDocument​()
                             throws java.io.IOException,
                                    NormalizationException

      Description copied from interface: `Normalizer`
      Start document is the first call to the normalizer. At this point, all meta-data has been given and the document context is filled correctly. Starting the document also starts a new PageContext.
      Specified by:
        `startDocument` in interface `Normalizer`
      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### startElement

          public void startElement​(java.lang.String namespace,
                                   java.lang.String tag,
                                   AttributeMap attributes)
                            throws NormalizationException,
                                   java.io.IOException

      Starts a new element. The element uses the given namespace and tagname. The element's attributes are given as collection, each attribute is keyed with a namespace and attributename. The values contained in the attributes are not defined.
      Specified by:
        `startElement` in interface `Normalizer`
      Parameters:
        `namespace` -
        `tag` -
        `attributes` -
      Throws:
        `NormalizationException`
        `java.io.IOException`

    - #### startElementInternal

          protected void startElementInternal​(java.lang.String namespace,
                                              java.lang.String tag,
                                              java.lang.String pseudo,
                                              AttributeMap attributes)
                                       throws NormalizationException,
                                              java.io.IOException

      Throws:
        `NormalizationException`
        `java.io.IOException`

    - #### generateBeforePseudoElements

          protected boolean generateBeforePseudoElements​(LayoutElement element)
                                                  throws java.io.IOException,
                                                         NormalizationException

      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### generateContentBefore

          protected boolean generateContentBefore​(LayoutElement element)
                                           throws java.io.IOException,
                                                  NormalizationException

      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### generateContentAfter

          protected void generateContentAfter​(LayoutElement element)
                                       throws java.io.IOException,
                                              NormalizationException

      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### generateStrings

          protected void generateStrings​(LayoutElement element)
                                  throws java.io.IOException,
                                         NormalizationException

      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### generateAfterPseudoElements

          protected void generateAfterPseudoElements​(LayoutElement element)
                                              throws java.io.IOException,
                                                     NormalizationException

      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### addText

          public void addText​(java.lang.String text)
                       throws NormalizationException,
                              java.io.IOException

      Adds text content to the current element.
      Specified by:
        `addText` in interface `Normalizer`
      Parameters:
        `text` -
      Throws:
        `NormalizationException`
        `java.io.IOException`

    - #### endElement

          public void endElement​()
                          throws NormalizationException,
                                 java.io.IOException

      Ends the current element. The namespace and tagname are given for convienience.
      Specified by:
        `endElement` in interface `Normalizer`
      Throws:
        `NormalizationException`
        `java.io.IOException`

    - #### endDocument

          public void endDocument​()
                           throws java.io.IOException,
                                  NormalizationException

      Description copied from interface: `Normalizer`
      Ends the document. No other events will be fired against this normalizer once this method has been called.
      Specified by:
        `endDocument` in interface `Normalizer`
      Throws:
        `java.io.IOException`
        `NormalizationException`

    - #### handlePageBreak

          public void handlePageBreak​(CSSValue pageName,
                                      PseudoPage[] pseudoPages)

      Specified by:
        `handlePageBreak` in interface `Normalizer`

    - #### createSaveState

          protected ContentNormalizer.ContentNormalizerState createSaveState​()

    - #### fillState

          protected void fillState​(ContentNormalizer.ContentNormalizerState state)
                            throws StateException

      Throws:
        `StateException`

    - #### saveState

          public State saveState​()
                          throws StateException

      Specified by:
        `saveState` in interface `StatefullComponent`
      Throws:
        `StateException`

    - #### restore

          protected void restore​(ContentNormalizer.ContentNormalizerState state)
                          throws StateException

      Throws:
        `StateException`

    - #### getRenderer

          public Renderer getRenderer​()

      Returns the renderer. The renderer is the last step in the processing chain. The ModelBuilder and ContentGenerator steps are considered internal, as they may refeed the normalizer.
      Specified by:
        `getRenderer` in interface `Normalizer`
      Returns:
        the current renderer

    - #### getStyleResolver

          public StyleResolver getStyleResolver​()