### org.jfree.layouting.normalizer.content

# Class ContentNormalizer

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

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

  `protected static class`

  `ContentNormalizer.ContentNormalizerState`

  ## Constructor Summary

  `ContentNormalizer(LayoutProcess layoutProcess)`

  `ContentNormalizer(LayoutProcess layoutProcess, boolean init)`

  ## Method Summary

  `void`

  `addText(String text)`
    Adds text content to the current element.

  `protected ContentNormalizer.ContentNormalizerState`

  `createSaveState()`

  `void`

  `endDocument()`

  `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()`

  `void`

  `startElement(String namespace, String tag, AttributeMap attributes)`
    Starts a new element.

  `protected void`

  `startElementInternal(String namespace, String tag, String pseudo, AttributeMap attributes)`

## Constructor Details

### ContentNormalizer

    public ContentNormalizer(LayoutProcess layoutProcess)

### ContentNormalizer

    protected ContentNormalizer(LayoutProcess layoutProcess,
                                boolean init)

## Method Details

### addText

    public void addText(String text)
                throws NormalizationException,
                       IOException

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

### createSaveState

    protected ContentNormalizer.ContentNormalizerState createSaveState()

### endDocument

    public void endDocument()
                throws IOException,
                       NormalizationException

> Specified by:
>   endDocument in interface Normalizer

### endElement

    public void endElement()
                throws NormalizationException,
                       IOException

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

### fillState

    protected void fillState(ContentNormalizer.ContentNormalizerState state)
                throws StateException

### generateAfterPseudoElements

    protected void generateAfterPseudoElements(LayoutElement element)
                throws IOException,
                       NormalizationException

### generateBeforePseudoElements

    protected boolean generateBeforePseudoElements(LayoutElement element)
                throws IOException,
                       NormalizationException

### generateContentAfter

    protected void generateContentAfter(LayoutElement element)
                throws IOException,
                       NormalizationException

### generateContentBefore

    protected boolean generateContentBefore(LayoutElement element)
                throws IOException,
                       NormalizationException

### generateStrings

    protected void generateStrings(LayoutElement element)
                throws IOException,
                       NormalizationException

### 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()

### handlePageBreak

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

> Specified by:
>   handlePageBreak in interface Normalizer

### restore

    protected void restore(ContentNormalizer.ContentNormalizerState state)
                throws StateException

### saveState

    public State saveState()
                throws StateException

> Specified by:
>   saveState in interface StatefullComponent

### startDocument

    public void startDocument()
                throws IOException,
                       NormalizationException

> Specified by:
>   startDocument in interface Normalizer

### startElement

    public void startElement(String namespace,
                             String tag,
                             AttributeMap attributes)
                throws NormalizationException,
                       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` -

### startElementInternal

    protected void startElementInternal(String namespace,
                                        String tag,
                                        String pseudo,
                                        AttributeMap attributes)
                throws NormalizationException,
                       IOException