// (c) MIT 2003.  All rights reserved.

// -*-Mode: Java-*- 
// $Id: WUtterance.java,v 1.16 2003/03/06 00:40:39 moltmans Exp $
// WUtterance.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Tue Aug  3 15:40:17 1999> 
// Time-stamp: <2000-07-20 20:54:29 moltmans> 

package rec.sys;

import java.util.*;
import java.awt.*;
import rec.sys.*;
import rec.geo.*;
import rec.util.*;
import rec.speech.*;

/**
 * This class is the super class of all utterances.  We want to
 * distinguish the utterance types since sometimes we might want to
 * treat text and speech differently but sometimes we are only
 * interested in the semantic content of the utterance.
 **/
public abstract class WUtterance extends Widget
{
  protected Tag m_tags;
  protected long m_startTime;
  protected long m_endTime;

  /**
   * Don't create a WUtterance create one of its subclasses
   **/
  protected WUtterance( Tag tags )
  {
    m_tags = new Tag( tags );
    m_startTime = tags.getStartTime();
    m_endTime = tags.getEndTime();
  }

  public Tag getTags( )
  {
    return m_tags;
  }

  public Tag getTag( String tag ) 
  {
    return m_tags.getTag( tag ) ;
  }

  public boolean hasTag( String tag ) 
  {
    return m_tags.hasTag( tag );
  }

  public String getText() 
  {
    return m_tags.getText();
  }

  // note these are not the same as get time which is the time when
  // the widget was created...  these represent the actual time
  // spanned by the utterance
  
  public long getStartTime()
  {
    return m_startTime;
  }
  public long getEndTime()
  {
    return m_endTime;
  }
  

  public String getTextForTag( String tag )
  {
    return (String)m_tags.getText( tag );
  }
  

  public Object clone()
  {
    WUtterance clone = (WUtterance)super.clone();
    clone.m_tags = new Tag( m_tags );
    return clone;
  }

  public void makeDefaultSuitcase( Surface s )
  {
    // Only really want to do this for commands
    //    addToSuitcase( new DieTransition( s, this ) );
    DebugWindow.addLine( "Problems",
			 "Why are you electing an Utterance: " +
			 m_tags.getText() );
  }

  /**
   * Since we use wutterances but recognizers need to know the most
   * specific class...
   **/
  public static Iterator getUtteranceTypes() 
  {
    Vector v = new Vector();

    v.addElement( "rec.sys.WUtterance" );
    v.addElement( "rec.sys.WTextUtterance" );
    v.addElement( "rec.sys.WSpeechUtterance" );

    return( v.iterator() );
  }
  

    
}
