Class AbstractTextPartAsDocumentProxy
- All Implemented Interfaces:
IGenericDocument
,ITextDocument
,IEventSource
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
addListener
(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.int
Get the numbers of objects listening to this event source.void
dispose()
Dispose of resources and handles used by this document.format()
Format this text document.long
Get 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.long
Get the first anchor identifier of the document.Retrieve the full (provider) document.long
Get 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 ITextDocumentPart
Provide 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.void
insertListener
(int index, IEventListener listener) Register a listener.void
Notify listeners that an event has occurred.void
removeListener
(IEventListener listener) Unregister a listener.void
setParentSource
(IEventSource parentSource) Set a parent source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:IGenericDocument
Dispose of resources and handles used by this document. The object creator should call this method upon destruction.- Specified by:
dispose
in interfaceIGenericDocument
-
getUnit
Description copied from interface:IGenericDocument
If available, retrieve the unit that backs up this document.- Specified by:
getUnit
in interfaceIGenericDocument
- Returns:
- an optional unit reference (may be null)
-
getPropertyManager
Description copied from interface:IGenericDocument
Provide 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:
getPropertyManager
in interfaceIGenericDocument
- Returns:
- a PM, null if none
-
getInitialAnchor
public long getInitialAnchor()Description copied from interface:ITextDocument
Get 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:
getInitialAnchor
in interfaceITextDocument
- Returns:
- an integer, 0 if not specified
-
getFirstAnchor
public long getFirstAnchor()Description copied from interface:ITextDocument
Get the first anchor identifier of the document. Most document will want to have 0 as their first anchor identifier.- Specified by:
getFirstAnchor
in interfaceITextDocument
- Returns:
- an integer greater or equal than zero
-
getAnchorCount
public long getAnchorCount()Description copied from interface:ITextDocument
Get 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:
getAnchorCount
in interfaceITextDocument
- Returns:
- the count/range of anchors in this document, must be greater 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
-
getDocumentPart
Description copied from interface:ITextDocument
Retrieve 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:
getDocumentPart
in 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:ITextDocument
Retrieve the document part located between two anchor references. This method is optional.- 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
-
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
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
-
format
Description copied from interface:ITextDocument
Format this text document.- Specified by:
format
in interfaceITextDocument
- Returns:
-
setParentSource
Description copied from interface:IEventSource
Set a parent source.- Specified by:
setParentSource
in interfaceIEventSource
- Parameters:
parentSource
- the optional parent source
-
getParentSource
Description copied from interface:IEventSource
Get the parent source.- Specified by:
getParentSource
in interfaceIEventSource
- Returns:
- the parent source, or null if none
-
countListeners
public int countListeners()Description copied from interface:IEventSource
Get the numbers of objects listening to this event source.- Specified by:
countListeners
in interfaceIEventSource
- Returns:
- the number of listeners
-
getListeners
Description copied from interface:IEventSource
Get a copy of the list of listeners.- Specified by:
getListeners
in interfaceIEventSource
- Returns:
-
addListener
Description copied from interface:IEventSource
Register a listener. The listener is appended to the existing list of listeners. The implementor may allow duplicates.- Specified by:
addListener
in interfaceIEventSource
- Parameters:
listener
- a listener of events generated by this source
-
insertListener
Description copied from interface:IEventSource
Register a listener. The implementor may allow duplicates.- Specified by:
insertListener
in interfaceIEventSource
- Parameters:
index
- insertion pointlistener
- a listener of events generated by this source
-
removeListener
Description copied from interface:IEventSource
Unregister a listener. If the implementor allows duplicates in addListener(), it should deal with those consistently.- Specified by:
removeListener
in interfaceIEventSource
- Parameters:
listener
- the listener to be removed
-
notifyListeners
Description copied from interface:IEventSource
Notify listeners that an event has occurred.- Specified by:
notifyListeners
in interfaceIEventSource
- Parameters:
e
- the event to be propagated
-