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

// $Id: Before.java,v 1.2 2003/03/06 00:40:49 moltmans Exp $
// Before.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Fri Jul 21 00:53:27 2000> 
// Time-stamp: <2000-07-21 01:02:12 moltmans> 
package rec.annotate.facts;

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

public class Before extends Annotation
{
  private Event m_event1;
  private Event m_event2;
  
  public Before( Event e1, Event e2 )
  {
    super( Math.min( e1.getStartTime(), e2.getStartTime() ),
	   Math.max( e1.getEndTime(), e2.getEndTime() ) );
    m_event1 = e1;
    m_event2 = e2;
  }

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

  public Event getEvent1() 
  {
    return m_event1;
  }

  public Event getEvent2() 
  {
    return m_event2;
  }
  
  public boolean sameFact( Fact fact ) 
  {
    if( fact instanceof Before ) {
      Before b = (Before)fact;
      return ( m_event1.sameFact( b.m_event1 ) &&
	       m_event2.sameFact( b.m_event2 ) );
    }
    return false;
  }

  public String toEnglish() 
  {
    return ( m_event1.toEnglish() + " is before " +
	     m_event2.toEnglish() );
  }

  public String toString() 
  {
    return "<before: [" + m_event1 + "] [" + m_event2 + "]>";
  }
}
