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

import java.util.*;
import com.silverwrist.dynamo.velocity.VelocityOwnTemplate;
import com.silverwrist.venice.iface.ContentBlock;

public class StringTemplateContentBlock implements VelocityOwnTemplate, ContentBlock
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private String m_mime_type;
  private String m_template;
  private String m_identifier;
  private HashMap m_params = new HashMap();

  /*--------------------------------------------------------------------------------
   * Constructors
   *--------------------------------------------------------------------------------
   */

  public StringTemplateContentBlock(String template, String identifier, String mime_type)
  {
    m_mime_type = mime_type;
    m_template = template;
    m_identifier = identifier;

  } // end constructor

  public StringTemplateContentBlock(String template, String identifier)
  {
    this(template,identifier,"text/html");

  } // end constructor

  public StringTemplateContentBlock(String template)
  {
    this(template,"StringTemplateContentBlock","text/html");

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Overrides from class Object
   *--------------------------------------------------------------------------------
   */

  public String toString()
  {
    return m_template;

  } // end toString

  /*--------------------------------------------------------------------------------
   * Implementations from interface VelocityParamSupplier
   *--------------------------------------------------------------------------------
   */

  public Object getParameter(String key)
  {
    return m_params.get(key);

  } // end getParameter

  public Collection getParameterNames()
  {
    return Collections.unmodifiableSet(m_params.keySet());

  } // end getParameterNames

  /*--------------------------------------------------------------------------------
   * Implementations from interface VelocityOwnTemplate
   *--------------------------------------------------------------------------------
   */

  public String getMimeType()
  {
    return m_mime_type;

  } // end getMimeType

  public String getTemplate()
  {
    return m_template;

  } // end getTemplate

  public String getIdentifier()
  {
    return m_identifier;

  } // end getIdentifier

  /*--------------------------------------------------------------------------------
   * Implementations from interface ContentBlock
   *--------------------------------------------------------------------------------
   */

  public void setContentParameter(String name, Object obj)
  {
    m_params.put(name,obj);

  } // end setContentParameter

} // end class StringTemplateContentBlock
