Class AbstractTextDocument
java.lang.Object
com.pnfsoftware.jeb.util.events.EventSource
com.pnfsoftware.jeb.core.output.text.impl.AbstractTextDocument
- All Implemented Interfaces:
IGenericDocument
,ITextDocument
,IEventSource
- Direct Known Subclasses:
AsciiDocument
,CodeDocument
,HexDumpDocument
,StaticTextDocument
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"
-
Field Summary
Fields inherited from class com.pnfsoftware.jeb.util.events.EventSource
onEventCallCount
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal ICoordinates
addressToCoordinates
(String address) Convert a unit-specific address to document-specific text coordinates.addressToCoordinates
(String address, CoordinatesConversionPrecision precision) Precision is not used - Use an exact addressfinal String
coordinatesToAddress
(ICoordinates coordinates) Convert document-specific text coordinates to a unit-specific address using a default conversion precision.coordinatesToAddress
(ICoordinates coordinates, AddressConversionPrecision precision) Convert document-specific text coordinates to a unit-specific address.void
dispose()
The default implementation does nothing.format()
Format this text document.getDocumentPart
(long anchorId, int linesAfter) Retrieve a document part.getDocumentPart2
(long anchorBegin, long anchorEnd) The default implementation throws.long
The default implementation returns 0.long
The default implementation returns the first anchor as the initial anchor.The default implementation returns null.toString()
protected boolean
Specify ifcoordinatesToAddress(ICoordinates, AddressConversionPrecision)
andaddressToCoordinates(String, CoordinatesConversionPrecision)
will use the anchor inner value or should display as a text editor (where first line is line 1).protected boolean
Specify ifcoordinatesToAddress(ICoordinates, AddressConversionPrecision)
andaddressToCoordinates(String, CoordinatesConversionPrecision)
will use the line Delta.Methods inherited from class com.pnfsoftware.jeb.util.events.EventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, notifyListeners, notifyListeners, relay, removeListener, setParentSource
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSource
Methods inherited from interface com.pnfsoftware.jeb.core.output.IGenericDocument
getUnit
Methods inherited from interface com.pnfsoftware.jeb.core.output.text.ITextDocument
getAnchorCount, getBinaryRepresentation, getDocumentPart, hasBinaryRepresentation
-
Constructor Details
-
AbstractTextDocument
public AbstractTextDocument()
-
-
Method Details
-
dispose
public void dispose()The default implementation does nothing.- Specified by:
dispose
in interfaceIGenericDocument
-
getPropertyManager
The default implementation returns null.- Specified by:
getPropertyManager
in interfaceIGenericDocument
- Returns:
- a PM, null if none
-
getInitialAnchor
public long getInitialAnchor()The default implementation returns the first anchor as the initial anchor.- Specified by:
getInitialAnchor
in interfaceITextDocument
- Returns:
- an integer, 0 if not specified
-
getFirstAnchor
public long getFirstAnchor()The default implementation returns 0.- Specified by:
getFirstAnchor
in interfaceITextDocument
- Returns:
- an integer greater or equal than zero
-
getDocumentPart
Description copied from interface:ITextDocument
Retrieve a document part. Equivalent togetDocumentPart(anchorId, linesAfter)
.- Specified by:
getDocumentPart
in interfaceITextDocument
- Parameters:
anchorId
- the anchor idlinesAfter
- number of lines after- Returns:
- the document part
-
getDocumentPart2
public ITextDocumentPart getDocumentPart2(long anchorBegin, long anchorEnd) throws NotImplementedException The default implementation throws.- Specified by:
getDocumentPart2
in interfaceITextDocument
- Parameters:
anchorBegin
- start anchor, inclusiveanchorEnd
- final anchor, exclusive- Returns:
- the document part
- Throws:
NotImplementedException
- implementations should throw if this method is not implemented
-
useLineDelta
protected boolean useLineDelta()Specify ifcoordinatesToAddress(ICoordinates, AddressConversionPrecision)
andaddressToCoordinates(String, CoordinatesConversionPrecision)
will use the line Delta. Default is true, but implementations can decide to use only one line for an anchor.- Returns:
-
useDisplayLineNumber
protected boolean useDisplayLineNumber()Specify ifcoordinatesToAddress(ICoordinates, AddressConversionPrecision)
andaddressToCoordinates(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. -
coordinatesToAddress
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 interfaceITextDocument
- Parameters:
coordinates
- the coordinates- Returns:
- the address, null on error
-
coordinatesToAddress
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 interfaceITextDocument
- Parameters:
coordinates
- the coordinatesprecision
- indicate the precision of the address (AddressConversionPrecision.COARSE
will return a raw address, with a faster result whileAddressConversionPrecision.FINE
will return a more precise address that can be a bit longer). IfAddressConversionPrecision.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
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 interfaceITextDocument
- Parameters:
address
- a textual address- Returns:
- the text coordinates, null on error
-
addressToCoordinates
Precision is not used - Use an exact address- Specified by:
addressToCoordinates
in interfaceITextDocument
- Parameters:
address
- a textual address- Returns:
- the text coordinates, null on error
-
toString
-
format
Description copied from interface:ITextDocument
Format this text document.- Specified by:
format
in interfaceITextDocument
- Returns:
-