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

class SimpleTag
{
  /*--------------------------------------------------------------------------------
   * Attributes
   *--------------------------------------------------------------------------------
   */

  private String tagname;         // the name of the tag
  private boolean linebreak;      // does tag cause line breaks?
  private int index;              // index of the tag

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

  SimpleTag(String name, boolean brk)
  {
    tagname = name.toUpperCase();
    linebreak = brk;
    index = -1;

  } // end constructor

  /*--------------------------------------------------------------------------------
   * Operations usable only within the package
   *--------------------------------------------------------------------------------
   */

  final void setIndex(int ndx)
  {
    if (index==-1)
      index = ndx;

  } // end setIndex

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public String getTagName()
  {
    return tagname;

  } // end getTagName

  public boolean allowClose()
  {
    return false;

  } // end allowClose

  public boolean balanceTags()
  {
    return false;

  } // end balanceTags

  public boolean causeLineBreak(boolean is_closing)
  {
    return linebreak;

  } // end causeLineBreak

  public final int getIndex()
  {
    return index;

  } // end getIndex

  public String makeClosingTag()
  {
    throw new RuntimeException("cannot make closing tags of SimpleTag");

  } // end makeClosingTag

  public String rewriteTagContents(String contents, boolean is_closing, HTMLCheckerBackend context)
  {
    return contents;  // just let everything pass for now

  } // end rewriteTagContents

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

  public boolean equals(Object obj)
  {
    if (!(obj instanceof SimpleTag))
      return false;
    SimpleTag other = (SimpleTag)obj;
    return tagname.equals(other.tagname);

  } // end equals

  public int hashCode()
  {
    return tagname.hashCode();

  } // end hashCode

} // end class SimpleTag

