/*
 * 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.dynamo.iface;

/**
 * An interface implemented by HTML Checker <EM>output filters</EM>, which process all characters prior to their being
 * placed in the output buffer.
 *
 * @author Eric J. Bowersox &lt;erbo@silcom.com&gt;
 * @version X
 */
public interface HTMLOutputFilter
{
  /**
   * Checks and possibly outputs a character.  If the character <EM>ch</EM> is handled by this filter, it appends
   * the encoded equivalent to the string buffer <EM>buf</EM> and returns <CODE>true</CODE>.  If not, it returns
   * <CODE>false</CODE> and leaves the buffer alone.
   *
   * @param buf The string buffer to append the character equivalent to.
   * @param ch The character to be checked and possibly output.
   * @return <CODE>true</CODE> if the character matches and was output, <CODE>false</CODE> if not.
   */
  public boolean tryOutputCharacter(StringBuffer buf, char ch);

  /**
   * Returns <CODE>true</CODE> if the character <EM>ch</EM> is handled by this filter, <CODE>false</CODE> if not.
   *
   * @param ch The character to be tested.
   * @return <CODE>true</CODE> if the character <EM>ch</EM> is handled by this filter, <CODE>false</CODE> if not.
   */
  public boolean matchCharacter(char ch);

  /**
   * Given a character string, returns the total number of characters in that string, starting from the beginning,
   * that are <I>not</I> handled by this filter before one that <I>is</I> appears.  If none of the characters in this
   * string are handled by the filter, the length of the string is returned.
   *
   * @param s The string to scan through.
   * @return The length of the initial sequence of non-matching characters in this string.
   */
  public int lengthNoMatch(String s);

} // end interface HTMLOutputFilter
