org.apache.tapestry.script
Class ScriptSessionImpl

java.lang.Object
  extended by org.apache.tapestry.script.ScriptSessionImpl
All Implemented Interfaces:
IScriptProcessor, ScriptSession

public class ScriptSessionImpl
extends java.lang.Object
implements ScriptSession

The result of executing a script, the session is used during the parsing process as well. Following IScript.execute(org.apache.tapestry.IRequestCycle, org.apache.tapestry.IScriptProcessor, java.util.Map), the session provides access to output symbols as well as the body and initialization blocks created by the script tokens.

Since:
0.2.9
Author:
Howard Lewis Ship

Constructor Summary
ScriptSessionImpl(org.apache.hivemind.Resource scriptTemplateResource, IRequestCycle cycle, IScriptProcessor processor, ExpressionEvaluator evaluator, ValueConverter valueConverter, java.util.Map symbols)
           
 
Method Summary
 void addBodyScript(java.lang.String script)
          Adds scripting code to the main body.
 void addExternalScript(org.apache.hivemind.Resource resource)
          Adds an external script.
 void addInitializationScript(java.lang.String script)
          Adds initialization script.
 java.lang.Object evaluate(java.lang.String expression)
          Evaluates an OGNL expression, where the root object for the expression is the symbols map.
 java.lang.Object evaluate(java.lang.String expression, java.lang.Class desiredType)
          Evaluates an expression and coerces the result to a particlar type.
 IRequestCycle getRequestCycle()
          Returns the current request cycle.
 org.apache.hivemind.Resource getScriptTemplateResource()
          Returns the resource for the script template.
 java.util.Map getSymbols()
          Returns the symbols (which may be created or updated during the execution of the script template).
 java.lang.String getUniqueString(java.lang.String baseValue)
          Ensures that the given string is unique.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ScriptSessionImpl

public ScriptSessionImpl(org.apache.hivemind.Resource scriptTemplateResource,
                         IRequestCycle cycle,
                         IScriptProcessor processor,
                         ExpressionEvaluator evaluator,
                         ValueConverter valueConverter,
                         java.util.Map symbols)
Method Detail

evaluate

public java.lang.Object evaluate(java.lang.String expression)
Description copied from interface: ScriptSession
Evaluates an OGNL expression, where the root object for the expression is the symbols map.

Specified by:
evaluate in interface ScriptSession

evaluate

public java.lang.Object evaluate(java.lang.String expression,
                                 java.lang.Class desiredType)
Description copied from interface: ScriptSession
Evaluates an expression and coerces the result to a particlar type.

Specified by:
evaluate in interface ScriptSession
See Also:
ValueConverter

getScriptTemplateResource

public org.apache.hivemind.Resource getScriptTemplateResource()
Description copied from interface: ScriptSession
Returns the resource for the script template.

Specified by:
getScriptTemplateResource in interface ScriptSession

getSymbols

public java.util.Map getSymbols()
Description copied from interface: ScriptSession
Returns the symbols (which may be created or updated during the execution of the script template).

Specified by:
getSymbols in interface ScriptSession

getRequestCycle

public IRequestCycle getRequestCycle()
Description copied from interface: ScriptSession
Returns the current request cycle.

Specified by:
getRequestCycle in interface ScriptSession

addBodyScript

public void addBodyScript(java.lang.String script)
Description copied from interface: IScriptProcessor
Adds scripting code to the main body. During the render, multiple scripts may render multiple bodies; all are concatinated together to form a single block. The Body component will write the body script contents just inside the <body> tag.

Specified by:
addBodyScript in interface IScriptProcessor

addExternalScript

public void addExternalScript(org.apache.hivemind.Resource resource)
Description copied from interface: IScriptProcessor
Adds an external script. The processor is expected to ensure that external scripts are only loaded a single time per page.

Specified by:
addExternalScript in interface IScriptProcessor

addInitializationScript

public void addInitializationScript(java.lang.String script)
Description copied from interface: IScriptProcessor
Adds initialization script. Initialization script is executed once, when the containing page loads. Initialization script content is written only after all HTML content that could be referenced from the script (in effect, just before the </body> tag).

Specified by:
addInitializationScript in interface IScriptProcessor

getUniqueString

public java.lang.String getUniqueString(java.lang.String baseValue)
Description copied from interface: IScriptProcessor
Ensures that the given string is unique. The string is either returned unchanged, or a suffix is appended to ensure uniqueness.

Specified by:
getUniqueString in interface IScriptProcessor

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object