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
Known Indirect 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

[Expand]
Inherited Fields
From class com.pnfsoftware.jeb.util.events.EventSource
Public Constructors
AbstractTextDocument()
Public Methods
final ICoordinates addressToCoordinates(String address)
Convert a unit-specific address to document-specific text coordinates.
ICoordinates addressToCoordinates(String address, CoordinatesConversionPrecision precision)
Precision is not used - Use an exact address
final String coordinatesToAddress(ICoordinates coordinates)
Convert document-specific text coordinates to a unit-specific address using a default conversion precision.
String coordinatesToAddress(ICoordinates coordinates, AddressConversionPrecision precision)
Convert document-specific text coordinates to a unit-specific address.
void dispose()
The default implementation does nothing.
String format()
Format this text document.
ITextDocumentPart getDocumentPart(long anchorId, int linesAfter)
Retrieve a document part.
ITextDocumentPart getDocumentPart2(long anchorBegin, long anchorEnd)
The default implementation throws.
long getFirstAnchor()
The default implementation returns 0.
long getInitialAnchor()
The default implementation returns the first anchor as the initial anchor.
IPropertyManager getPropertyManager()
The default implementation returns null.
String toString()
Protected Methods
boolean useDisplayLineNumber()
Specify if coordinatesToAddress(ICoordinates, AddressConversionPrecision) and addressToCoordinates(String, CoordinatesConversionPrecision) will use the anchor inner value or should display as a text editor (where first line is line 1).
boolean useLineDelta()
[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 final 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 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.

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

public ICoordinates addressToCoordinates (String address, CoordinatesConversionPrecision precision)

Precision is not used - Use an exact address

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

public final String coordinatesToAddress (ICoordinates coordinates)

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.

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

public String coordinatesToAddress (ICoordinates coordinates, AddressConversionPrecision precision)

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
precision indicate the precision of the address ( COARSE will return a raw address, with a faster result while FINE will return a more precise address that can be a bit longer). If 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

public void dispose ()

The default implementation does nothing.

public String format ()

Format this text document.

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 ITextDocumentPart getDocumentPart2 (long anchorBegin, long anchorEnd)

The default implementation throws.

Parameters
anchorBegin start anchor, inclusive
anchorEnd final anchor, exclusive
Returns
  • the document part

public long getFirstAnchor ()

The default implementation returns 0.

Returns
  • an integer greater or equal than zero

public long getInitialAnchor ()

The default implementation returns the first anchor as the initial anchor.

Returns
  • an integer, 0 if not specified

public IPropertyManager getPropertyManager ()

The default implementation returns null.

Returns
  • a PM, null if none

public String toString ()

Protected Methods

protected boolean useDisplayLineNumber ()

Specify if coordinatesToAddress(ICoordinates, AddressConversionPrecision) and addressToCoordinates(String, CoordinatesConversionPrecision) will use the anchor inner value or should display as a text editor (where first line is line 1). Line Delta and column offset are not modified.

protected boolean useLineDelta ()

Specify if coordinatesToAddress(ICoordinates, AddressConversionPrecision) and addressToCoordinates(String, CoordinatesConversionPrecision) will use the line Delta. Default is true, but implementations can decide to use only one line for an anchor.