org.apache.cocoon.environment
Interface Environment

All Superinterfaces:
SourceResolver
All Known Implementing Classes:
AbstractEnvironment, EnvironmentWrapper

public interface Environment
extends SourceResolver

Base interface for an environment abstraction

Version:
CVS $Id: Environment.java,v 1.6.2.3 2002/08/04 04:11:52 vgritsenko Exp $
Author:
Giacomo Pati, Carsten Ziegeler

Method Summary
 void changeContext(java.lang.String uriprefix, java.lang.String context)
          Change the context from uriprefix to context
 java.lang.String getAction()
          Get the action to process
 java.lang.Object getAttribute(java.lang.String name)
          Returns the object bound with the specified name, or null if no object is bound under the name.
 java.util.Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
 java.lang.String getContentType()
          Get the content type of the resource
 java.net.URL getContext()
          Get current context
 java.util.Map getObjectModel()
          Get the underlying object model
 java.io.OutputStream getOutputStream()
          Get the output stream where to write the generated resource.
 java.net.URL getRootContext()
          Get the Root Context
 SourceHandler getSourceHandler()
          Get the SourceHandler for the current request
 java.lang.String getURI()
          Get the URI to process.
 java.lang.String getURIPrefix()
          Get the prefix of the URI in progress.
 java.lang.String getView()
          Get the view to process
 boolean isResponseModified(long lastModified)
          Check if the response has been modified since the same "resource" was requested.
 void redirect(boolean sessionmode, java.lang.String url)
          Redirect to the given URL
 void removeAttribute(java.lang.String name)
          Removes the object bound with the specified name from this environment.
 void setAttribute(java.lang.String name, java.lang.Object value)
          Binds an object to this environment, using the name specified.
 void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
          Set the ComponentManager for the current request.
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(java.lang.String mimeType)
          Set the content type of the generated resource
 void setContext(java.lang.String prefix, java.lang.String uri)
          Set the context.
 void setResponseIsNotModified()
          Mark the response as not modified.
 void setSourceHandler(SourceHandler sourceHandler)
          Set the SourceHandler for the current request
 void setStatus(int statusCode)
          Set the response status code
 boolean tryResetResponse()
          Reset the response if possible.
 
Methods inherited from interface org.apache.cocoon.environment.SourceResolver
resolve
 

Method Detail

getSourceHandler

public SourceHandler getSourceHandler()
Get the SourceHandler for the current request

setSourceHandler

public void setSourceHandler(SourceHandler sourceHandler)
Set the SourceHandler for the current request

getURI

public java.lang.String getURI()
Get the URI to process. The prefix is stripped off.

getURIPrefix

public java.lang.String getURIPrefix()
Get the prefix of the URI in progress.

getRootContext

public java.net.URL getRootContext()
Get the Root Context

getContext

public java.net.URL getContext()
Get current context

getView

public java.lang.String getView()
Get the view to process

getAction

public java.lang.String getAction()
Get the action to process

setContext

public void setContext(java.lang.String prefix,
                       java.lang.String uri)
Set the context. This is similar to changeContext() except that it is absolute.

changeContext

public void changeContext(java.lang.String uriprefix,
                          java.lang.String context)
                   throws java.lang.Exception
Change the context from uriprefix to context

redirect

public void redirect(boolean sessionmode,
                     java.lang.String url)
              throws java.io.IOException
Redirect to the given URL

setContentType

public void setContentType(java.lang.String mimeType)
Set the content type of the generated resource

getContentType

public java.lang.String getContentType()
Get the content type of the resource

setContentLength

public void setContentLength(int length)
Set the length of the generated content

setStatus

public void setStatus(int statusCode)
Set the response status code

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Get the output stream where to write the generated resource.

getObjectModel

public java.util.Map getObjectModel()
Get the underlying object model

isResponseModified

public boolean isResponseModified(long lastModified)
Check if the response has been modified since the same "resource" was requested. The caller has to test if it is really the same "resource" which is requested.
Returns:
true if the response is modified or if the environment is not able to test it

setComponentManager

public void setComponentManager(org.apache.avalon.framework.component.ComponentManager manager)
Set the ComponentManager for the current request.

setResponseIsNotModified

public void setResponseIsNotModified()
Mark the response as not modified.

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
Binds an object to this environment, using the name specified. This allows the pipeline assembly engine to store for its own use objects that souldn't be exposed to other components (generators, selectors, etc) and therefore cannot be put in the object model.

If an object of the same name is already bound, the object is replaced.

Parameters:
name - the name to which the object is bound
value - the object to be bound

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Returns the object bound with the specified name, or null if no object is bound under the name.
Parameters:
name - a string specifying the name of the object
Returns:
the object with the specified name

removeAttribute

public void removeAttribute(java.lang.String name)
Removes the object bound with the specified name from this environment. If the environment does not have an object bound with the specified name, this method does nothing.
Parameters:
name - the name of the object to remove

getAttributeNames

public java.util.Enumeration getAttributeNames()
Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
Returns:
an Enumeration of Strings.

tryResetResponse

public boolean tryResetResponse()
Reset the response if possible. This allows error handlers to have a higher chance to produce clean output if the pipeline that raised the error has already output some data.
Returns:
true if the response was successfully reset


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