org.eclipse.birt.chart.script
Class ScriptHandler

java.lang.Object
  extended by org.mozilla.javascript.ScriptableObject
      extended by org.eclipse.birt.chart.script.ScriptHandler
All Implemented Interfaces:
java.io.Serializable, org.mozilla.javascript.ConstProperties, org.mozilla.javascript.debug.DebuggableObject, org.mozilla.javascript.Scriptable

public final class ScriptHandler
extends org.mozilla.javascript.ScriptableObject

This class forms the basis of script handling in the charting library. It creates a default scope and/or subclasses from a predefined scope. It also provides convenience methods for execution of functions defined in the scope.

See Also:
IChartEventHandler, Serialized Form

Field Summary
static java.lang.String AFTER_COMPUTATIONS
           
static java.lang.String AFTER_DATA_SET_FILLED
           
static java.lang.String AFTER_DRAW_AXIS_LABEL
           
static java.lang.String AFTER_DRAW_AXIS_TITLE
           
static java.lang.String AFTER_DRAW_BLOCK
           
static java.lang.String AFTER_DRAW_DATA_POINT
           
static java.lang.String AFTER_DRAW_DATA_POINT_LABEL
           
static java.lang.String AFTER_DRAW_ELEMENT
          Deprecated. This is kept for backward compatibility only.
static java.lang.String AFTER_DRAW_FITTING_CURVE
           
static java.lang.String AFTER_DRAW_LEGEND_ENTRY
          Deprecated. This is kept for backward compatibility only.
static java.lang.String AFTER_DRAW_LEGEND_ITEM
           
static java.lang.String AFTER_DRAW_MARKER
           
static java.lang.String AFTER_DRAW_MARKER_LINE
           
static java.lang.String AFTER_DRAW_MARKER_RANGE
           
static java.lang.String AFTER_DRAW_SERIES
           
static java.lang.String AFTER_DRAW_SERIES_TITLE
           
static java.lang.String AFTER_GENERATION
           
static java.lang.String AFTER_LAYOUT
          Deprecated. This is kept for backward compatibility only.
static java.lang.String AFTER_RENDERING
           
static java.lang.String BASE_VALUE
          The pre-defined chart variable name to access base category data.
static java.lang.String BEFORE_COMPUTATIONS
           
static java.lang.String BEFORE_DATA_SET_FILLED
           
static java.lang.String BEFORE_DRAW_AXIS_LABEL
           
static java.lang.String BEFORE_DRAW_AXIS_TITLE
           
static java.lang.String BEFORE_DRAW_BLOCK
           
static java.lang.String BEFORE_DRAW_DATA_POINT
           
static java.lang.String BEFORE_DRAW_DATA_POINT_LABEL
           
static java.lang.String BEFORE_DRAW_ELEMENT
          Deprecated. This is kept for backward compatibility only.
static java.lang.String BEFORE_DRAW_FITTING_CURVE
           
static java.lang.String BEFORE_DRAW_LEGEND_ENTRY
          Deprecated. This is kept for backward compatibility only.
static java.lang.String BEFORE_DRAW_LEGEND_ITEM
           
static java.lang.String BEFORE_DRAW_MARKER
           
static java.lang.String BEFORE_DRAW_MARKER_LINE
           
static java.lang.String BEFORE_DRAW_MARKER_RANGE
           
static java.lang.String BEFORE_DRAW_SERIES
           
static java.lang.String BEFORE_DRAW_SERIES_TITLE
           
static java.lang.String BEFORE_GENERATION
           
static java.lang.String BEFORE_LAYOUT
          Deprecated. This is kept for backward compatibility only.
static java.lang.String BEFORE_RENDERING
           
static java.lang.String FINISH_COMPUTE_SERIES
          Deprecated. This is kept for backward compatibility only.
static java.lang.String FINISH_GENERATION
          Deprecated. This is kept for backward compatibility only.
static java.lang.String FINISH_RENDERING
          Deprecated. This is kept for backward compatibility only.
static java.lang.String ORTHOGONAL_VALUE
          The pre-defined chart variable name to access orthogonal value data.
static java.lang.String SERIES_VALUE
          The pre-defined chart variable name to access series value data.
static java.lang.String START_COMPUTE_SERIES
          Deprecated. This is kept for backward compatibility only.
