001 /** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017 // 018 // This source code implements specifications defined by the Java 019 // Community Process. In order to remain compliant with the specification 020 // DO NOT add / change / or delete method signatures! 021 // 022 package javax.ejb; 023 024 import java.io.Serializable; 025 import java.util.Date; 026 027 public class ScheduleExpression implements Serializable { 028 029 private static final long serialVersionUID = -3813254457230997879L; 030 031 private String dayOfMonth = "*"; 032 private String dayOfWeek = "*"; 033 private String hour = "0"; 034 private String minute = "0"; 035 private String month = "*"; 036 private String second = "0"; 037 private String year = "*"; 038 private String timezone; 039 private Date start; 040 private Date end; 041 042 public ScheduleExpression dayOfMonth(int d) { 043 dayOfMonth = Integer.toString(d); 044 return this; 045 } 046 047 public ScheduleExpression dayOfMonth(String d) { 048 dayOfMonth = d; 049 return this; 050 } 051 052 public ScheduleExpression dayOfWeek(int d) { 053 dayOfWeek = Integer.toString(d); 054 return this; 055 } 056 057 public ScheduleExpression dayOfWeek(String d) { 058 dayOfWeek = d; 059 return this; 060 } 061 062 public ScheduleExpression end(Date e) { 063 end = e; 064 return this; 065 } 066 067 public String getDayOfMonth() { 068 return dayOfMonth; 069 } 070 071 public String getDayOfWeek() { 072 return dayOfWeek; 073 } 074 075 public Date getEnd() { 076 return end; 077 } 078 079 public String getHour() { 080 return hour; 081 } 082 083 public String getMinute() { 084 return minute; 085 } 086 087 public String getMonth() { 088 return month; 089 } 090 091 public String getSecond() { 092 return second; 093 } 094 095 public Date getStart() { 096 return start; 097 } 098 099 public String getYear() { 100 return year; 101 } 102 103 public String getTimezone() { 104 return timezone; 105 } 106 107 public ScheduleExpression hour(int h) { 108 hour = Integer.toString(h); 109 return this; 110 } 111 112 public ScheduleExpression hour(String h) { 113 hour = h; 114 return this; 115 } 116 117 public ScheduleExpression minute(int m) { 118 minute = Integer.toString(m); 119 return this; 120 } 121 122 public ScheduleExpression minute(String m) { 123 minute = m; 124 return this; 125 } 126 127 public ScheduleExpression month(int m) { 128 month = Integer.toString(m); 129 return this; 130 } 131 132 public ScheduleExpression month(String m) { 133 month = m; 134 return this; 135 } 136 137 public ScheduleExpression second(int s) { 138 second = Integer.toString(s); 139 return this; 140 } 141 142 public ScheduleExpression second(String s) { 143 second = s; 144 return this; 145 } 146 147 public ScheduleExpression start(Date s) { 148 start = s; 149 return this; 150 } 151 152 public ScheduleExpression year(int y) { 153 year = Integer.toString(y); 154 return this; 155 } 156 157 public ScheduleExpression year(String y) { 158 year = y; 159 return this; 160 } 161 162 /** 163 * See http://en.wikipedia.org/wiki/List_of_zoneinfo_timezones for valid timezones 164 * @param t 165 * @return 166 */ 167 public ScheduleExpression timezone(String t) { 168 timezone = t; 169 return this; 170 } 171 }