Class JRVirtualizationContext

    • Field Detail

      • EXCEPTION_MESSAGE_KEY_LOCKING_INTERRUPTED

        public static final String EXCEPTION_MESSAGE_KEY_LOCKING_INTERRUPTED
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_RENDERER_NOT_FOUND_IN_CONTEXT

        public static final String EXCEPTION_MESSAGE_KEY_RENDERER_NOT_FOUND_IN_CONTEXT
        See Also:
        Constant Field Values
      • EXCEPTION_MESSAGE_KEY_TEMPLATE_NOT_FOUND_IN_CONTEXT

        public static final String EXCEPTION_MESSAGE_KEY_TEMPLATE_NOT_FOUND_IN_CONTEXT
        See Also:
        Constant Field Values
    • Constructor Detail

      • JRVirtualizationContext

        public JRVirtualizationContext​(JasperReportsContext jasperReportsContext)
        Constructs a context.
    • Method Detail

      • cacheRenderer

        public void cacheRenderer​(Renderable renderer)
        Caches an image renderer.
        Parameters:
        renderer - the image whose renderer should be cached
      • getCachedRenderer

        public Renderable getCachedRenderer​(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​(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​(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​(String templateId)
        Retrieves a cached template.
        Parameters:
        templateId - the template ID
        Returns:
        the cached template having the given ID
      • cacheTemplate

        public void cacheTemplate​(JRPrintElement element)
        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(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
      • getVirtualizer

        public JRVirtualizer getVirtualizer()
        Returns the virtualizer used by this context.
      • setVirtualizer

        public void setVirtualizer​(JRVirtualizer virtualizer)
      • traverseDeepElements

        protected void traverseDeepElements​(PrintElementVisitor<Void> visitor,
                                            Collection<? extends JRPrintElement> elements)
        Traverses all the elements on the page, including the ones placed inside frames.
        Parameters:
        visitor - element visitor
      • replaceSerializedObject

        public Object replaceSerializedObject​(Object obj)
      • resolveSerializedObject

        public Object resolveSerializedObject​(Object obj)
      • 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