📄 crontabentrybean.java
字号:
*/ public String[] getExtraInfo(){ return extraInfo; } /** Hours getter * @return the hours of this CrontabBean */ public String getHours(){ return hours; } /** Minutes getter * @return the minutes of this CrontabBean */ public String getMinutes(){ return minutes; } /** Minutes getter * @return the minutes of this CrontabBean */ public String getSeconds(){ return seconds; } /** Months getter * @return the months of this CrontabBean */ public String getMonths(){ return months; } /** Hours booleans getter * @return boolean[] The hours to execute the Class, */ public boolean[] getBHours(){ return bHours; } /** Minutes getter * @return boolean[] The minutes to execute the Class, */ public boolean[] getBMinutes(){ return bMinutes; } /** Months Boolean getter * @return months The Months to execute the Class, */ public boolean[] getBMonths(){ return bMonths; } /** Getter Days of Week * @return daysOfWeek The days of the week */ public boolean[] getBDaysOfWeek(){ return bDaysOfWeek; } /** Days of Month getter * @return daysOfMonth The days of the month */ public boolean[] getBDaysOfMonth(){ return bDaysOfMonth; } /** Days of Month setter * @return daysOfMonth The days of the month */ public boolean[] getBSeconds(){ return bSeconds; } /** bYears getter * @return bYears Of ecah century */ public boolean[] getBYears(){ return bYears; } /** Returns true if theres extra info false otherwise. * @return extraInfo */ public boolean getBExtraInfo() { return bextraInfo; } /** Days of week getter * @return the Days of week of this CrontabBean */ public String getDaysOfWeek(){ return daysOfWeek; } /** Days of Month getter * @return the Id of this CrontabBean */ public String getDaysOfMonth(){ return daysOfMonth; } /** Year getter * @return the year of this CrontabEntryBean */ public String getYears() { return years; } /** Description getter * @return the Description of this CrontabBean */ public String getDescription(){ return description; } /**runOnlyInBusinessDays getter * @return true if shouldRun only in Business Days false otherwise */ public boolean getBusinessDays() { return runInBusinessDays; } /**startDate setter * @param the starting date of this Task */ public Date getStartDate() { return startDate; } /**endDate setter * @param the ending date of this Task */ public Date getEndDate() { return endDate; } /** Represents the CrotnabEntryBean in ASCII format * @return the returning string */ public String toString(){ try { CrontabParser cp = new CrontabParser(); return cp.unmarshall(this); } catch (Exception e) { return e.toString(); } } /** Represents the CrotnabEntryBean in XML format * @return the returning XML */ public String toXML(){ StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter, true); toXML(printWriter); return stringWriter.toString(); } /** Returns the XML that represents this Crontab EntryBean * @param pw The printWritter to write the XML */ public void toXML(PrintWriter pw) { pw.println("<crontabentry id=\""+ id + "\">"); pw.println("\t<seconds>" + seconds + "</seconds> "); pw.println("\t<minutes>" + minutes + "</minutes> "); pw.println("\t<hours>" + hours + "</hours> "); pw.println("\t<daysofmonth>" + daysOfMonth + "</daysofmonth> "); pw.println("\t<months>" + months + "</months> "); pw.println("\t<daysofweek>" + daysOfWeek + "</daysofweek> "); pw.println("\t<years>" + years + "</years> "); pw.println("\t<bussinesdays>" + runInBusinessDays +"</bussinesdays> " ); pw.println("\t<startDate>" + startDate +"</startDate> " ); pw.println("\t<endDate>" + endDate +"</endDate> " ); pw.println("\t<class>" + className + "</class> "); pw.println("\t<method>" + methodName + "</method> "); if (bextraInfo) { pw.print("\t<parameters>"); for (int i = 0; i < extraInfo.length ; i++) { pw.print(extraInfo[i]); if (i < extraInfo.length -1) pw.print(" "); } pw.println("</parameters>"); } pw.println("\t<description>" + description + "</description> "); pw.println("</crontabentry>"); } /** * This method is here to wrap other two avaiable equals * @param obj Object to compare with the time table entry * @return true if the time table entry matchs with the Object given * false otherwise */ public boolean equals(Object obj) { if (obj instanceof Calendar ) { return equalsCalendar((Calendar)obj); } else if (obj instanceof CrontabEntryBean) { return equalCrontabEntryBean((CrontabEntryBean)obj); } else { return false; } } /** * Helps to do the castings in a more simple way. * @param obj Object to cast to CrontabEntryBean * @return The resulting array of CrontabEntryBean */ public static CrontabEntryBean[] toArray(Object[] obj) { CrontabEntryBean[] ceb = new CrontabEntryBean[obj.length]; for (int i = 0; i < obj.length ; i++) { ceb[i] = (CrontabEntryBean)obj[i]; } return ceb; } /** * Returns true if the time table entry matchs with the calendar given * @param cal Calendar to compare with the time table entry * @return true if the time table entry matchs with the calendar given */ private boolean equalsCalendar(Calendar cal) { // IMPORTANT: Day of week and day of month in Calendar begin in // 1, not in 0. Thats why we decrement them return ( bSeconds[cal.get(Calendar.SECOND)] && bHours[cal.get(Calendar.HOUR_OF_DAY)] && bMinutes[cal.get(Calendar.MINUTE)] && bMonths[cal.get(Calendar.MONTH)] && bDaysOfWeek[cal.get(Calendar.DAY_OF_WEEK)-1] && bDaysOfMonth[cal.get(Calendar.DAY_OF_MONTH)-1] && bYears[cal.get(Calendar.YEAR)]) ; } /** * Returns true if the CrontabEntryBean equals the given * @param ceb CrontabEntryBean to compare with the CrontabEntryBean * @return true if the CrontabEntryBean entry equals the CrontabEntryBean * given */ private boolean equalCrontabEntryBean(CrontabEntryBean ceb) { if ( this.id != ceb.getId()) { return false; } if (!this.getSeconds().equals(ceb.getSeconds())){ return false; } if (!this.getMinutes().equals(ceb.getMinutes())){ return false; } if (!this.getHours().equals(ceb.getHours())){ return false; } if (!this.getDaysOfWeek().equals(ceb.getDaysOfWeek())){ return false; } if (!this.getDaysOfMonth().equals(ceb.getDaysOfMonth())){ return false; } if (!this.getMonths().equals(ceb.getMonths())){ return false; } if (!this.getYears().equals(ceb.getYears())){ return false; } if (!this.getClassName().equals(ceb.getClassName())){ return false; } if (this.getBExtraInfo() != ceb.getBExtraInfo()){ return false; } if (this.getBusinessDays() != ceb.getBusinessDays()){ return false; } if (this.getBExtraInfo()) { if (this.getExtraInfo().length != ceb.getExtraInfo().length) return false; for (int i = 0; i < this.getExtraInfo().length ; i++) { if(!this.getExtraInfo()[i].trim().equals( ceb.getExtraInfo()[i].trim())) return false; } } return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -