org.apache.cocoon.environment.wrapper
Class EnvironmentWrapper

java.lang.Object
  |
  +--org.apache.avalon.framework.logger.AbstractLoggable
        |
        +--org.apache.cocoon.environment.AbstractEnvironment
              |
              +--org.apache.cocoon.environment.wrapper.EnvironmentWrapper
All Implemented Interfaces:
Environment, org.apache.avalon.framework.logger.Loggable, SourceResolver

public class EnvironmentWrapper
extends AbstractEnvironment
implements Environment

This is a wrapper class for the Environment object. It has the same properties except that the object model contains a RequestWrapper object.

Version:
$Id: EnvironmentWrapper.java,v 1.11.2.4 2002/12/06 08:02:09 cziegeler Exp $
Author:
Carsten Ziegeler

Field Summary
protected  Environment environment
          The wrapped environment
protected  java.net.URL lastContext
          The last context
protected  java.lang.String lastPrefix
          The last prefix
protected  java.lang.String lastURI
          The last uri
protected  java.util.Map objectModel
          The object model
protected  java.io.OutputStream outputStream
          The stream to output to
protected  Processor processor
          The processor used
protected  java.lang.String redirectURL
          The redirect url
protected  Request request
          The request object
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, context, manager, prefix, rootContext, sourceHandler, uris, view
 
Constructor Summary
EnvironmentWrapper(Environment env, java.lang.String requestURI, java.lang.String queryString, org.apache.log.Logger logger)
          Constructs an EnvironmentWrapper object from a Request and Response objects
EnvironmentWrapper(Environment env, java.lang.String requestURI, java.lang.String queryString, org.apache.log.Logger logger, boolean rawMode)
          Constructs an EnvironmentWrapper object from a Request and Response objects
 
Method Summary
 void changeContext(java.lang.String prefix, java.lang.String context)
          Change the context from uriprefix to context
 Processor changeToLastContext()
          Change the current context to the last one set by changeContext() and return last processor.
 java.lang.Object getAttribute(java.lang.String name)
          Lookup an attribute in this instance, and if not found search it in the wrapped environment.
 java.lang.String getContentType()
          Get the ContentType
 java.util.Map getObjectModel()
          Get the underlying object model
 java.io.OutputStream getOutputStream()
          Get the output stream
 java.lang.String getRedirectURL()
          if a redirect should happen this returns the url, otherwise null is returned
 void globalRedirect(boolean sessionmode, java.lang.String newURL)
          Redirect in the first non-wrapped environment
 void redirect(boolean sessionmode, java.lang.String newURL)
          Redirect the client to a new URL is not allowed
 void removeAttribute(java.lang.String name)
          Remove attribute from the current instance, as well as from the wrapped environment.
 void reset()
           
 void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
          The sitemap processor sets up new managers per sitemap.
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(java.lang.String contentType)
          Set the ContentType
 void setOutputStream(java.io.OutputStream stream)
          Set the output stream for this environment.
 void setStatus(int statusCode)
          Set the StatusCode
 void setURI(java.lang.String prefix, java.lang.String uris)
          Set a new URI for processing.
 
Methods inherited from class org.apache.cocoon.environment.AbstractEnvironment
getAction, getAttributeNames, getComponentManager, getContext, getRootContext, getSourceHandler, getURI, getURIPrefix, getView, isResponseModified, resolve, setAttribute, setContext, setContext, setResponseIsNotModified, setSourceHandler, setURIPrefix, tryResetResponse
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLoggable
getLogger, setLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.cocoon.environment.Environment
getAction, getAttributeNames, getContext, getRootContext, getSourceHandler, getURI, getURIPrefix, getView, isResponseModified, setAttribute, setContext, setResponseIsNotModified, setSourceHandler, tryResetResponse
 
Methods inherited from interface org.apache.cocoon.environment.SourceResolver
resolve
 

Field Detail

environment

protected Environment environment
The wrapped environment

objectModel

