Class AbstractTextPartAsDocumentProxy
- All Implemented Interfaces:
IGenericDocument,ITextDocument,IEventSource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(IEventListener listener) Register a listener.addressToCoordinates(String address) Convert a unit-specific address to document-specific text coordinates.addressToCoordinates(String address, CoordinatesConversionPrecision precision) Convert a unit-specific address to document-specific text coordinates.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.intGet the numbers of objects listening to this event source.voiddispose()Dispose of resources and handles used by this document.format()Format this text document.longGet the range of anchor points in the document.getDocumentPart(long anchorId, int linesAfter) Retrieve a document part.getDocumentPart(long anchorId, int linesAfter, int linesBefore) Retrieve a document part.getDocumentPart2(long anchorBegin, long anchorEnd) Retrieve the document part located between two anchor references.longGet the first anchor identifier of the document.Retrieve the full (provider) document.longGet the anchor identifier that would represent the first logical section of a document (meaning the anchor to focus on when opening a document).List<? extends IEventListener>Get a copy of the list of listeners.Get the parent source.protected abstract ITextDocumentPartProvide the part to be viewed as whole document.Provide the optional property manager to customize rendering of the document.getUnit()If available, retrieve the unit that backs up this document.voidinsertListener(int index, IEventListener listener) Register a listener.voidNotify listeners that an event has occurred.voidremoveListener(IEventListener listener) Unregister a listener.voidsetParentSource(IEventSource parentSource) Set a parent source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.pnfsoftware.jeb.core.output.text.ITextDocument
getBinaryRepresentation, hasBinaryRepresentation
-
Constructor Details
-
AbstractTextPartAsDocumentProxy
Create a proxy object.- Parameters:
idoc- the full document.
-
-
Method Details
-
getFullDocument
Retrieve the full (provider) document.- Returns:
-
getPartAsDocument
Provide the part to be viewed as whole document.- Returns:
- a part
-
dispose
public void dispose()Description copied from interface:IGenericDocumentDispose of resources and handles used by this document. The object creator should call this method upon destruction.- Specified by:
disposein interfaceIGenericDocument
-
getUnit
Description copied from interface:IGenericDocumentIf available, retrieve the unit that backs up this document.- Specified by:
getUnitin interfaceIGenericDocument- Returns:
- an optional unit reference (may be null)
-
getPropertyManager
Description copied from interface:IGenericDocumentProvide 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:
getPropertyManagerin interfaceIGenericDocument- Returns:
- a PM, null if none
-
getInitialAnchor
public long getInitialAnchor()Description copied from interface:ITextDocumentGet 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:
getInitialAnchorin interfaceITextDocument- Returns:
- an integer, 0 if not specified
-
getFirstAnchor
public long getFirstAnchor()Description copied from interface:ITextDocumentGet the first anchor identifier of the document. Most document will want to have 0 as their first anchor identifier.- Specified by:
getFirstAnchorin interfaceITextDocument- Returns:
- an integer greater or equal than zero
-
getAnchorCount
public long getAnchorCount()Description copied from interface:ITextDocumentGet 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:
getAnchorCountin interfaceITextDocument- Returns:
- the count/range of anchors in this document, must be greater 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
-
getDocumentPart
Description copied from interface:ITextDocumentRetrieve 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:
getDocumentPartin interfaceITextDocument- Parameters:
anchorId- the anchor identifierlinesAfter- hint lines count to return after the given anchor, could be more or lesslinesBefore- 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:ITextDocumentRetrieve the document part located between two anchor references. This method is optional.- 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
-
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
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
-
format
Description copied from interface:ITextDocumentFormat this text document.- Specified by:
formatin interfaceITextDocument- Returns:
-
setParentSource
Description copied from interface:IEventSourceSet a parent source.- Specified by:
setParentSourcein interfaceIEventSource- Parameters:
parentSource- the optional parent source
-
getParentSource
Description copied from interface:IEventSourceGet the parent source.- Specified by:
getParentSourcein interfaceIEventSource- Returns:
- the parent source, or null if none
-
countListeners
public int countListeners()Description copied from interface:IEventSourceGet the numbers of objects listening to this event source.- Specified by:
countListenersin interfaceIEventSource- Returns:
- the number of listeners
-
getListeners
Description copied from interface:IEventSourceGet a copy of the list of listeners.- Specified by:
getListenersin interfaceIEventSource- Returns:
-
addListener
Description copied from interface:IEventSourceRegister a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.- Specified by:
addListenerin interfaceIEventSource- Parameters:
listener- a listener of events generated by this source
-
insertListener
Description copied from interface:IEventSourceRegister a listener. The implementor may allow duplicates.- Specified by:
insertListenerin interfaceIEventSource- Parameters:
index- insertion pointlistener- a listener of events generated by this source
-
removeListener
Description copied from interface:IEventSourceUnregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.- Specified by:
removeListenerin interfaceIEventSource- Parameters:
listener- the listener to be removed
-
notifyListeners
Description copied from interface:IEventSourceNotify listeners that an event has occurred.- Specified by:
notifyListenersin interfaceIEventSource- Parameters:
e- the event to be propagated
-