static java.lang.String START_GENERATION
          Deprecated. This is kept for backward compatibility only.
static java.lang.String START_RENDERING
          Deprecated. This is kept for backward compatibility only.
 
Fields inherited from class org.mozilla.javascript.ScriptableObject
CONST, DONTENUM, EMPTY, PERMANENT, READONLY, UNINITIALIZED_CONST
 
Fields inherited from interface org.mozilla.javascript.Scriptable
NOT_FOUND
 
Constructor Summary
ScriptHandler()
          The constructor.
 
Method Summary
static java.lang.Object callFunction(ScriptHandler sh, java.lang.String sFunction, java.lang.Object oArg1)
          Call JavaScript functions with one argument.
static java.lang.Object callFunction(ScriptHandler sh, java.lang.String sFunction, java.lang.Object oArg1, java.lang.Object oArg2)
          Call JavaScript functions with two arguments.
static java.lang.Object callFunction(ScriptHandler sh, java.lang.String sFunction, java.lang.Object oArg1, java.lang.Object oArg2, java.lang.Object oArg3)
          Call JavaScript functions with three arguments.
 java.lang.Object evaluate(java.lang.String sScriptContent)
          Evaluates the given expression and returns the value.
 java.lang.String getClassName()
           
 org.mozilla.javascript.Scriptable getScope()
           
 void init(org.mozilla.javascript.Scriptable scPrototype)
          Initialize the JavaScript context using given parent scope.
 java.lang.Object jsFunction_clone(java.lang.Object eo)
          Deprecated. Note used anymore. This is kept for backward compatibility only.
 java.lang.Object jsFunction_getDesignTimeModel()
          Deprecated. Not used anymore. This is kept for backward compatibility only.
 java.lang.Object jsFunction_getGeneratedChartState()
          Deprecated. Not used anymore. This is kept for backward compatibility only.
 java.lang.Object jsFunction_getLocale()
          Deprecated. Call IChartScriptContext.getLocale() instead. This is kept for backward compatibility only.
 java.lang.Object jsFunction_getRunTimeModel()
          Deprecated. Call IChartScriptContext.getChartInstance() instead. This is kept for backward compatibility only.
 void register(java.lang.String sScriptName, java.lang.String sScriptContent)
          Register the script content for current script handler.
 void registerExistingScriptableObject(org.mozilla.javascript.ScriptableObject so, java.lang.String sVarName)
          Registers an existing scriptable object into current JavaScript context.
 void registerNewScriptableObject(java.lang.Class<? extends org.mozilla.javascript.Scriptable> clsScriptable, java.lang.String sVarName)
          Registers a new scriptable object into current JavaScript context.
 void registerVariable(java.lang.String sVarName, java.lang.Object var)
          Registers a new variable to current JavaScript context.
 void setDesignTimeModel(Chart cmDesignTime)
          Deprecated. Not used anymore. This is kept for backward compatibility only.
 void setGeneratedChartState(GeneratedChartState gcs)
          Deprecated. Not used anymore. This is kept for backward compatibility only.
 void setLocale(com.ibm.icu.util.ULocale lcl)
          Deprecated. Not used anymore. Use IChartScriptContext to store the locale now. This is kept for backward compatibility only.
 void setRunTimeModel(Chart cmRunTime)
          Deprecated. Not used anymore. Use IChartScriptContext to store the run-time model now. This is kept for backward compatibility only.
 void setScriptClassLoader(IScriptClassLoader value)
          Sets the script class loader.
 void setScriptContext(IChartScriptContext csc)
          Sets the context object of current script handler.
 void unregisterVariable(java.lang.String sVarName)
          Unregister a variable from current JavaScript context.
 
Methods inherited from class org.mozilla.javascript.ScriptableObject
associateValue, avoidObjectDetection, callMethod, callMethod, defineClass, defineClass, defineClass, defineConst, defineConstProperty, defineFunctionProperties, defineProperty, defineProperty, defineProperty, defineProperty, delete, delete, deleteProperty, deleteProperty, get, get, getAllIds, getAssociatedValue, getAttributes, getAttributes, getAttributes, getAttributes, getClassPrototype, getDefaultValue, getDefaultValue, getFunctionPrototype, getGetterOrSetter, getIds, getObjectPrototype, getParentScope, getProperty, getProperty, getPropertyIds, getPrototype, getTopLevelScope, getTopScopeValue, has, has, hasInstance, hasProperty, hasProperty, isConst, isSealed, put, put, putConst, putConstProperty, putProperty, putProperty, redefineProperty, sealObject, setAttributes, setAttributes, setAttributes, setAttributes, setGetterOrSetter, setParentScope, setPrototype
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

