# Interface: com.pnfsoftware.jeb.core.output.IUnitFormatter

A unit formatter is used to retrieve presentations of a unit. A [unit](IUnit) is responsible for providing 0 or more document presentations, which can then be displayed by clients. Presentations held by the formatter are of two types: **transient** and **persisted**. Persisted presentations are serialized upon saving; care should be exercised to make sure that persisted documents do not contain references to transient documents. 
 
- Transient presentations: primary use is to hold dynamically\-generated or internal documents generated by a unit at runtime. Most presentations fall into this category.
-  
- Persisted presentations: primary use is to hold documents generated by clients at runtime. Example: generation and addition of presentations by a plugin or script.
-  

 

 Adding and removing presentations is allowed. It is the responsibility of the client code to notify of such changes by issuing [J#UnitChange](J#UnitChange) events.

## Method: addPresentation
- parameter: `presentation`, type: `com.pnfsoftware.jeb.core.output.IUnitDocumentPresentation`
- parameter: `persisted`, type: `boolean`

Description: Add a presentation. The presentation will be appended to the list of existing presentations. If the presentation already exists in this formatter, this method will silently fail.
parameter: presentation: the presentation
parameter: persisted: true to persist the presentation, false otherwise; if true, the presentation            must be [serializable](Ser)

## Method: discardTransientPresentations

Description: Discard all presentations not marked as [persisted](#isPersisted(int)).

## Method: getPresentation
- parameter: `index`, type: `int`
- return type: `com.pnfsoftware.jeb.core.output.IUnitDocumentPresentation`

Description: Retrieve a presentation.
parameter: index: presentation index
return: the presentation or null

## Method: getPresentationCount
- return type: `int`

Description: Get the number of document presentations contained in this formatter.
return: the number of presentations

## Method: getPresentations
- return type: `java.util.List<com.pnfsoftware.jeb.core.output.IUnitDocumentPresentation>`

Description: Retrieve a list of all \(persisted and transient\) document presentations. This list is a copy; any attempt to modify it will raise an exception.
return: a list of document presentations, possibly empty

## Method: insertPresentation
- parameter: `index`, type: `int`
- parameter: `presentation`, type: `com.pnfsoftware.jeb.core.output.IUnitDocumentPresentation`
- parameter: `persisted`, type: `boolean`

Description: Insert a presentation at the given index. If the presentation already exists in this formatter, this method will silently fail.
parameter: index: insertion index
parameter: presentation: the presentation
parameter: persisted: true to persist the presentation, false otherwise; if true, the presentation            must be [serializable](Ser)

## Method: isPersisted
- parameter: `index`, type: `int`
- return type: `boolean`

Description: Determine whether or not a presentation is to be persisted upon serialization.
parameter: index: presentation index
return: persistence indicator

## Method: removePresentation
- parameter: `index`, type: `int`

Description: Remove a presentation.
parameter: index: presentation index

