Package com.pnfsoftware.jeb.core.output
Interface IUnitFormatter
- All Known Implementing Classes:
UnitFormatterAdapter
A unit formatter is used to retrieve presentations of a unit. A
unit
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
events.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addPresentation
(IUnitDocumentPresentation presentation, boolean persisted) Add a presentation.void
Discard all presentations not marked aspersisted
.getPresentation
(int index) Retrieve a presentation.int
Get the number of document presentations contained in this formatter.Retrieve a list of all (persisted and transient) document presentations.void
insertPresentation
(int index, IUnitDocumentPresentation presentation, boolean persisted) Insert a presentation at the given index.boolean
isPersisted
(int index) Determine whether or not a presentation is to be persisted upon serialization.void
removePresentation
(int index) Remove a presentation.
-
Method Details
-
getPresentationCount
int getPresentationCount()Get the number of document presentations contained in this formatter.- Returns:
- the number of presentations
-
getPresentation
Retrieve a presentation.- Parameters:
index
- presentation index- Returns:
- the presentation or null
-
addPresentation
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.- Parameters:
presentation
- the presentationpersisted
- true to persist the presentation, false otherwise; if true, the presentation must beserializable
-
insertPresentation
Insert a presentation at the given index. If the presentation already exists in this formatter, this method will silently fail.- Parameters:
index
- insertion indexpresentation
- the presentationpersisted
- true to persist the presentation, false otherwise; if true, the presentation must beserializable
-
removePresentation
void removePresentation(int index) Remove a presentation.- Parameters:
index
- presentation index
-
isPersisted
boolean isPersisted(int index) Determine whether or not a presentation is to be persisted upon serialization.- Parameters:
index
- presentation index- Returns:
- persistence indicator
-
getPresentations
List<IUnitDocumentPresentation> getPresentations()Retrieve a list of all (persisted and transient) document presentations. This list is a copy; any attempt to modify it will raise an exception.- Returns:
- a list of document presentations, possibly empty
-
discardTransientPresentations
void discardTransientPresentations()Discard all presentations not marked aspersisted
.
-