Interface IUnitFormatter

All Known Implementing Classes:
UnitFormatterAdapter

@Ser public interface IUnitFormatter
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 Details

    • getPresentationCount

      int getPresentationCount()
      Get the number of document presentations contained in this formatter.
      Returns:
      the number of presentations
    • getPresentation

      IUnitDocumentPresentation getPresentation(int index)
      Retrieve a presentation.
      Parameters:
      index - presentation index
      Returns:
      the presentation or null
    • addPresentation

      void addPresentation(IUnitDocumentPresentation presentation, boolean persisted)
      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 presentation
      persisted - true to persist the presentation, false otherwise; if true, the presentation must be serializable
    • insertPresentation

      void insertPresentation(int index, IUnitDocumentPresentation presentation, boolean persisted)
      Insert a presentation at the given index. If the presentation already exists in this formatter, this method will silently fail.
      Parameters:
      index - insertion index
      presentation - the presentation
      persisted - true to persist the presentation, false otherwise; if true, the presentation must be serializable
    • 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 as persisted.