InternalContextAdapterImpl (Velocity 1.4 API)
Keywords: org.apache.velocity.context.InternalContextAdapterImpl 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 InternalContextAdapterImpl

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

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

public final class InternalContextAdapterImpl
extends java.lang.Object
implements InternalContextAdapter

This adapter class is the container for all context types for internal use. The AST now uses this class rather than the app-level Context interface to allow flexibility in the future. Currently, we have two context interfaces which must be supported :

- Context : used for application/template data access
- InternalHousekeepingContext : used for internal housekeeping and caching
- InternalWrapperContext : used for getting root cache context and other such.
- InternalEventContext : for event handling.

This class implements the two interfaces to ensure that all methods are supported. When adding to the interfaces, or adding more context functionality, the interface is the primary definition, so alter that first and then all classes as necessary. As of this writing, this would be the only class affected by changes to InternalContext This class ensures that an InternalContextBase is available for internal use. If an application constructs their own Context-implementing object w/o subclassing AbstractContext, it may be that support for InternalContext is not available. Therefore, InternalContextAdapter will create an InternalContextBase if necessary for this support. Note that if this is necessary, internal information such as node-cache data will be lost from use to use of the context. This may or may not be important, depending upon application.

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

Field Summary
`(package private) Context` | `context` the user data Context that we are wrapping
`(package private) InternalHousekeepingContext` | `icb` the ICB we are wrapping.
`(package private) InternalEventContext` | `iec` The InternalEventContext that we are wrapping.

Constructor Summary
`InternalContextAdapterImpl(Context c)` CTOR takes a Context and wraps it, delegating all 'data' calls to it.

Method Summary
`EventCartridge` | `attachEventCartridge(EventCartridge ec)`
`boolean` | `containsKey(java.lang.Object key)` Indicates whether the specified key is in the context.
`java.lang.Object` | `get(java.lang.String key)` Gets the value corresponding to the provided key from the context.
`InternalContextAdapter` | `getBaseContext()` Returns the base context that we are wrapping.
`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()` returns the user data context that we are wrapping
`java.lang.Object[]` | `getKeys()` Get all the keys for the values in the context
`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)` Adds a name/value pair to the context.
`java.lang.Object` | `remove(java.lang.Object key)` Removes the value associated with the specified key from the context.
`void` | `setCurrentResource(Resource r)`

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

Field Detail

### context

    Context context

  the user data Context that we are wrapping

### icb

    InternalHousekeepingContext icb

  the ICB we are wrapping. We may need to make one if the user data context implementation doesn't support one. The default AbstractContext-derived VelocityContext does, and it's recommended that people derive new contexts from AbstractContext rather than piecing things together

### iec

    InternalEventContext iec

  The InternalEventContext that we are wrapping. If the context passed to us doesn't support it, no biggie. We don't make it for them - since its a user context thing, nothing gained by making one for them now

Constructor Detail

### InternalContextAdapterImpl

    public InternalContextAdapterImpl(Context c)

  CTOR takes a Context and wraps it, delegating all 'data' calls to it. For support of internal contexts, it will create an InternalContextBase if need be.

Method Detail

### 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

### 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`

### put

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

  Description copied from interface: `Context`
  Adds a name/value pair to the context.

  Specified by:
    `put` in interface `Context`
  Parameters:
    `key` - The name to key the provided value with.
    `value` - The corresponding value.

### get

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

  Description copied from interface: `Context`
  Gets the value corresponding to the provided key from the context.

  Specified by:
    `get` in interface `Context`
  Parameters:
    `key` - The name of the desired value.
  Returns:
    The value corresponding to the provided key.

### containsKey

    public boolean containsKey(java.lang.Object key)

  Description copied from interface: `Context`
  Indicates whether the specified key is in the context.

  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()

  Description copied from interface: `Context`
  Get all the keys for the values in the context

  Specified by:
    `getKeys` in interface `Context`

### remove

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

  Description copied from interface: `Context`
  Removes the value associated with the specified key from the context.

  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.

### getInternalUserContext

    public Context getInternalUserContext()

  returns the user data context that we are wrapping

  Specified by:
    `getInternalUserContext` in interface `InternalWrapperContext`

### getBaseContext

    public InternalContextAdapter getBaseContext()

  Returns the base context that we are wrapping. Here, its this, but for other thing like VM related context contortions, it can be something else

  Specified by:
    `getBaseContext` in interface `InternalWrapperContext`

### attachEventCartridge

    public EventCartridge attachEventCartridge(EventCartridge ec)

  Specified by:
    `attachEventCartridge` in interface `InternalEventContext`

### getEventCartridge

    public EventCartridge getEventCartridge()

  Specified by:
    `getEventCartridge` in interface `InternalEventContext`

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.