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 ICoordinatesaddressToCoordinates(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 StringcoordinatesToAddress(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.voiddispose()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.longThe default implementation returns 0.longThe default implementation returns the first anchor as the initial anchor.The default implementation returns null.toString()protected booleanSpecify 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 booleanSpecify 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, setParentSourceMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.util.events.IEventSource
addListener, countListeners, getListeners, getParentSource, insertListener, notifyListeners, removeListener, setParentSourceMethods inherited from interface com.pnfsoftware.jeb.core.output.IGenericDocument
getUnitMethods 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:
disposein interfaceIGenericDocument
-
getPropertyManager
The default implementation returns null.- Specified by:
getPropertyManagerin interfaceIGenericDocument- Returns:
- a PM, null if none
-
getInitialAnchor
public long getInitialAnchor()The default implementation returns the first anchor as the initial anchor.- Specified by:
getInitialAnchorin interfaceITextDocument- Returns:
- an integer, 0 if not specified
-
getFirstAnchor
public long getFirstAnchor()The default implementation returns 0.- Specified by:
getFirstAnchorin interfaceITextDocument- Returns:
- an integer greater or equal than zero
-
getDocumentPart
Description copied from interface:ITextDocumentRetrieve a document part. Equivalent togetDocumentPart(anchorId, linesAfter).- Specified by:
getDocumentPartin 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:
getDocumentPart2in 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:ITextDocumentConvert 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:
coordinatesToAddressin interfaceITextDocument- Parameters:
coordinates- the coordinates- Returns:
- the address, null on error
-
coordinatesToAddress
Description copied from interface:ITextDocumentConvert 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:
coordinatesToAddressin interfaceITextDocument- Parameters:
coordinates- the coordinatesprecision- indicate the precision of the address (AddressConversionPrecision.COARSEwill return a raw address, with a faster result whileAddressConversionPrecision.FINEwill return a more precise address that can be a bit longer). IfAddressConversionPrecision.COARSEcan 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:ITextDocumentConvert 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:
addressToCoordinatesin interfaceITextDocument- Parameters:
address- a textual address- Returns:
- the text coordinates, null on error
-
addressToCoordinates
Precision is not used - Use an exact address- Specified by:
addressToCoordinatesin interfaceITextDocument- Parameters:
address- a textual address- Returns:
- the text coordinates, null on error
-
toString
-
format
Description copied from interface:ITextDocumentFormat this text document.- Specified by:
formatin interfaceITextDocument- Returns:
-