Package net.sf.jasperreports.engine.fill
Class JRVirtualizationContext
java.lang.Object
net.sf.jasperreports.engine.fill.JRVirtualizationContext
- All Implemented Interfaces:
Serializable,VirtualizationListener<VirtualElementsData>
public class JRVirtualizationContext
extends Object
implements Serializable, VirtualizationListener<VirtualElementsData>
Context used to store data shared by virtualized objects resulted from a report fill process.
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJRVirtualizationContext(JRVirtualizationContext parentContext) JRVirtualizationContext(JasperReportsContext jasperReportsContext) Constructs a context. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(VirtualizationListener<VirtualElementsData> listener) Adds a virtualization listener.voidvoidCalled after an object's data was made available to the object.voidCalled before an object's data is externalized.voidcacheRenderer(Renderable renderer) Caches an image renderer.voidcacheTemplate(JRTemplateElement template) Caches an element template.voidcacheTemplate(JRPrintElement element) Caches the template of an element.voidcacheVirtualizableList(PrintElementId id, VirtualizableElementList virtualizableList) voiddispose()Marks this context as disposed in order to instruct the virtualizer that pages owned by this context are no longer used.Retrieves a cached image renderer based on an ID.getCachedTemplate(String templateId) Retrieves a cached template.intReturns the virtual page size used by the report.static JRVirtualizationContextgetRegistered(JasperPrint print) Returns the virtualization context registered for a print object.Returns the virtualizer used by this context.booleanDetermines whether a cached image renderer for a specified ID exists.booleanDetermines whether a cachedtemplatewith a specified ID exists.booleanDetermines if this context is marked as disposed.booleanDetermines whether this context has been marked as read-only.voidlock()Acquires a lock on this context.static voidregister(JRVirtualizationContext context, JasperPrint print) Registers a virtualization context forJasperPrintobject.voidRemove a virtualization listener.voidsetPageElementSize(int pageElementSize) Set the virtual page size used by the report.voidsetReadOnly(boolean readOnly) Sets the read-only flag for this context.voidsetVirtualizer(JRVirtualizer virtualizer) protected voidtraverseDeepElements(PrintElementVisitor<Void> visitor, Collection<? extends JRPrintElement> elements) Traverses all the elements on the page, including the ones placed insideframes.booleantryLock()Attempts to acquire a lock on this context.voidunlock()Releases the lock previously acquired on this context.voidupdateParent(JRVirtualizationContext destinationContext)
-
Field Details
-
EXCEPTION_MESSAGE_KEY_LOCKING_INTERRUPTED
- See Also:
-
EXCEPTION_MESSAGE_KEY_RENDERER_NOT_FOUND_IN_CONTEXT
- See Also:
-
EXCEPTION_MESSAGE_KEY_TEMPLATE_NOT_FOUND_IN_CONTEXT
- See Also:
-
-
Constructor Details
-
JRVirtualizationContext
Constructs a context. -
JRVirtualizationContext
-
-
Method Details
-
addListener
Adds a virtualization listener.- Parameters:
listener-
-
removeListener
Remove a virtualization listener.- Parameters:
listener-
-
beforeExternalization
Description copied from interface:VirtualizationListenerCalled before an object's data is externalized.- Specified by:
beforeExternalizationin interfaceVirtualizationListener<VirtualElementsData>- Parameters:
object-- See Also:
-
afterExternalization
-
afterInternalization
Description copied from interface:VirtualizationListenerCalled after an object's data was made available to the object.- Specified by:
afterInternalizationin interfaceVirtualizationListener<VirtualElementsData>- Parameters:
object-- See Also:
-
cacheRenderer
Caches an image renderer.- Parameters:
renderer- the image whose renderer should be cached
-
getCachedRenderer
Retrieves a cached image renderer based on an ID.- Parameters:
id- the ID- Returns:
- the cached image renderer for the ID
-
hasCachedRenderer
Determines whether a cached image renderer for a specified ID exists.- Parameters:
id- the ID- Returns:
trueif and only if the context contains a cached renderer with the specified ID
-
hasCachedTemplate
Determines whether a cachedtemplatewith a specified ID exists.- Parameters:
id- the template ID- Returns:
trueif and only if the context contains a cached template with the specified ID
-
cacheTemplate
Caches an element template.- Parameters:
template- the template to cache
-
getCachedTemplate
Retrieves a cached template.- Parameters:
templateId- the template ID- Returns:
- the cached template having the given ID
-
cacheTemplate
Caches the template of an element.- Parameters:
element- the element whose template to cache
-
isReadOnly
public boolean isReadOnly()Determines whether this context has been marked as read-only.- Returns:
- whether this context has been marked as read-only
- See Also:
-
setReadOnly
public void setReadOnly(boolean readOnly) Sets the read-only flag for this context.When in read-only mode, all the virtualizable objects belonging to this context are assumed final by the virtualizer and any change in a virtualizable object's data would be discarded on virtualization.
- Parameters:
readOnly- the read-only flag
-
register
Registers a virtualization context forJasperPrintobject.- Parameters:
context- the virtualization contextprint- the print object
-
getRegistered
Returns the virtualization context registered for a print object.When the engine fills a report using a virtualizer, it
registersthe virtualization context with the generatedJasperPrintobject so that the caller would be able to retrieve the context based on the returned print object.- Parameters:
print- a print object- Returns:
- the virtualization context registered for the print object, or
nullif no context has been registered
-
getPageElementSize
public int getPageElementSize()Returns the virtual page size used by the report.- Returns:
- the virtual page size used by the report
- See Also:
-
setPageElementSize
public void setPageElementSize(int pageElementSize) Set the virtual page size used by the report.- Parameters:
pageElementSize- the virtual page size- See Also:
-
getVirtualizer
Returns the virtualizer used by this context. -
setVirtualizer
-
traverseDeepElements
protected void traverseDeepElements(PrintElementVisitor<Void> visitor, Collection<? extends JRPrintElement> elements) Traverses all the elements on the page, including the ones placed insideframes.- Parameters:
visitor- element visitor
-
replaceSerializedObject
-
resolveSerializedObject
-
lock
public void lock()Acquires a lock on this context. -
tryLock
public boolean tryLock()Attempts to acquire a lock on this context.- Returns:
- true iff the lock was acquired on the context
-
unlock
public void unlock()Releases the lock previously acquired on this context. -
dispose
public void dispose()Marks this context as disposed in order to instruct the virtualizer that pages owned by this context are no longer used. -
isDisposed
public boolean isDisposed()Determines if this context is marked as disposed.- Returns:
- whether this context has been marked as disposed
-
getMasterContext
-
getCachedRenderers
-
getCachedTemplates
-
getFramesContext
-
getVirtualizableLists
-
cacheVirtualizableList
-
getVirtualizableList
-
updateParent
-
getJasperReportsContext
-