cookxml.cookjython.creator
Class JythonCreator
java.lang.Object
cookxml.cookjython.creator.JythonCreator
- All Implemented Interfaces:
- Creator
- public class JythonCreator
- extends Object
- implements Creator
This class creates a Jython Interpreter instance and use it to interpret code within the tag.
Currently, it supports three optional attributes:
- return="variable", useful if you intend to read an object from jython interpreter
- class="java class name", useful only when the object obtained from jython interpreter could not be converted
to the correct Java class. In most cases, it is not needed.
- src="uri for the external python code", useful when you want to load source code from a resource
This code depends on TextCreator of CookXml's common component to load source code from a resource.
- Since:
- CookJython 1.0
- See Also:
PythonInterpreter
,
CookJythonIdMap
,
TextCreator.readText(String)
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
SRC_ATTR
public static final String SRC_ATTR
- See Also:
- Constant Field Values
RETURN_ATTR
public static final String RETURN_ATTR
- See Also:
- Constant Field Values
CLASS_ATTR
public static final String CLASS_ATTR
- See Also:
- Constant Field Values
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 elementelm
- the DOM element that contains all the information regarding this node.parentObj
- the parent object in the nodevalue
- the string value specified in the constructor fielddecodeEngine
- 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 tagelm
- the DOM element that contains all the information regarding this node.parentObj
- the parent object of the parent elementobj
- the object that was created by this create functiondecodeEngine
- 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