1 package hudson.scheduler; 2 3 import antlr.ANTLRException; 4 5 import java.util.Calendar ; 6 import java.util.Collection ; 7 import java.util.Vector ; 8 9 14 public final class CronTabList { 15 private final Vector <CronTab> tabs; 16 17 public CronTabList(Collection <CronTab> tabs) { 18 this.tabs = new Vector <CronTab>(tabs); 19 } 20 21 public synchronized boolean check(Calendar cal) { 22 for (CronTab tab : tabs) { 23 if(tab.check(cal)) 24 return true; 25 } 26 return false; 27 } 28 29 public static CronTabList create(String format) throws ANTLRException { 30 Vector <CronTab> r = new Vector <CronTab>(); 31 int lineNumber = 0; 32 for (String line : format.split("\\r?\\n")) { 33 lineNumber++; 34 line = line.trim(); 35 if(line.length()==0 || line.startsWith("#")) 36 continue; try { 38 r.add(new CronTab(line,lineNumber)); 39 } catch (ANTLRException e) { 40 throw new ANTLRException("Invalid input: \""+line+"\": "+e.toString(),e); 41 } 42 } 43 return new CronTabList(r); 44 } 45 } 46 | Popular Tags |