VMContext (Velocity 1.4 API)
Keywords: org.apache.velocity.context.VMContext class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.velocity.context
Class VMContext

    java.lang.Object
      org.apache.velocity.context.VMContext

All Implemented Interfaces:
  Context, InternalContextAdapter, InternalEventContext, InternalHousekeepingContext, InternalWrapperContext

public class VMContext
extends java.lang.Object
implements InternalContextAdapter

This is a special, internal-use-only context implementation to be used for the new Velocimacro implementation. The main distinguishing feature is the management of the VMProxyArg objects in the put() and get() methods. Further, this context also supports the 'VM local context' mode, where any get() or put() of references that aren't args to the VM are considered local to the vm, protecting the global context.

Version:
  $Id: VMContext.java,v 1.9.10.1 2004/03/03 23:22:54 geirm Exp $
Author:
  Geir Magnusson Jr.

Field Summary
`(package private) InternalContextAdapter` | `innerContext` the base context store.
`(package private) java.util.HashMap` | `localcontext` container for any local or constant VMProxy items
`private boolean` | `localcontextscope` support for local context scope feature, where all references are local
`(package private) java.util.HashMap` | `vmproxyhash` container for our VMProxy Objects
`(package private) InternalContextAdapter` | `wrappedContext` context that we are wrapping

Constructor Summary
`VMContext(InternalContextAdapter inner, RuntimeServices rsvc)` CTOR, wraps an ICA

Method Summary
`void` | `addVMProxyArg(VMProxyArg vmpa)` Used to put VMProxyArgs into this context.
`EventCartridge` | `attachEventCartridge(EventCartridge ec)`
`boolean` | `containsKey(java.lang.Object key)` not yet impl
`java.lang.Object` | `get(java.lang.String key)` Impl of the Context.gut() method.
`InternalContextAdapter` | `getBaseContext()` returns the base full context impl
`Resource` | `getCurrentResource()` temporary fix to enable #include() to figure out current encoding.
`java.lang.String` | `getCurrentTemplateName()` get the current template name
`EventCartridge` | `getEventCartridge()`
`Context` | `getInternalUserContext()` return the inner / user context
`java.lang.Object[]` | `getKeys()` impl badly
`java.lang.Object[]` | `getTemplateNameStack()` Returns the template name stack in form of an array.
`IntrospectionCacheData` | `icacheGet(java.lang.Object key)` returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key
`void` | `icachePut(java.lang.Object key, IntrospectionCacheData o)` places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key
`void` | `popCurrentTemplateName()` remove the current template name from stack
`void` | `pushCurrentTemplateName(java.lang.String s)` set the current template name on top of stack
`java.lang.Object` | `put(java.lang.String key, java.lang.Object value)` Impl of the Context.put() method.
`java.lang.Object` | `remove(java.lang.Object key)` impl badly
`void` | `setCurrentResource(Resource r)`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### vmproxyhash

    java.util.HashMap vmproxyhash

  container for our VMProxy Objects

### localcontext

    java.util.HashMap localcontext

  container for any local or constant VMProxy items

### innerContext

    InternalContextAdapter innerContext

  the base context store. This is the 'global' context

### wrappedContext

    InternalContextAdapter wrappedContext

  context that we are wrapping

### localcontextscope

    private boolean localcontextscope

  support for local context scope feature, where all references are local

Constructor Detail

### VMContext

    public VMContext(InternalContextAdapter inner,
                     RuntimeServices rsvc)

  CTOR, wraps an ICA

Method Detail

### getInternalUserContext

    public Context getInternalUserContext()

  return the inner / user context

  Specified by:
    `getInternalUserContext` in interface `InternalWrapperContext`

### getBaseContext

    public InternalContextAdapter getBaseContext()

  Description copied from interface: `InternalWrapperContext`
  returns the base full context impl

  Specified by:
    `getBaseContext` in interface `InternalWrapperContext`

