public abstract class

AbstractTextDocument

extends EventSource
implements ITextDocument
java.lang.Object
   ↳ com.pnfsoftware.jeb.util.events.EventSource
     ↳ com.pnfsoftware.jeb.core.output.text.impl.AbstractTextDocument
Known Direct Subclasses

Class Overview

A skeleton implementation of a text document. In order to minimize code breakage on API changes, it is recommended plugins extend this class instead of implements ITextDocument from scratch.

The first anchor is 0. By default, the addressing scheme mirrors document coordinates:

 coordinates: (anchor, line, column) <-> address: "a,y,x"
 

Summary

Public Constructors
AbstractTextDocument()
Public Methods
ICoordinates addressToCoordinates(String address)
Convert a unit-specific address to document-specific text coordinates.
String coordinatesToAddress(ICoordinates coordinates)
Convert document-specific text coordinates to a unit-specific address.
void dispose()
Dispose of resources and handles used by this document.
ITextDocumentPart getDocumentPart(long anchorId, int linesAfter)
Retrieve a document part.
long getFirstAnchor()
Get the first anchor identifier of the document.
long getInitialAnchor()
Get the anchor identifier that would represent the first logical section of a document.
String toString()
[Expand]
Inherited Methods
From class com.pnfsoftware.jeb.util.events.EventSource
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.output.IGenericDocument
From interface com.pnfsoftware.jeb.core.output.text.ITextDocument
From interface com.pnfsoftware.jeb.util.events.IEventSource

Public Constructors

public AbstractTextDocument ()

Public Methods

public ICoordinates addressToCoordinates (String address)

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 minimizing 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.

Parameters
address a textual address
Returns
  • the text coordinates, null on error

public String coordinatesToAddress (ICoordinates coordinates)

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.

Parameters
coordinates the coordinates
Returns
  • the address, null on error

public void dispose ()

Dispose of resources and handles used by this document. The object creator should call this method upon destruction.

public ITextDocumentPart getDocumentPart (long anchorId, int linesAfter)

Retrieve a document part. Equivalent to getDocumentPart(anchorId, linesAfter) .

Parameters
anchorId the anchor id
linesAfter number of lines after
Returns
  • the document part

public long getFirstAnchor ()

Get the first anchor identifier of the document. Most document will want to have 0 as their first anchor identifier.

Returns
  • an integer greater or equal than zero

public long getInitialAnchor ()

Get the anchor identifier that would represent the first logical section of a document. If not specified, the first anchor is considered to be the initial anchor.

Returns
  • an integer, 0 if not specified

public String toString ()