public final static NewTask cloneTask( PlanningFactory factory, Task task, String[] prepositionsToExclude) { Enumeration enum = null; NewTask subtask = factory.newTask(); subtask.setContext( task.getContext()); subtask.setPlan( task.getPlan()); subtask.setParentTaskUID( task.getParentTaskUID()); subtask.setVerb( task.getVerb()); subtask.setDirectObject( task.getDirectObject()); subtask.setWorkflow( task.getWorkflow());  enum = task.getPrepositionalPhrases(); if ( enum != null) { Vector pPhrases = new Vector(); NewPrepositionalPhrase clonePhrase; while ( enum.hasMoreElements()) { PrepositionalPhrase pPhrase = (PrepositionalPhrase)enum.nextElement();   if ( prepositionsToExclude != null) { boolean skipPreposition = false; String preposition = pPhrase.getPreposition(); for ( int i = 0; i < prepositionsToExclude.length && !skipPreposition; i++) { String tmpPreposition = (String)prepositionsToExclude[ i]; if ( tmpPreposition != null && tmpPreposition.equals( preposition)) { skipPreposition = true; } } if ( skipPreposition) { continue; } }  clonePhrase = factory.newPrepositionalPhrase(); clonePhrase.setPreposition( pPhrase.getPreposition()); Object object = pPhrase.getIndirectObject(); if ( object instanceof Vector) { Vector orgVector = (Vector)object; Class vectorClass = object.getClass(); Vector newVector = null; try { newVector = (Vector)vectorClass.newInstance(); } catch ( Exception ex) { System.out.println( "PlanElements.cloneTask: unable to create newVector instance"); return null; } Enumeration tmpEnum = orgVector.elements(); while ( tmpEnum.hasMoreElements()) { newVector.add( tmpEnum.nextElement()); } clonePhrase.setIndirectObject( newVector); } else { clonePhrase.setIndirectObject( object); } pPhrases.addElement( clonePhrase); }
public final static NewTask cloneTask( PlanningFactory factory, Task task) { return cloneTask( factory, task, null); }
  public final static NewTask cloneTask( PlanningFactory factory, Task task, String[] prepositionsToExclude) {    Enumeration enum = null;    NewTask subtask = factory.newTask();    subtask.setContext( task.getContext());    subtask.setPlan( task.getPlan());    subtask.setParentTaskUID( task.getParentTaskUID());    subtask.setVerb( task.getVerb());    subtask.setDirectObject( task.getDirectObject());    subtask.setWorkflow( task.getWorkflow());    enum = task.getPrepositionalPhrases();    if ( enum != null) {      Vector pPhrases = new Vector();      NewPrepositionalPhrase clonePhrase;      while ( enum.hasMoreElements()) {        PrepositionalPhrase pPhrase = (PrepositionalPhrase)enum.nextElement();        // Don't include prepositional phrases in the new task that are listed in prepositionsToExclude.        if ( prepositionsToExclude != null) {          boolean skipPreposition = false;          String preposition = pPhrase.getPreposition();          for ( int i = 0; i < prepositionsToExclude.length && !skipPreposition; i++) {            String tmpPreposition = (String)prepositionsToExclude[ i];            if ( tmpPreposition != null && tmpPreposition.equals( preposition)) {              skipPreposition = true;            }          }          if ( skipPreposition) {            continue;          }        }        clonePhrase = factory.newPrepositionalPhrase();        clonePhrase.setPreposition( pPhrase.getPreposition());        Object object = pPhrase.getIndirectObject();        if ( object instanceof Vector) {          Vector orgVector = (Vector)object;          Class vectorClass = object.getClass();          Vector newVector = null;          try {            newVector = (Vector)vectorClass.newInstance();          } catch ( Exception ex) {            System.out.println( "PlanElements.cloneTask: unable to create newVector instance");            return null;          }          Enumeration tmpEnum = orgVector.elements();          while ( tmpEnum.hasMoreElements()) {            newVector.add( tmpEnum.nextElement());          }          clonePhrase.setIndirectObject( newVector);        } else {          clonePhrase.setIndirectObject( object);        }        pPhrases.addElement( clonePhrase);      }