Class AbstractTextPartAsDocumentProxy

java.lang.Object
com.pnfsoftware.jeb.core.output.text.impl.AbstractTextPartAsDocumentProxy
All Implemented Interfaces:
IGenericDocument, ITextDocument, IEventSource

public abstract class AbstractTextPartAsDocumentProxy extends Object implements ITextDocument
This utility class allows clients to view a part of a document as a virtual, whole document.
  • Constructor Details

    • AbstractTextPartAsDocumentProxy

      public AbstractTextPartAsDocumentProxy(ITextDocument idoc)
      Create a proxy object.
      Parameters:
      idoc - the full document.
  • Method Details

    • getFullDocument

      public ITextDocument getFullDocument()
      Retrieve the full (provider) document.
      Returns:
    • getPartAsDocument

      protected abstract ITextDocumentPart getPartAsDocument()
      Provide the part to be viewed as whole document.
      Returns:
      a part
    • dispose

      public void dispose()
      Description copied from interface: IGenericDocument
      Dispose of resources and handles used by this document. The object creator should call this method upon destruction.
      Specified by:
      dispose in interface IGenericDocument
    • getUnit

      public IUnit getUnit()
      Description copied from interface: IGenericDocument
      If available, retrieve the unit that backs up this document.
      Specified by:
      getUnit in interface IGenericDocument
      Returns:
      an optional unit reference (may be null)
    • getPropertyManager

      public IPropertyManager getPropertyManager()
      Description copied from interface: IGenericDocument
      Provide the optional property manager to customize rendering of the document. Available properties can be retrieved by retrieving the PDM provided by the property manager.
      Specified by:
      getPropertyManager in interface IGenericDocument
      Returns:
      a PM, null if none
    • getInitialAnchor

      public long getInitialAnchor()
      Description copied from interface: ITextDocument
      Get the anchor identifier that would represent the first logical section of a document (meaning the anchor to focus on when opening a document). If not specified, the first anchor is considered to be the initial anchor.
      Specified by:
      getInitialAnchor in interface ITextDocument
      Returns:
      an integer, 0 if not specified
    • getFirstAnchor

      public long getFirstAnchor()
      Description copied from interface: ITextDocument
      Get the first anchor identifier of the document. Most document will want to have 0 as their first anchor identifier.
      Specified by:
      getFirstAnchor in interface ITextDocument
      Returns:
      an integer greater or equal than zero
    • getAnchorCount

      public long getAnchorCount()
      Description copied from interface: ITextDocument
      Get the range of anchor points in the document. Returning 1 means that the document returns a single part, holding the entire contents.

      Note that the anchor at "ITextDocument.getFirstAnchor() + ITextDocument.getAnchorCount()" is the "end" anchor (one after the last), and lies outside the document. It is not a valid anchor.

      Specified by:
      getAnchorCount in interface ITextDocument
      Returns:
      the count/range of anchors in this document, must be greater than zero
    • getDocumentPart

      public ITextDocumentPart getDocumentPart(long anchorId, int linesAfter)
      Description copied from interface: ITextDocument
      Retrieve a document part. Equivalent to getDocumentPart(anchorId, linesAfter) .
      Specified by:
      getDocumentPart in interface ITextDocument
      Parameters:
      anchorId - the anchor id
      linesAfter - number of lines after
      Returns:
      the document part
    • getDocumentPart

      public ITextDocumentPart getDocumentPart(long anchorId, int linesAfter, int linesBefore)
      Description copied from interface: ITextDocument
      Retrieve a document part. Clients call this method to retrieve a document part starting at a specific anchor, and containing the given amount of lines after and before the anchor. It is the responsibility of the implementor to sanitize the input (eg, negative number of lines, invalid anchor, etc.) and provide appropriate response (eg, truncating). It is recommended that implementors try not to raise an exception on error. In the worst case scenario, an empty document can be returned.
      Specified by:
      getDocumentPart in interface ITextDocument
      Parameters:
      anchorId - the anchor identifier
      linesAfter - hint lines count to return after the given anchor, could be more or less
      linesBefore - hint lines count to return before the given anchor, could be more or less
      Returns:
      a document part containing as many anchors as required to honor the client requests. If linesAfter is non-null, the first anchor within the document part may not be anchorId, but one anchor before that. THis method should return null if an invalid anchor was provided
    • getDocumentPart2

      public ITextDocumentPart getDocumentPart2(long anchorBegin, long anchorEnd) throws NotImplementedException
      Description copied from interface: ITextDocument
      Retrieve the document part located between two anchor references. This method is optional.
      Specified by:
      getDocumentPart2 in interface ITextDocument
      Parameters:
      anchorBegin - start anchor, inclusive
      anchorEnd - final anchor, exclusive
      Returns:
      the document part
      Throws:
      NotImplementedException - implementations should throw if this method is not implemented
    • coordinatesToAddress

      public String coordinatesToAddress(ICoordinates coordinates)
      Description copied from interface: ITextDocument
      Convert document-specific text coordinates to a unit-specific address using a default conversion precision.

      Note: The addressing scheme is unit specific, and defined by the plugin developer. Addresses should not start with the reserved '@' prefix.

      Specified by:
      coordinatesToAddress in interface ITextDocument
      Parameters:
      coordinates - the coordinates
      Returns:
      the address, null on error
    • coordinatesToAddress

      public String coordinatesToAddress(ICoordinates coordinates, AddressConversionPrecision precision)
      Description copied from interface: ITextDocument
      Convert document-specific text coordinates to a unit-specific address.

      Note: The addressing scheme is unit specific, and defined by the plugin developer. Addresses should not start with the reserved '@' prefix.

      Specified by:
      coordinatesToAddress in interface ITextDocument
      Parameters:
      coordinates - the coordinates
      precision - indicate the precision of the address ( AddressConversionPrecision.COARSE will return a raw address, with a faster result while AddressConversionPrecision.FINE will return a more precise address that can be a bit longer). If AddressConversionPrecision.COARSE can not be retrieved, it may return a null result, and the user will need to recall this method with another precision.
      Returns:
      the address, null on error
    • addressToCoordinates

      public ICoordinates addressToCoordinates(String address)
      Description copied from interface: ITextDocument
      Convert a unit-specific address to document-specific text coordinates. It is recommended to return canonical coordinates. The implementation might return approximate coordinates, ie the closest coordinates (in terms of distance) calculated as part of a best effort approach to minimize the return of null values.

      Note: The addressing scheme is unit specific, and defined by the plugin developer. Addresses should not start with the reserved '@' prefix.

      Specified by:
      addressToCoordinates in interface ITextDocument
      Parameters:
      address - a textual address
      Returns:
      the text coordinates, null on error
    • addressToCoordinates

      public ICoordinates addressToCoordinates(String address, CoordinatesConversionPrecision precision)
      Description copied from interface: ITextDocument
      Convert a unit-specific address to document-specific text coordinates. It is recommended to return canonical coordinates. The implementation might return approximate coordinates, ie the closest coordinates (in terms of distance) calculated as part of a best effort approach to minimize the return of null values.

      Note: The addressing scheme is unit specific, and defined by the plugin developer. Addresses should not start with the reserved '@' prefix.

      Specified by:
      addressToCoordinates in interface ITextDocument
      Parameters:
      address - a textual address
      Returns:
      the text coordinates, null on error
    • format

      public String format()
      Description copied from interface: ITextDocument
      Format this text document.
      Specified by:
      format in interface ITextDocument
      Returns:
    • setParentSource

      public void setParentSource(IEventSource parentSource)
      Description copied from interface: IEventSource
      Set a parent source.
      Specified by:
      setParentSource in interface IEventSource
      Parameters:
      parentSource - the optional parent source
    • getParentSource

      public IEventSource getParentSource()
      Description copied from interface: IEventSource
      Get the parent source.
      Specified by:
      getParentSource in interface IEventSource
      Returns:
      the parent source, or null if none
    • countListeners

      public int countListeners()
      Description copied from interface: IEventSource
      Get the numbers of objects listening to this event source.
      Specified by:
      countListeners in interface IEventSource
      Returns:
      the number of listeners
    • getListeners

      public List<? extends IEventListener> getListeners()
      Description copied from interface: IEventSource
      Get a copy of the list of listeners.
      Specified by:
      getListeners in interface IEventSource
      Returns:
    • addListener

      public void addListener(IEventListener listener)
      Description copied from interface: IEventSource
      Register a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.
      Specified by:
      addListener in interface IEventSource
      Parameters:
      listener - a listener of events generated by this source
    • insertListener

      public void insertListener(int index, IEventListener listener)
      Description copied from interface: IEventSource
      Register a listener. The implementor may allow duplicates.
      Specified by:
      insertListener in interface IEventSource
      Parameters:
      index - insertion point
      listener - a listener of events generated by this source
    • removeListener

      public void removeListener(IEventListener listener)
      Description copied from interface: IEventSource
      Unregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.
      Specified by:
      removeListener in interface IEventSource
      Parameters:
      listener - the listener to be removed
    • notifyListeners

      public void notifyListeners(IEvent e)
      Description copied from interface: IEventSource
      Notify listeners that an event has occurred.
      Specified by:
      notifyListeners in interface IEventSource
      Parameters:
      e - the event to be propagated