Kinesis SoftwareKineticFusion

[Show Table of Contents]

10 RVML Reference

[Hide Table of Contents]



10.6.3 Anatomy of an RVML SAX Handler

All KineticFusion SAX handlers must implement the KFSaxElementHandlerType interface. The full interface is shown below:

/****************************************************************
 * Copyright (c) 2005, Kinesis Software Ltd, All rights reserved.
 ****************************************************************/
package com.kinesis.xml;
 
    
**
 * Interface for all Element handlers in KineticFusion
 */
public interface KFSaxElementHandlerType {
    /**
     * Called when a sub element is encountered for the element handled by this
     * handler. This will return the handler capable of handling the sub-element
     * or null if the sub-element handler cannot be found
     * 
     * @param namespaceURI
     * @param localName
     * @param qName
     * @param atts
     * @return The handler for processing the specified element
     * @throws Exception
     */
    public KFSaxElementHandlerType startSubElement(String namespaceURI, 
            String localName, String qName, AttributeProcessorType atts) 
            throws Exception;
 
    
    /**
     * Returns true if closure of sub element was handled successfully
     * 
     * @param namespaceURI
     * @param localName
     * @return true if closure of sub element was handled
     *                successfully
     * @throws Exception
     */
    public boolean endSubElement(String namespaceURI, String localName) 
                                                          throws Exception;
 
    
    /**
     * Add a persistent child element handler to this handler. The handler will
     * be be automatically returned when the specified element name and
     * namespace are encountered
     * 
     * @param namespace
     * @param elementName
     * @param handler
     * @return true if the ElementHandler supports the addition
     *                of persistent child element handlers
     */
        public boolean addGeneralSubElementHandler(String namespace, 
                                             String elementName,
                                             KFSaxElementHandlerType handler);
 
    
    /**
     * Add a persistent child element handler to this handler. The handler will
     * be be automatically returned when any element with the specified
     * namespace is encountered
     * 
     * @param namespace
     * @param handler
     * @return true if the ElementHandler supports the addition
     *                of persistent child namespace handlers
     */
    public boolean addGeneralSubElementHandler(String namespace, 
                                               KFSaxElementHandlerType handler);
 
    
    /**
     * Handle the current start element declaration, parsing and processing all
     * attributes. Returns true if element was handled successfully.
     * 
     * @param namespaceURI
     *                  The namespace of the element
     * @param localName
     *                  The local name of the element
     * @param qName
     *                  The qualified name of the element
     * @param atts
     *                  Attribute processor providing resolved attribute values
     * @return true if the start element event was handled
     *                successfully
     * @throws Exception
     */
    public boolean handleElement(String namespaceURI, String localName,
                        String qName, AttributeProcessorType atts) throws Exception;
 
    
    /**
     * Perform any end-of-element processing
     * 
     * @return true if element was handled successfully
     * @throws Exception
     */
    public boolean endElement() throws Exception;
 
    
    /**
     * Process character data for the current element
     * 
     * @param ch
     * @param start
     * @param length
     * @return true if characters were handled successfully
     * @throws Exception
     */
    public boolean characters(char[] ch, int start, int length) throws Exception;
 }

10.6.3.1 The RVMLSaxContextType Context Object

An RVMLSaxContextType (Context) instance is made available to all KineticFusion ElementHandlers on creation. The Context object stores both persistent and document-local information.

The following persistent information is stored in the context:

  • Logging Object
  • User-defined Global data
  • List of registered Resetable objects

The following information is specific to a single RVML document:

  • Document ID
  • Input Specification
  • Document User Data
  • ActionScript Settings
  • Actions Factory
  • Component Integrator
  • Data Model
  • Font Character Factory
  • Current Location String
  • Current Movie object
  • Parent Handlers
  • Source Location
  • SymbolFactory
  • Timeline Resolver

Further information on the contents of the context can be found in the javadoc.

10.6.3.2 The RVMLHandlerAdapter class

All current RVML handlers extend the RVMLHandlerAdapter class. This class provides default processing for all ElementHandler operations, and a full implementation of all methods required to add persistent child ElementHandlers to a handler. It also contains an implementation of startSubElement() that manages lookup and retrieval of persistent child handlers. All KineticFusion handlers use the mechanisms provided in this class to define a persistent handler hierarchy.

10.6.3.3 The Lifecycle of The ElementHandler Hierarchy

KineticFusion MovieHandler and Context object is generally persistent for the lifetime of an instance of the application and consequently so are all KineticFusion RVML handlers. For this reason, it is essential that handlers do not maintain state between RVML documents.

10.6.3.4 Resetable Interface

If any ElementHandler returns a fail status then processing of the input document is aborted. This means that it is possible for a Handler to receive a handleElement() event but not receive an endElement() event and may mean that the handler is in an inconsistent state or is storing unneeded information. Where this is possible, the Handler should implement the Resetable interface, implement the reset() method to reinitialize itself, and add itself to the RVMLSaxContext passed to it on creation. The context will iterate through all registered Resetable instances at the end of processing.

10.6.3.4.1 Attribute Processors

KineticFusion supports the evaluation of expressions embedded within attribute values. To optimize the processing of attribute values, attributes are passed to the handleElements() method using an AttributeProcessorType object. All values returned by the accessor methods of this object will already have all pre-processing carried out transparently. This class also provides many shortcut methods for extracting RVML-specific value types from attributes.

Now that we've explored the structure of the RVML processing architecture, it is now time to look at developer extensions.