### addVMProxyArg

    public void addVMProxyArg(VMProxyArg vmpa)

  Used to put VMProxyArgs into this context. It separates the VMProxyArgs into constant and non-constant types pulling out the value of the constant types so they can be modified w/o damaging the VMProxyArg, and leaving the dynamic ones, as they modify context rather than their own state

  Parameters:
    `vmpa` - VMProxyArg to add

### put

    public java.lang.Object put(java.lang.String key,
                                java.lang.Object value)

  Impl of the Context.put() method.

  Specified by:
    `put` in interface `Context`
  Parameters:
    `key` - name of item to set
    `value` - object to set to key
  Returns:
    old stored object

### get

    public java.lang.Object get(java.lang.String key)

  Impl of the Context.gut() method.

  Specified by:
    `get` in interface `Context`
  Parameters:
    `key` - name of item to get
  Returns:
    stored object or null

### containsKey

    public boolean containsKey(java.lang.Object key)

  not yet impl

  Specified by:
    `containsKey` in interface `Context`
  Parameters:
    `key` - The key to look for.
  Returns:
    Whether the key is in the context.

### getKeys

    public java.lang.Object[] getKeys()

  impl badly

  Specified by:
    `getKeys` in interface `Context`

### remove

    public java.lang.Object remove(java.lang.Object key)

  impl badly

  Specified by:
    `remove` in interface `Context`
  Parameters:
    `key` - The name of the value to remove.
  Returns:
    The value that the key was mapped to, or `null` if unmapped.

### pushCurrentTemplateName

    public void pushCurrentTemplateName(java.lang.String s)

  Description copied from interface: `InternalHousekeepingContext`
  set the current template name on top of stack

  Specified by:
    `pushCurrentTemplateName` in interface `InternalHousekeepingContext`
  Parameters:
    `s` - current template name

### popCurrentTemplateName

    public void popCurrentTemplateName()

  Description copied from interface: `InternalHousekeepingContext`
  remove the current template name from stack

  Specified by:
    `popCurrentTemplateName` in interface `InternalHousekeepingContext`

### getCurrentTemplateName

    public java.lang.String getCurrentTemplateName()

  Description copied from interface: `InternalHousekeepingContext`
  get the current template name

  Specified by:
    `getCurrentTemplateName` in interface `InternalHousekeepingContext`
  Returns:
    String current template name

### getTemplateNameStack

    public java.lang.Object[] getTemplateNameStack()

  Description copied from interface: `InternalHousekeepingContext`
  Returns the template name stack in form of an array.

  Specified by:
    `getTemplateNameStack` in interface `InternalHousekeepingContext`
  Returns:
    Object[] with the template name stack contents.

### icacheGet

    public IntrospectionCacheData icacheGet(java.lang.Object key)

  Description copied from interface: `InternalHousekeepingContext`
  returns an IntrospectionCache Data (@see IntrospectionCacheData) object if exists for the key

  Specified by:
    `icacheGet` in interface `InternalHousekeepingContext`
  Parameters:
    `key` - key to find in cache
  Returns:
    cache object

### icachePut

    public void icachePut(java.lang.Object key,
                          IntrospectionCacheData o)

  Description copied from interface: `InternalHousekeepingContext`
  places an IntrospectionCache Data (@see IntrospectionCacheData) element in the cache for specified key

  Specified by:
    `icachePut` in interface `InternalHousekeepingContext`
  Parameters:
    `key` - key
    `o` - IntrospectionCacheData object to place in cache

### attachEventCartridge

    public EventCartridge attachEventCartridge(EventCartridge ec)

  Specified by:
    `attachEventCartridge` in interface `InternalEventContext`

### getEventCartridge

    public EventCartridge getEventCartridge()

  Specified by:
    `getEventCartridge` in interface `InternalEventContext`

### setCurrentResource

    public void setCurrentResource(Resource r)

  Specified by:
    `setCurrentResource` in interface `InternalHousekeepingContext`

### getCurrentResource

    public Resource getCurrentResource()

  Description copied from interface: `InternalHousekeepingContext`
  temporary fix to enable #include() to figure out current encoding.

  Specified by:
    `getCurrentResource` in interface `InternalHousekeepingContext`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2002 Apache Software Foundation. All Rights Reserved.