/*
 * 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) 2003 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.sidebox.test;

import com.silverwrist.dynamo.except.*;
import com.silverwrist.dynamo.iface.*;
import com.silverwrist.venice.content.*;
import com.silverwrist.venice.iface.*;

public class TestSideboxes implements SideboxTypeFactory
{
  /*--------------------------------------------------------------------------------
   * Internal class for sidebox factory
   *--------------------------------------------------------------------------------
   */

  private static class TestFactory implements SideboxFactory
  {
    /*====================================================================
     * Attributes
     *====================================================================
     */

    private String m_title;
    private String m_body;

    /*====================================================================
     * Constructor
     *====================================================================
     */

    TestFactory(String title, String body)
    {
      m_title = title;
      m_body = body;

    } // end constructor

    /*====================================================================
     * Implementations from interface SideboxFactory
     *====================================================================
     */

    public Sidebox createSidebox(Request req)
    {
      return new StringSidebox(m_body,m_title);

    } // end createSidebox

  } // end class TestFactory

  /*--------------------------------------------------------------------------------
   * Static data members
   *--------------------------------------------------------------------------------
   */

  public static final String NAMESPACE = "http://www.silverwrist.com/NS/venice/2003/05/31/test.sideboxes";

  /*--------------------------------------------------------------------------------
   * Constructor
   *--------------------------------------------------------------------------------
   */

  public TestSideboxes()
  { // do nothing
  } // end constructor

  /*--------------------------------------------------------------------------------
   * Implementations from interface SideboxTypeFactory
   *--------------------------------------------------------------------------------
   */

  public SideboxFactory createFactory(String type_namespace, String type_name, String box_namespace, String box_name,
				      ObjectProvider properties) throws DynamoException
  {
    if (box_name.equals("test1"))
      return new TestFactory("Number One","The quick brown fox jumped over the lazy dog.");
    else if (box_name.equals("test2"))
      return new TestFactory("List Test","<ul><li>First</li><li>Second</li><li>Third</li></ul>");
    else
      throw new DynamoException("invalid sidebox");

  } // end createFactory

} // end class TestSideboxes
