net.sf.jasperreports.engine.fill

## Class JRAbstractLRUVirtualizer

- java.lang.Object
- - net.sf.jasperreports.engine.fill.JRAbstractLRUVirtualizer

- All Implemented Interfaces:
    JRVirtualizer
  Direct Known Subclasses:
    JRFileVirtualizer, JRGzipVirtualizer, StoreFactoryVirtualizer, StoreVirtualizer

      public abstract class JRAbstractLRUVirtualizer
      extends java.lang.Object
      implements JRVirtualizer

  Abstract base for LRU and serialization based virtualizer
  Version:
    $Id: JRAbstractLRUVirtualizer.java 6863 2014-02-06 09:59:27Z teodord $
  Author:
    John Bindel

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `JRAbstractLRUVirtualizer.Cache` This class keeps track of how many objects are currently in memory, and when there are too many, it pushes the last touched one to disk.
    `protected static class` | `JRAbstractLRUVirtualizer.CacheReference`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected org.apache.commons.collections.map.ReferenceMap` | `lastObjectMap`
    `protected java.lang.ref.WeakReference<JRVirtualizable>` | `lastObjectRef`
    `protected org.apache.commons.collections.map.ReferenceMap` | `lastObjectSet`
    `protected VirtualizationSerializer` | `serializer`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `JRAbstractLRUVirtualizer(int maxSize)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clearData(JRVirtualizable o)` Called when the virtual object paged-out data should be freed.
    `void` | `deregisterObject(JRVirtualizable o)` Lets this virtualizer know that it no longer must track the object.
    `protected void` | `dispose(JRVirtualizable o)`
    `protected abstract void` | `dispose(java.lang.String virtualId)` Removes the external data associated with a virtualizable object.
    `protected void` | `disposeAll()`
    `protected void` | `evict()`
    `protected void` | `finalize()`
    `protected boolean` | `isEvictable(JRVirtualizable value)`
    `protected boolean` | `isPagedOut(java.lang.String id)`
    `protected boolean` | `isPagedOutAndTouch(JRVirtualizable o, java.lang.String uid)`
    `boolean` | `isReadOnly()` Determines whether the virtualizer is in read-only mode.
    `protected boolean` | `isReadOnly(JRVirtualizable o)`
    `protected JRVirtualizable` | `lastObject()`
    `protected abstract void` | `pageIn(JRVirtualizable o)` Reads a virtualizable object's data from an external storage.
    `protected abstract void` | `pageOut(JRVirtualizable o)` Writes a virtualizable object's data to an external storage.
    `protected void` | `readData(JRVirtualizable o, java.io.InputStream in)` Reads serialized identity and virtual data for a virtualizable object from a stream.
    `void` | `registerObject(JRVirtualizable o)` Lets this virtualizer know that it must track the object.
    `void` | `requestData(JRVirtualizable o)` Called when the virtual object must be paged-in.
    `protected void` | `reset()`
    `protected void` | `setLastObject(JRVirtualizable o)`
    `void` | `setReadOnly(boolean ro)` Sets the read only mode for the virtualizer.
    `void` | `touch(JRVirtualizable o)` Lets the virtualizer know that this object is still being used.
    `void` | `virtualizeData(JRVirtualizable o)` Called when the virtual object should be paged-out.
    `protected void` | `writeData(JRVirtualizable o, java.io.OutputStream out)` Writes serialized indentity and virtual data of a virtualizable object to a stream.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface net.sf.jasperreports.engine.JRVirtualizer

      `cleanup`

- - ### Field Detail

    - #### serializer

          protected final VirtualizationSerializer serializer

    - #### lastObjectRef

          protected volatile java.lang.ref.WeakReference<JRVirtualizable> lastObjectRef

    - #### lastObjectMap

          protected org.apache.commons.collections.map.ReferenceMap lastObjectMap

    - #### lastObjectSet

          protected org.apache.commons.collections.map.ReferenceMap lastObjectSet

  - ### Constructor Detail

    - #### JRAbstractLRUVirtualizer

          protected JRAbstractLRUVirtualizer(int maxSize)

      Parameters:
        `maxSize` - the maximum size (in JRVirtualizable objects) of the paged in cache.

  - ### Method Detail

    - #### isPagedOut

          protected final boolean isPagedOut(java.lang.String id)

    - #### isPagedOutAndTouch

          protected boolean isPagedOutAndTouch(JRVirtualizable o,
                                   java.lang.String uid)

    - #### lastObject

          protected JRVirtualizable lastObject()

    - #### setLastObject

          protected final void setLastObject(JRVirtualizable o)

    - #### setReadOnly

          public void setReadOnly(boolean ro)

      Sets the read only mode for the virtualizer.

      When in read-only mode, the virtualizer assumes that virtualizable objects are final and any change in a virtualizable object's data is discarded.

      When the virtualizer is used for multiple virtualization contexts (in shared mode), calling this method would override the read-only flags from all the contexts and all the objects will be manipulated in read-only mode. Use `JRVirtualizationContext.setReadOnly(boolean)` to set the read-only mode for one specific context.
      Parameters:
        `ro` - the read-only mode to set

    - #### isReadOnly

          public boolean isReadOnly()

      Determines whether the virtualizer is in read-only mode.
      Returns:
        whether the virtualizer is in read-only mode
      See Also:
        `setReadOnly(boolean)`

    - #### isReadOnly

          protected final boolean isReadOnly(JRVirtualizable o)

    - #### registerObject

          public void registerObject(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Lets this virtualizer know that it must track the object.

      All virtualizable object must register with their virtualizer upon construction.

      Specified by:
        `registerObject` in interface `JRVirtualizer`

    - #### isEvictable

          protected boolean isEvictable(JRVirtualizable value)

    - #### evict

          protected void evict()

    - #### deregisterObject

          public void deregisterObject(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Lets this virtualizer know that it no longer must track the object.
      Specified by:
        `deregisterObject` in interface `JRVirtualizer`

    - #### touch

          public void touch(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Lets the virtualizer know that this object is still being used. This should be called to help the virtualizer determine which objects to keep in its cache, and which objects to page-out when it must do some paging-out.

      The virtualizer gets to decide what type of caching strategy it will use.

      Specified by:
        `touch` in interface `JRVirtualizer`

    - #### requestData

          public void requestData(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Called when the virtual object must be paged-in.

      If the object's virtual data is not paged-out, the object will only be `touched`.

      Specified by:
        `requestData` in interface `JRVirtualizer`

    - #### clearData

          public void clearData(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Called when the virtual object paged-out data should be freed.

      If the object's virtual data is not paged-out, the object will only be `touched`.

      Specified by:
        `clearData` in interface `JRVirtualizer`

    - #### virtualizeData

          public void virtualizeData(JRVirtualizable o)

      Description copied from interface: `JRVirtualizer`
      Called when the virtual object should be paged-out.
      Specified by:
        `virtualizeData` in interface `JRVirtualizer`

    - #### finalize

          protected void finalize()
                           throws java.lang.Throwable

      Overrides:
        `finalize` in class `java.lang.Object`
      Throws:
        `java.lang.Throwable`

    - #### writeData

          protected final void writeData(JRVirtualizable o,
                       java.io.OutputStream out)
                                  throws JRRuntimeException

      Writes serialized indentity and virtual data of a virtualizable object to a stream.
      Parameters:
        `o` - the serialized object
        `out` - the output stream
      Throws:
        `JRRuntimeException`

    - #### readData

          protected final void readData(JRVirtualizable o,
                      java.io.InputStream in)
                                 throws JRRuntimeException

      Reads serialized identity and virtual data for a virtualizable object from a stream.
      Parameters:
        `o` - the virtualizable object
        `in` - the input stream
      Throws:
        `JRRuntimeException`

    - #### reset

          protected void reset()

    - #### disposeAll

          protected final void disposeAll()

    - #### pageOut

          protected abstract void pageOut(JRVirtualizable o)
                                   throws java.io.IOException

      Writes a virtualizable object's data to an external storage.
      Parameters:
        `o` - a virtualizable object
      Throws:
        `java.io.IOException`

    - #### pageIn

          protected abstract void pageIn(JRVirtualizable o)
                                  throws java.io.IOException

      Reads a virtualizable object's data from an external storage.
      Parameters:
        `o` - a virtualizable object
      Throws:
        `java.io.IOException`

    - #### dispose

          protected void dispose(JRVirtualizable o)

    - #### dispose

          protected abstract void dispose(java.lang.String virtualId)

      Removes the external data associated with a virtualizable object.
      Parameters:
        `virtualId` - the ID of the virtualizable object

© 2001-2010 Jaspersoft Corporation www.jaspersoft.com