protected java.util.Map objectModel
The object model

redirectURL

protected java.lang.String redirectURL
The redirect url

request

protected Request request
The request object

lastContext

protected java.net.URL lastContext
The last context

lastPrefix

protected java.lang.String lastPrefix
The last prefix

lastURI

protected java.lang.String lastURI
The last uri

outputStream

protected java.io.OutputStream outputStream
The stream to output to

processor

protected Processor processor
The processor used
Constructor Detail

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          java.lang.String requestURI,
                          java.lang.String queryString,
                          org.apache.log.Logger logger)
                   throws java.net.MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects

EnvironmentWrapper

public EnvironmentWrapper(Environment env,
                          java.lang.String requestURI,
                          java.lang.String queryString,
                          org.apache.log.Logger logger,
                          boolean rawMode)
                   throws java.net.MalformedURLException
Constructs an EnvironmentWrapper object from a Request and Response objects
Method Detail

redirect

public void redirect(boolean sessionmode,
                     java.lang.String newURL)
              throws java.io.IOException
Redirect the client to a new URL is not allowed
Specified by:
redirect in interface Environment
Overrides:
redirect in class AbstractEnvironment

globalRedirect

public void globalRedirect(boolean sessionmode,
                           java.lang.String newURL)
                    throws java.io.IOException
Redirect in the first non-wrapped environment
Overrides:
globalRedirect in class AbstractEnvironment

setComponentManager

public void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
The sitemap processor sets up new managers per sitemap. Set the "current" one for this environment.
Specified by:
setComponentManager in interface Environment
Overrides:
setComponentManager in class AbstractEnvironment

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get the output stream
Specified by:
getOutputStream in interface Environment

setOutputStream

public void setOutputStream(java.io.OutputStream stream)
Set the output stream for this environment. It hides the one of the wrapped environment.

getRedirectURL

public java.lang.String getRedirectURL()
if a redirect should happen this returns the url, otherwise null is returned

reset

public void reset()

setStatus

public void setStatus(int statusCode)
Set the StatusCode
Specified by:
setStatus in interface Environment
Overrides:
setStatus in class AbstractEnvironment

setContentLength

public void setContentLength(int length)
Description copied from interface: Environment
Set the length of the generated content
Specified by:
setContentLength in interface Environment

setContentType

public void setContentType(java.lang.String contentType)
Set the ContentType
Specified by:
setContentType in interface Environment

getContentType

public java.lang.String getContentType()
Get the ContentType
Specified by:
getContentType in interface Environment

getObjectModel

public java.util.Map getObjectModel()
Get the underlying object model
Specified by:
getObjectModel in interface Environment
Overrides:
getObjectModel in class AbstractEnvironment

setURI

public void setURI(java.lang.String prefix,
                   java.lang.String uris)
Set a new URI for processing. If the prefix is null the new URI is inside the current context. If the prefix is not null the context is changed to the root context and the prefix is set.

changeContext

public void changeContext(java.lang.String prefix,
                          java.lang.String context)
                   throws java.net.MalformedURLException
Description copied from interface: Environment
Change the context from uriprefix to context
Specified by:
changeContext in interface Environment
Overrides:
changeContext in class AbstractEnvironment

changeToLastContext

public Processor changeToLastContext()
Change the current context to the last one set by changeContext() and return last processor.

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Lookup an attribute in this instance, and if not found search it in the wrapped environment.
Specified by:
getAttribute in interface Environment
Overrides:
getAttribute in class AbstractEnvironment
Parameters:
name - a String, the name of the attribute to look for
Returns:
an Object, the value of the attribute or null if no such attribute was found.

removeAttribute

public void removeAttribute(java.lang.String name)
Remove attribute from the current instance, as well as from the wrapped environment.
Specified by:
removeAttribute in interface Environment
Overrides:
removeAttribute in class AbstractEnvironment
Parameters:
name - a String value


Copyright © 1999-2002 Apache Software Foundation. All Rights Reserved.