cookxml.cookjs.creator
Class JSCreator

java.lang.Object
  extended bycookxml.cookjs.creator.JSCreator
All Implemented Interfaces:
Creator

public class JSCreator
extends Object
implements Creator

This creator creates a new JavaScript interpreter. It creates a hierarchy of scopes ImporterTopLevel -> Context scope -> CookXmlScope -> NativeObject scope (for actual interpretation).

Since:
CookJS 1.0
See Also:
ImporterTopLevel, Context, NativeObject

Field Summary
static String DEFAULT_SRC_NAME
           
static String SRC_ATTR
           
 
Method Summary
 Object create(String parentTag, Element elm, Object parentObj, String value, DecodeEngine decodeEngine)
          This function is called whenever decodeEngine starts processing an element.
 Object editFinished(String parentTag, Element elm, Object parentObj, Object obj, DecodeEngine decodeEngine)
          This function is called when the element and its subnodes have all been processed. and about to be returned.
static Creator getInstance()
           
static boolean isDisablingOptimization()
           
static boolean isUsingProxyJavaAdapter()
           
static void setDisablingOptimization(boolean disablingOptimization)
           
static void setUsingProxyJavaAdapter(boolean b)
          Set true if you want to use ProxyJavaAdapter, which is a JDK 1.3 feature that allows dynamic binding of JavaScript object functions etc to Java objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SRC_ATTR

public static final String SRC_ATTR
See Also:
Constant Field Values

DEFAULT_SRC_NAME

public static final String DEFAULT_SRC_NAME
See Also:
Constant Field Values
Method Detail

isUsingProxyJavaAdapter

public static boolean isUsingProxyJavaAdapter()

setUsingProxyJavaAdapter

public static void setUsingProxyJavaAdapter(boolean b)
Set true if you want to use ProxyJavaAdapter, which is a JDK 1.3 feature that allows dynamic binding of JavaScript object functions etc to Java objects. This approach does not involve creating a ClassLoader, which Rhino JavaScript's own JavaAdapter class uses. Creating a ClassLoader can cause permission exception from SecurityManager if there is one. The main benefit of using ProxyJavaAdapter is to allow JavaScript embedded programs running in Java Web Start or Applet in a Sandbox without signed jars.

Parameters:
b - use or not

isDisablingOptimization

public static boolean isDisablingOptimization()

setDisablingOptimization

public static void setDisablingOptimization(boolean disablingOptimization)

getInstance

public static Creator getInstance()

create

public Object create(String parentTag,
                     Element elm,
                     Object parentObj,
                     String value,
                     DecodeEngine decodeEngine)
              throws CreatorException
Description copied from interface: Creator
This function is called whenever decodeEngine starts processing an element. It should return an object that corresponds to the tag, or null to indicate no object could be created. If the object returned is of NoAdd type, then the object is not added to the parent object by decodeEngine.

There can be creative use of this function. For example, one could create another instance of CookXml that process the element differently, then call this instanceof decodeEngine to add the processed object to the parent, and then return null to tell this instance of decodeEngine/CookXml to stop processing the element.

Specified by:
create in interface Creator
Parameters:
parentTag - the parent tag that contains this element
elm - the DOM element that contains all the information regarding this node.
parentObj - the parent object in the node
value - the string value specified in the constructor field
decodeEngine - the decode engine that is being used
Returns:
the object created, or null to tell decodeEngine to stop processing this node
Throws:
CreatorException

editFinished

public Object editFinished(String parentTag,
                           Element elm,
                           Object parentObj,
                           Object obj,
                           DecodeEngine decodeEngine)
                    throws CookXmlException
Description copied from interface: Creator
This function is called when the element and its subnodes have all been processed. and about to be returned. For many helper objects that implement NoAdd, this is a great time to generate the real object and call the decodeEngine.addChild to add the real object to the parent.

Specified by:
editFinished in interface Creator
Parameters:
parentTag - the parent element tag
elm - the DOM element that contains all the information regarding this node.
parentObj - the parent object of the parent element
obj - the object that was created by this create function
decodeEngine - the decode engine that is being used.
Returns:
the object. The purpose is to allow a helper object to return the real object.
Throws:
CookXmlException