START_GENERATION

public static final java.lang.String START_GENERATION
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

FINISH_GENERATION

public static final java.lang.String FINISH_GENERATION
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

BEFORE_LAYOUT

public static final java.lang.String BEFORE_LAYOUT
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

AFTER_LAYOUT

public static final java.lang.String AFTER_LAYOUT
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

BEFORE_COMPUTATIONS

public static final java.lang.String BEFORE_COMPUTATIONS
See Also:
Constant Field Values

AFTER_COMPUTATIONS

public static final java.lang.String AFTER_COMPUTATIONS
See Also:
Constant Field Values

START_RENDERING

public static final java.lang.String START_RENDERING
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

FINISH_RENDERING

public static final java.lang.String FINISH_RENDERING
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

START_COMPUTE_SERIES

public static final java.lang.String START_COMPUTE_SERIES
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

FINISH_COMPUTE_SERIES

public static final java.lang.String FINISH_COMPUTE_SERIES
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

BEFORE_DRAW_ELEMENT

public static final java.lang.String BEFORE_DRAW_ELEMENT
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

AFTER_DRAW_ELEMENT

public static final java.lang.String AFTER_DRAW_ELEMENT
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

BEFORE_DATA_SET_FILLED

public static final java.lang.String BEFORE_DATA_SET_FILLED
See Also:
Constant Field Values

AFTER_DATA_SET_FILLED

public static final java.lang.String AFTER_DATA_SET_FILLED
See Also:
Constant Field Values

BEFORE_GENERATION

public static final java.lang.String BEFORE_GENERATION
See Also:
Constant Field Values

AFTER_GENERATION

public static final java.lang.String AFTER_GENERATION
See Also:
Constant Field Values

BEFORE_RENDERING

public static final java.lang.String BEFORE_RENDERING
See Also:
Constant Field Values

AFTER_RENDERING

public static final java.lang.String AFTER_RENDERING
See Also:
Constant Field Values

BEFORE_DRAW_BLOCK

public static final java.lang.String BEFORE_DRAW_BLOCK
See Also:
Constant Field Values

AFTER_DRAW_BLOCK

public static final java.lang.String AFTER_DRAW_BLOCK
See Also:
Constant Field Values

BEFORE_DRAW_LEGEND_ENTRY

public static final java.lang.String BEFORE_DRAW_LEGEND_ENTRY
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

AFTER_DRAW_LEGEND_ENTRY

public static final java.lang.String AFTER_DRAW_LEGEND_ENTRY
Deprecated. This is kept for backward compatibility only.
See Also:
Constant Field Values

BEFORE_DRAW_LEGEND_ITEM

public static final java.lang.String BEFORE_DRAW_LEGEND_ITEM
See Also:
Constant Field Values

AFTER_DRAW_LEGEND_ITEM

public static final java.lang.String AFTER_DRAW_LEGEND_ITEM
See Also:
Constant Field Values

BEFORE_DRAW_SERIES

public static final java.lang.String BEFORE_DRAW_SERIES
See Also:
Constant Field Values

AFTER_DRAW_SERIES

public static final java.lang.String AFTER_DRAW_SERIES
See Also:
Constant Field Values

BEFORE_DRAW_SERIES_TITLE

public static final java.lang.String BEFORE_DRAW_SERIES_TITLE
See Also:
Constant Field Values

AFTER_DRAW_SERIES_TITLE

public static final java.lang.String AFTER_DRAW_SERIES_TITLE
See Also:
Constant Field Values

BEFORE_DRAW_MARKER

public static final java.lang.String BEFORE_DRAW_MARKER
See Also:
Constant Field Values

AFTER_DRAW_MARKER

public static final java.lang.String AFTER_DRAW_MARKER
See Also:
Constant Field Values

BEFORE_DRAW_MARKER_LINE

public static final java.lang.String BEFORE_DRAW_MARKER_LINE
See Also:
Constant Field Values

