/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Communities System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2002-03 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.dynamo.iface;

import java.io.IOException;
import com.silverwrist.dynamo.HttpStatusCode;
import com.silverwrist.dynamo.except.RenderingException;

/**
 * The interface implemented by the rendering control object used by
 * {@link com.silverwrist.dynamo.iface.SelfRenderable SelfRenderable} objects.<P>
 * Note that this interface, unlike the other rendering control interfaces, does not extend
 * {@link com.silverwrist.dynamo.iface.RenderControl RenderControl}; however, its
 * {@link #getTextRender() getTextRender()} and {@link #getBinaryRender() getBinaryRender()} methods return objects
 * that do.
 *
 * @author Eric J. Bowersox &lt;erbo@silcom.com&gt;
 * @version X
 */
public interface SelfRenderControl extends ServiceProvider
{
  /**
   * Sends an HTTP status code to the browser.  This may be combined with other output methods to write a specific
   * message.
   *
   * @param code The status code to be sent to the browser.
   * @exception java.io.IOException If there was an I/O error sending the status code.
   * @exception com.silverwrist.dynamo.except.RenderingException If there was another error sending the status code
   *            (for example, if the code has already been set).
   */
  public void status(HttpStatusCode code) throws RenderingException;

  /**
   * Causes the browser to redirect to another URL.  Sends a "302 Redirect" status code to the browser.
   *
   * @param location URL to redirect the browser to.
   * @exception java.io.IOException If there was an I/O error sending the redirect.
   * @exception com.silverwrist.dynamo.except.RenderingException If there was another error sending the redirect
   *            (for example, if text has already been written).
   */
  public void redirect(String location) throws IOException, RenderingException;

  /**
   * Sends an HTTP error message to the browser.
   *
   * @param code The status code to be sent to the browser.
   * @exception java.io.IOException If there was an I/O error sending the error message.
   * @exception com.silverwrist.dynamo.except.RenderingException If there was another error sending the error message
   *            (for example, if text has already been written).
   */
  public void error(HttpStatusCode code) throws IOException, RenderingException;

  /**
   * Sends an HTTP error message to the browser.
   *
   * @param code The status code to be sent to the browser.
   * @param message The error message to be sent to the browser.
   * @exception java.io.IOException If there was an I/O error sending the error message.
   * @exception com.silverwrist.dynamo.except.RenderingException If there was another error sending the error message
   *            (for example, if text has already been written).
   */
  public void error(HttpStatusCode code, String message) throws IOException, RenderingException;

  /**
   * Returns a rendering control interface suitable for rendering an object in text mode.
   *
   * @return An instance of {@link com.silverwrist.dynamo.iface.TextRenderControl TextRenderControl}.
   * @exception com.silverwrist.dynamo.except.RenderingException If the text rendering interface cannot be returned
   *            (for instance, if this object is already rendering in binary mode).
   */
  public TextRenderControl getTextRender() throws RenderingException;

  /**
   * Returns a rendering control interface suitable for rendering an object in binary mode.
   *
   * @return An instance of {@link com.silverwrist.dynamo.iface.BinaryRenderControl BinaryRenderControl}.
   * @exception com.silverwrist.dynamo.except.RenderingException If the binary rendering interface cannot be returned
   *            (for instance, if this object is already rendering in text mode).
   */
  public BinaryRenderControl getBinaryRender() throws RenderingException;

} // end interface SelfRenderControl
