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.1 2002/04/21 17:36:05 vgritsenko Exp $
Author:
Carsten Ziegeler

Field Summary
protected  Environment environment
          The wrapped environment
 
Fields inherited from class org.apache.cocoon.environment.AbstractEnvironment
action, context, objectModel, 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
 void changeToLastContext()
          Change the current context to the last one set by changeContext()
 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 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, 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
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

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 void changeToLastContext()
Change the current context to the last one set by changeContext()

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.