AFTER_DRAW_MARKER_LINE

public static final java.lang.String AFTER_DRAW_MARKER_LINE
See Also:
Constant Field Values

BEFORE_DRAW_MARKER_RANGE

public static final java.lang.String BEFORE_DRAW_MARKER_RANGE
See Also:
Constant Field Values

AFTER_DRAW_MARKER_RANGE

public static final java.lang.String AFTER_DRAW_MARKER_RANGE
See Also:
Constant Field Values

BEFORE_DRAW_DATA_POINT

public static final java.lang.String BEFORE_DRAW_DATA_POINT
See Also:
Constant Field Values

AFTER_DRAW_DATA_POINT

public static final java.lang.String AFTER_DRAW_DATA_POINT
See Also:
Constant Field Values

BEFORE_DRAW_DATA_POINT_LABEL

public static final java.lang.String BEFORE_DRAW_DATA_POINT_LABEL
See Also:
Constant Field Values

AFTER_DRAW_DATA_POINT_LABEL

public static final java.lang.String AFTER_DRAW_DATA_POINT_LABEL
See Also:
Constant Field Values

BEFORE_DRAW_FITTING_CURVE

public static final java.lang.String BEFORE_DRAW_FITTING_CURVE
See Also:
Constant Field Values

AFTER_DRAW_FITTING_CURVE

public static final java.lang.String AFTER_DRAW_FITTING_CURVE
See Also:
Constant Field Values

BEFORE_DRAW_AXIS_LABEL

public static final java.lang.String BEFORE_DRAW_AXIS_LABEL
See Also:
Constant Field Values

AFTER_DRAW_AXIS_LABEL

public static final java.lang.String AFTER_DRAW_AXIS_LABEL
See Also:
Constant Field Values

BEFORE_DRAW_AXIS_TITLE

public static final java.lang.String BEFORE_DRAW_AXIS_TITLE
See Also:
Constant Field Values

AFTER_DRAW_AXIS_TITLE

public static final java.lang.String AFTER_DRAW_AXIS_TITLE
See Also:
Constant Field Values

BASE_VALUE

public static final java.lang.String BASE_VALUE
The pre-defined chart variable name to access base category data.

See Also:
Constant Field Values

ORTHOGONAL_VALUE

public static final java.lang.String ORTHOGONAL_VALUE
The pre-defined chart variable name to access orthogonal value data.

See Also:
Constant Field Values

SERIES_VALUE

public static final java.lang.String SERIES_VALUE
The pre-defined chart variable name to access series value data.

See Also:
Constant Field Values
Constructor Detail

ScriptHandler

public ScriptHandler()
The constructor.

Method Detail

getClassName

public final java.lang.String getClassName()
Specified by:
getClassName in interface org.mozilla.javascript.Scriptable
Specified by:
getClassName in class org.mozilla.javascript.ScriptableObject

getScope

public final org.mozilla.javascript.Scriptable getScope()
Returns:
returns the scope of current JavaScript context.

jsFunction_getDesignTimeModel

public java.lang.Object jsFunction_getDesignTimeModel()
Deprecated. Not used anymore. This is kept for backward compatibility only.

Returns:
An instance of the chart model used at design time

jsFunction_getRunTimeModel

public java.lang.Object jsFunction_getRunTimeModel()
Deprecated. Call IChartScriptContext.getChartInstance() instead. This is kept for backward compatibility only.

Returns:
An instance of the chart model used at run time

jsFunction_getGeneratedChartState

public java.lang.Object jsFunction_getGeneratedChartState()
Deprecated. Not used anymore. This is kept for backward compatibility only.

Returns:
An instance of the run time model coupled with a computations and series filled with datasets

jsFunction_getLocale

public final java.lang.Object jsFunction_getLocale()
Deprecated. Call IChartScriptContext.getLocale() instead. This is kept for backward compatibility only.

Returns:
The locale associated with the generation request

jsFunction_clone

public final java.lang.Object jsFunction_clone(java.lang.Object eo)
Deprecated. Note used anymore. This is kept for backward compatibility only.

Parameters:
eo - An EMF generated model object to be cloned
Returns:
A cloned instance of the specified EMF generated model object

setDesignTimeModel

