Classes involved

The content on demand feature involves the following classes:

The IlvContentController class

The IlvContentController class defines the following methods:
  • setSDMEngine(IlvSDMEngine engine) Sets the SDM engine to work on.
  • setContentHandler(IlvContentHandler handler) Sets the handler.
  • setCacheSize(int size) Sets the cache size.
Methods to send requests
  • lockArea(IlvRect area, int mode) Locks the objects that intersect with the given rectangle. The mode indicates the status of previously locked objects. The allowed values are:
    • IlvContentHandler.OVERRIDE Previously locked objects are unlocked.
    • IlvContentHandler.AUGMENT Previously locked objects remain locked.
    The class ilog.views.sdm.modeltools.IlvVisibleAreaListener provides a view listener that locks automatically the visible area of an SDM view.
  • processObjects(Object[] objects, int action) Locks, loads, or unloads the given objects, according to the action value, which can be one of:
    • IlvContentHandler.LOCK Lock action.
    • IlvContentHandler.UNLOCK Unlock action (once unlocked, objects can be unloaded at any time).
    • IlvContentHandler.UNLOAD Unload action.
  • processObjects(Enumeration objects, int action) Similar to the previous method but objects are defined in an Enumeration.
  • processObjects(Iterator objects, int action) Similar to the previous method but objects are defined in an Iterator.
  • processAllObjects(int action) Similar to the previous method but operates on all objects.
All these methods are synchronized and return an integer which represents the number of objects that have switched to the requested state.
Methods to retrieve the current state of an object
The following method retrieves the current state (LOCK/UNLOCK/UNLOAD) of an object in the controller. Depending on the handler implementation (typically, if actions are performed in a different thread), the state may differ from reality, for example, a content is not yet available although the state is LOCK.
  • int getObjectStatus(Object obj) Returns the current state of the given object.
Other methods of the IlvContentController class:
  • IlvSDMEngine getSDMEngine() Returns the SDM engine.
  • IlvContentHandler getContentHandler() Returns the content handler.
  • void setNotificationEnabled(boolean on) If on is false, the handler is not notified.
  • boolean isNotificationEnabled() Returns whether notifications are enabled.
  • int getLockedCount() Returns the number of locked objects.
  • int getLoadedCount() Returns the number of objects in the cache.

The IlvContentHandler interface

The IlvContentHandler interface defines the following methods:
  • loadContent(IlvContentControler source, Object[] objs) Loads the content of the given objects into the SDM model.
  • unloadContent(IlvContentControler source, Object[] objs) Unloads the content of the given objects into the SDM model.
The source argument indicates the controller that sends the request.

The IlvVisibleAreaListener class

The IlvVisibleAreaListener class computes the visible area of a view as it changes and sends it as a request to the controller. The constructor takes the controller as parameter. To start listening to the visible area changes on a view, call the method:
  • installListener(IlvManagerView target) Installs a transformer listener.
Example of use:
IlvVisibleAreaListener l = new IlvVisibleAreaListener(contentControler);
l.installListener(contentControler.getSDMEngine().getReferenceView());
The method requestAreaToLock can be subclassed to control the area to lock, as follows:
  • int requestAreaToLock(IlvRect area) Called when the view transformer has changed. The default implementation simply calls the controller method lockArea(area, OVERRIDE) and returns the number of objects that have been loaded.