1 23 package org.enhydra.kelp.common; 24 25 import org.enhydra.kelp.common.Constants; 27 import org.enhydra.kelp.common.ProgressBuilder; 28 import org.enhydra.kelp.common.node.OtterFileNode; 29 import org.enhydra.kelp.common.node.OtterProject; 30 import org.enhydra.kelp.common.event.WriteListener; 31 32 import java.io.PrintWriter ; 34 import java.io.File ; 35 import java.util.StringTokenizer ; 36 37 42 abstract public class AbstractNodeBuilder extends AbstractEchoBuilder { 43 private OtterFileNode[] nodes = null; 44 45 55 public AbstractNodeBuilder(WriteListener[] listeners) { 56 super(); 57 for (int i = 0; i < listeners.length; i++) { 58 addWriteListener(listeners[i]); 59 } 60 } 61 62 public AbstractNodeBuilder(WriteListener listener, boolean buffer) { 63 super(listener, buffer); 64 } 65 66 67 71 abstract public void printResults(); 72 73 76 public OtterFileNode[] getNodes() { 77 return nodes; 78 } 79 80 83 public void setNodes(OtterFileNode[] n) { 84 nodes = n; 85 } 86 87 public void printExceptions() { 88 StringTokenizer tokenizer = null; 89 int eCount = 0; 90 int totalCount = getNodes().length; 91 92 for (int i = 0; i < totalCount; i++) { 93 if (getNodes()[i].isSelected() 94 && getNodes()[i].getException() != null) { 95 eCount++; 96 } 97 } 98 if (eCount > 0) { 99 getEchoWriter().println(new String ()); 100 getEchoWriter().println("Exception encountered:"); 101 for (int i = 0; i < totalCount; i++) { 102 if (getNodes()[i].getException() != null) { 103 getEchoWriter().print(Constants.TAB4); 104 getEchoWriter().print(getNodes()[i].getFilePath()); 105 getEchoWriter().println(':'); 106 tokenizer = 107 new StringTokenizer (getNodes()[i].getException().getMessage(), 108 Constants.NEWLINE); 109 while (tokenizer.hasMoreTokens()) { 110 getEchoWriter().println(tokenizer.nextToken()); 111 } 112 } 113 } 114 } 115 } 116 117 124 public void sleepInSeconds(double seconds) { 125 try { 126 Thread.sleep((int) (seconds * 1000)); 127 } catch (InterruptedException e) {} 128 } 129 130 } 131 | Popular Tags |