PrepositionalPhrase prepItinerary = task.getPrepositionalPhrase(Constants.Preposition.ITINERARYOF);
  protected static void addLegsAlloc(      MyPSPState myState,      List toLegsList,       Allocation alloc) {    // create template leg    UITaskItineraryElement leg;    try {      leg = createUITaskItineraryElement(myState, alloc);    } catch (RuntimeException badAlloc) {      leg = null;    }    if (leg == null) {      // leg was still being calculated or broken.  silently ignore it.      if (DEBUG) {        System.out.println("Ignore leg for alloc: "+          alloc.getUID().getUID());      }      return;    }    Task task = alloc.getTask();    // check for simple case    if (!myState.interpolate && !myState.includeUnload) {      // build non-interpolated leg from task      if (setElementSchedule(leg, task, false, false)) {        toLegsList.add(leg);      }      return;    }    // look for itinerary info.    // currently we're only interested in transit and unload    ItineraryElement transIE = null;    ItineraryElement unloadIE = null;    ItineraryElement loadIE = null;    // look in preposition    PrepositionalPhrase prepItinerary =      task.getPrepositionalPhrase(Constants.Preposition.ITINERARYOF);    // If tasks ever get marked for indirect, but the check in here    // Check the task for the indirect intinerary Preposition    boolean isDefinitelyNotDirect = false;    // IF tasks ever get marked for overlap, put the check in here    // Tasks that have passed our filter, and have verb of supply    // get marked as overlap    boolean isDefinitelyOverlap =  false;      if (prepItinerary != null) {      Object itinIndObj = prepItinerary.getIndirectObject();      if (itinIndObj instanceof Schedule) {        // will use itinerary and task route for interpolation        // make sure that schedElems includes both Transit and Load        Enumeration schedElems =            ((Schedule)itinIndObj).getAllScheduleElements();	// check if it's an air itinerary, in which case, we probably want	// all the legs	List elems = new ArrayList ();        while (schedElems.hasMoreElements())	  elems.add(schedElems.nextElement());		       if (elems.size () > 2) {	  for (int i = 0; i < elems.size (); i++) {	    ItineraryElement ie = (ItineraryElement) elems.get(i);	    Verb v = ie.getRole();	    addLegFromItineraryElement(toLegsList, leg.copy(), ie, 				       isDefinitelyNotDirect,				       isDefinitelyOverlap);	  }	  return;	}	       while (schedElems.hasMoreElements()) {	   ItineraryElement ie = 	       (ItineraryElement)schedElems.nextElement();	   Verb v = ie.getRole();	   if ((Constants.Verb.Load).equals(v)) {	       loadIE = ie;	   } else if ((Constants.Verb.Transit).equals(v)) {	       if (myState.interpolate) {		   transIE = ie;	       }	   } else if ((Constants.Verb.Unload).equals(v)) {	       if (myState.includeUnload) {		   unloadIE = ie;	       }	   }       }      }    }    boolean needsOverallLeg = true;    if (unloadIE != null) {	// add an unload leg	System.out.println("Adding unload leg");	if (addLegFromItineraryElement(toLegsList, leg.copy(), 				       unloadIE, isDefinitelyNotDirect,				       isDefinitelyOverlap)) {	    // still want the overall leg	    System.out.println("Added unload leg");	} else {	    // couldn't add the unload.  at least take the overall leg	}    }    if (transIE != null) {	if (loadIE != null) {	    if (addLegsInterpolate(toLegsList, leg, task, transIE,				   isDefinitelyNotDirect,				   isDefinitelyOverlap)) {		// added interpolated legs.  don't add the overall leg,		// partially because the interpolate stole it.		needsOverallLeg = false;		System.out.println("added interpolated leg");	    } else {		// couldn't interpolate.  at least take the overall leg	    }	} else {	    // lacks a load, so transit is ignored!	    System.err.println("PSP_Itinerary: TRANSIT but no LOAD for task: "+			       task.getUID().getUID());	}    }    if (needsOverallLeg) {	// add the overall leg	if (setElementSchedule(leg, task, isDefinitelyNotDirect,			       isDefinitelyOverlap)) {	    //System.out.println(leg);	    toLegsList.add(leg);	    //System.out.println("Adding overall leg");	} else {	    // overall is bad?	}    }        }