public final void setDesignTimeModel(Chart cmDesignTime)
Deprecated. Not used anymore. This is kept for backward compatibility only.

Parameters:
cm -

setRunTimeModel

public final void setRunTimeModel(Chart cmRunTime)
Deprecated. Not used anymore. Use IChartScriptContext to store the run-time model now. This is kept for backward compatibility only.

Parameters:
cm -

setGeneratedChartState

public final void setGeneratedChartState(GeneratedChartState gcs)
Deprecated. Not used anymore. This is kept for backward compatibility only.

Parameters:
gcs -

setLocale

public final void setLocale(com.ibm.icu.util.ULocale lcl)
Deprecated. Not used anymore. Use IChartScriptContext to store the locale now. This is kept for backward compatibility only.

Parameters:
lcl -

setScriptClassLoader

public final void setScriptClassLoader(IScriptClassLoader value)
Sets the script class loader. This loader is responsible to load all user defined script class.

Parameters:
value -

init

public final void init(org.mozilla.javascript.Scriptable scPrototype)
                throws ChartException
Initialize the JavaScript context using given parent scope.

Parameters:
scPrototype - Parent scope object. If it's null, use default scope.
Throws:
ChartException

registerExistingScriptableObject

public final void registerExistingScriptableObject(org.mozilla.javascript.ScriptableObject so,
                                                   java.lang.String sVarName)
                                            throws ChartException
Registers an existing scriptable object into current JavaScript context.

Parameters:
so - The existing scriptable object to be registered
sVarName - The name of the javascript variable associated with the new scriptable object that will be added to the scope
Throws:
ChartException

registerNewScriptableObject

public final void registerNewScriptableObject(java.lang.Class<? extends org.mozilla.javascript.Scriptable> clsScriptable,
                                              java.lang.String sVarName)
                                       throws ChartException
Registers a new scriptable object into current JavaScript context.

Parameters:
clsScriptable - The class representing the new scriptable object to be registered
sVarName - The name of the javascript variable associated with the new scriptable object that will be added to the scope
Throws:
ChartException

registerVariable

public final void registerVariable(java.lang.String sVarName,
                                   java.lang.Object var)
                            throws ChartException
Registers a new variable to current JavaScript context. If the name already exists, it'll be overwritten.

Parameters:
sVarName -
Throws:
ChartException

unregisterVariable

public final void unregisterVariable(java.lang.String sVarName)
                              throws ChartException
Unregister a variable from current JavaScript context.

Parameters:
sVarName -
Throws:
ChartException

callFunction

public static final java.lang.Object callFunction(ScriptHandler sh,
                                                  java.lang.String sFunction,
                                                  java.lang.Object oArg1)
                                           throws ChartException
Call JavaScript functions with one argument.

Parameters:
sh -
sFunction -
oArg1 -
Throws:
ChartException

callFunction

public static final java.lang.Object callFunction(ScriptHandler sh,
                                                  java.lang.String sFunction,
                                                  java.lang.Object oArg1,
                                                  java.lang.Object oArg2)
                                           throws ChartException
Call JavaScript functions with two arguments.

Parameters:
sh -
sFunction -
oArg1 -
oArg2 -
Throws:
ChartException

callFunction

public static final java.lang.Object callFunction(ScriptHandler sh,
                                                  java.lang.String sFunction,
                                                  java.lang.Object oArg1,
                                                  java.lang.Object oArg2,
                                                  java.lang.Object oArg3)
                                           throws ChartException
Call JavaScript functions with three arguments.

Parameters:
sh -
sFunction -
oArg1 -
oArg2 -
oArg3 -
Throws:
ChartException

evaluate

public final java.lang.Object evaluate(java.lang.String sScriptContent)
                                throws ChartException
Evaluates the given expression and returns the value.

Parameters:
sScriptContent -
Throws:
ChartException

register

public final void register(java.lang.String sScriptName,
                           java.lang.String sScriptContent)
                    throws ChartException
Register the script content for current script handler.

Parameters:
sScriptContent - This is either the JavaSciprt code content or a full class name which has implemented IChartItemScriptHandler
Throws:
ChartException

setScriptContext

public void setScriptContext(IChartScriptContext csc)
Sets the context object of current script handler.

Parameters:
csc -


Copyright © 2005-2008 Actuate Corp. All rights reserved.