org.sapia.gumby
Class RenderContext

java.lang.Object
  |
  +--org.sapia.gumby.RenderContext

public class RenderContext
extends Object

An instance of this class holds tag definitions (in object form) and its own environment. It can be created through a RenderContextFactory or as a child of another instance of this class.

If it is created as a child of another context, it inherits the tag definitions and the environment of that context.

Instances of this class can be shared between multiple threads.

Author:
Yanick Duchesne
Copyright:
Copyright © 2002-2005 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site
See Also:
GuiEnv, RenderContextFactory, newChildInstance()

Method Summary
 View createView(String scope)
          Internally creates a view, maps as a scope under the given name, and returns it.
 GuiEnv getEnv()
          Returns the global environment object that this instance holds.
 Settings getSettings()
           
 void loadDefinitions(InputStream is)
          Loads the definitions corresponding to the givens stream within this context.
 RenderContext newChildInstance()
          This method returns a context that is a "child" of this instance: the child's environment will inherit its parent's.
 Object render(File xmlDesc)
           
 Object render(InputStream xmlDesc)
           
 void render(Object parent, File xmlDesc)
           
 void render(Object parent, InputStream xmlDesc)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEnv

public GuiEnv getEnv()
Returns the global environment object that this instance holds.

Returns:
a GuiEnv instance.

getSettings

public Settings getSettings()
Returns:
the Settings that this instance holds.

newChildInstance

public RenderContext newChildInstance()
This method returns a context that is a "child" of this instance: the child's environment will inherit its parent's. All scopes declared in the parent will thus be available to the child. All new scopes that do not yet exist in the parent will be created only in the child's environment (and will not be visible from the parent).

Similarly, all tags defined as part of the child will be visible only from the child downwards - if contexts are also created from the child and so on.

Creating different contexts with this method allows inheriting from the parent's environment and separating different instances when usage dictates it (for example, in a multithreaded context).

This is especially usefull when used in conjunction with views: the views can be created in isolation from one another, without risking naming conflicts and other side effects.

Returns:
a new RenderContext.
See Also:
View

createView

public View createView(String scope)
Internally creates a view, maps as a scope under the given name, and returns it.

Calling this method as the same effect as the following code:

   View v = new View(context);
   context.getEnv().addScope("someScope", v);
 

Parameters:
scope - the name of a scope.
Returns:
a View.

render

public Object render(InputStream xmlDesc)
              throws Exception
Parameters:
xmlDesc - the InputStream corresponding to an XML descriptor.
Returns:
the rendered Object.
Throws:
Exception - if a problem occurs while rendering.

render

public void render(Object parent,
                   InputStream xmlDesc)
            throws Exception
Parameters:
parent - Object that is intented to be the parent of the rendered root objects.
xmlDesc - the InputStream corresponding to an XML descriptor.
Throws:
Exception - if a problem occurs while rendering.

render

public Object render(File xmlDesc)
              throws Exception
Exception
See Also:
render(InputStream)

render

public void render(Object parent,
                   File xmlDesc)
            throws Exception
Exception
See Also:
render(Object, InputStream)

loadDefinitions

public void loadDefinitions(InputStream is)
                     throws Exception
Loads the definitions corresponding to the givens stream within this context. The definitions will be visible to all descendants of this context.

Parameters:
is - an InputStream corresponding to XML object definitions.
Throws:
Exception - if a problem occurs while loading the definitions.


Copyright © 2002 Sapia Open Community, Inc. All Rights Reserved.