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

// -*-Mode: Java-*- 
// $Id: LeadsTo.java,v 1.3 2003/03/06 00:40:49 moltmans Exp $
// LeadsTo.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Mon May 08 15:11:34 2000> 
// Time-stamp: <2000-07-19 16:46:05 moltmans> 
package rec.annotate.facts;

import rec.annotate.rules.*;
import rec.tms.*;
import rec.annotate.*;

/**
 * When it is ambiguous whether one event causes or allows another to
 * occur.  We stil want to record the fact that we have some evidence
 * that the two events are correlated...
 **/
public class LeadsTo extends Annotation
{
  protected Event m_cause;
  protected Event m_effect;

  public LeadsTo( Event cause, Event effect )
  {
    super( Math.min( cause.getStartTime(), effect.getStartTime() ),
	   Math.max( cause.getEndTime(), effect.getEndTime() ) );
    m_cause = cause;
    m_effect = effect;
  }

  public String getFactType() 
  {
    return Type.LEADS_TO;
  }

  public Event getCause() 
  {
    return m_cause;
  }

  public Event getEffect() 
  {
    return m_effect;
  }
  
  public boolean sameFact( Fact fact ) 
  {
    if( fact instanceof LeadsTo ) {
      LeadsTo f = (LeadsTo)fact;
      return ( m_cause.sameFact( f.m_cause ) &&
	       m_effect.sameFact( f.m_effect ) );
    }
    return false;
  }

  public String toEnglish() 
  {
    return m_cause.toEnglish() + " leads to " + m_effect.toEnglish();
  }
  

  public String toString() 
  {
    return "<leads-to: [" + m_cause + "] [" + m_effect + "]>";
  }
}
