net.sf.jasperreports.engine.fill
Class JRVirtualizationContext

java.lang.Object
  extended by net.sf.jasperreports.engine.fill.JRVirtualizationContext
All Implemented Interfaces:
java.io.Serializable

public class JRVirtualizationContext
extends java.lang.Object
implements java.io.Serializable

Context used to store data shared by virtualized objects resulted from a report fill process.

Version:
$Id: JRVirtualizationContext.java 3659 2010-03-31 10:20:49Z shertage $
Author:
Lucian Chirita ([email protected])
See Also:
Serialized Form

Constructor Summary
JRVirtualizationContext()
          Constructs a context.
 
Method Summary
 void cacheRenderer(JRPrintImage image)
          Caches an image renderer.
 void cacheTemplate(JRTemplateElement template)
          Caches an element template.
 JRRenderable getCachedRenderer(java.lang.String id)
          Retrieves a cached image renderer based on an ID.
 JRTemplateElement getCachedTemplate(java.lang.String templateId)
          Retrieves a cached template.
static JRVirtualizationContext getRegistered(JasperPrint print)
          Returns the virtualization context registered for a print object.
 boolean hasCachedRenderer(java.lang.String id)
          Determines whether a cached image renderer for a specified ID exists.
 boolean hasCachedTemplate(java.lang.String id)
          Determines whether a cached template with a specified ID exists.
 boolean isReadOnly()
          Determines whether this context has been marked as read-only.
static void register(JRVirtualizationContext context, JasperPrint print)
          Registers a virtualization context for JasperPrint object.
 void setReadOnly(boolean readOnly)
          Sets the read-only flag for this context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JRVirtualizationContext

public JRVirtualizationContext()
Constructs a context.

Method Detail

cacheRenderer

public void cacheRenderer(JRPrintImage image)
Caches an image renderer.

Parameters:
image - the image whose renderer should be cached

getCachedRenderer

public JRRenderable getCachedRenderer(java.lang.String id)
Retrieves a cached image renderer based on an ID.

Parameters:
id - the ID
Returns:
the cached image renderer for the ID

hasCachedRenderer

public boolean hasCachedRenderer(java.lang.String id)
Determines whether a cached image renderer for a specified ID exists.

Parameters:
id - the ID
Returns:
true if and only if the context contains a cached renderer with the specified ID

hasCachedTemplate

public boolean hasCachedTemplate(java.lang.String id)
Determines whether a cached template with a specified ID exists.

Parameters:
id - the template ID
Returns:
true if and only if the context contains a cached template with the specified ID

cacheTemplate

public void cacheTemplate(JRTemplateElement template)
Caches an element template.

Parameters:
template - the template to cache

getCachedTemplate

public JRTemplateElement getCachedTemplate(java.lang.String templateId)
Retrieves a cached template.

Parameters:
templateId - the template ID
Returns:
the cached template having the given ID

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(boolean)

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

public static void register(JRVirtualizationContext context,
                            JasperPrint print)
Registers a virtualization context for JasperPrint object.

Parameters:
context - the virtualization context
print - the print object

getRegistered

public static JRVirtualizationContext getRegistered(JasperPrint print)
Returns the virtualization context registered for a print object.

When the engine fills a report using a virtualizer, it registers the virtualization context with the generated JasperPrint object 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 null if no context has been registered


Copyright © 2011. All Rights Reserved.