org.apache.cocoon.environment
Interface Environment


public interface Environment

Base interface for an environment abstraction

Version:
$Id: Environment.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Method Summary
 void commitResponse()
          Commit the response
 void finishingProcessing()
          Notify that the processing is finished This can be used to cleanup the environment object
 String getAction()
          Get the action to process
 Object getAttribute(String name)
          Returns the object bound with the specified name, or null if no object is bound under the name.
 Enumeration getAttributeNames()
          Returns an Enumeration of String objects containing the names of all the objects bound to this environment.
 String getContentType()
          Get the content type of the resource
 Map getObjectModel()
          Get the underlying object model
 OutputStream getOutputStream(int bufferSize)
          Get the output stream where to write the generated resource.
 String getURI()
          Get the URI to process.
 String getURIPrefix()
          Get the prefix of the URI in progress.
 String getView()
          Get the view to process
 boolean isExternal()
          Is this environment external ? An external environment is one that is created in response to an external request (http, commandline, etc.).
 boolean isInternalRedirect()
          Is this an internal redirect? An environment is on internal redirect if it is an internal request (via the cocoon: protocol) and used for a redirect.
 boolean isResponseModified(long lastModified)
          Check if the response has been modified since the same "resource" was requested.
 void redirect(String url, boolean global, boolean permanent)
          Redirect the client to the given URL
 void removeAttribute(String name)
          Removes the object bound with the specified name from this environment.
 void setAttribute(String name, Object value)
          Binds an object to this environment, using the name specified.
 void setContentLength(int length)
          Set the length of the generated content
 void setContentType(String mimeType)
          Set the content type of the generated resource
 void setResponseIsNotModified()
          Mark the response as not modified.
 void setStatus(int statusCode)
          Set the response status code
 void setURI(String prefix, String value)
          Set the URI and the prefix to process.
 void startingProcessing()
          Notify that the processing starts.
 boolean tryResetResponse()
          Reset the response if possible.
 

Method Detail

getURI

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


getURIPrefix

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


setURI

public void setURI(String prefix,
                   String value)
Set the URI and the prefix to process.


getView

public String getView()
Get the view to process


getAction

public String getAction()
Get the action to process


redirect

public void redirect(String url,
                     boolean global,
                     boolean permanent)
              throws IOException
Redirect the client to the given URL

Throws:
IOException

setContentType

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


getContentType

public 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 OutputStream getOutputStream(int bufferSize)
                             throws IOException
Get the output stream where to write the generated resource. The returned stream is buffered by the environment. If the buffer size is -1 then the complete output is buffered. If the buffer size is 0, no buffering takes place.

Throws:
IOException

getObjectModel

public 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

setResponseIsNotModified

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


setAttribute

public void setAttribute(String name,
                         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 Object getAttribute(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(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 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()
                         throws IOException
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. If a buffered output stream is used, resetting is always successful.

Returns:
true if the response was successfully reset
Throws:
IOException

commitResponse

public void commitResponse()
                    throws IOException
Commit the response

Throws:
IOException

startingProcessing

public void startingProcessing()
Notify that the processing starts.


finishingProcessing

public void finishingProcessing()
Notify that the processing is finished This can be used to cleanup the environment object


isExternal

public boolean isExternal()
Is this environment external ? An external environment is one that is created in response to an external request (http, commandline, etc.). Environments created by the "cocoon:" protocol aren't external.

Returns:
true if this environment is external

isInternalRedirect

public boolean isInternalRedirect()
Is this an internal redirect? An environment is on internal redirect if it is an internal request (via the cocoon: protocol) and used for a redirect.



Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.