Anonymous avatar Anonymous committed b020cd8

fixes for JDK 1.3 compatibility.
CVS: ----------------------------------------------------------------------
CVS: Issue number:
CVS: If this change addresses one or more issues,
CVS: then enter the issue number(s) here.
CVS: Obtained from:
CVS: If this change has been taken from another system,
CVS: then name the system in this line, otherwise delete it.
CVS: Submitted by:
CVS: If this code has been contributed to the project by someone else; i.e.,
CVS: they sent us a patch or a set of diffs, then include their name/email
CVS: address here. If this is your work then delete this line.
CVS: Reviewed by:
CVS: If we are doing pre-commit code reviews and someone else has
CVS: reviewed your changes, include their name(s) here.
CVS: If you have not had it reviewed then delete this line.

git-svn-id: http://svn.opensymphony.com/svn/quartz/trunk@216 69f7d36a-ea1c-0410-88ea-9fd03e4c9665

Comments (0)

Files changed (6)

src/java/org/quartz/NthIncludedDayTrigger.java

 		String[] components;
 		
 		try {
-			components = fireAtTime.split(":");
-			fireHour = Integer.parseInt(components[0]);
-			fireMinute = Integer.parseInt(components[1]);
+			int i = fireAtTime.indexOf(":");
+			fireHour = Integer.parseInt(fireAtTime.substring(0, i));
+			fireMinute = Integer.parseInt(fireAtTime.substring(i+1));
 		} catch (Exception e) {
 			fireHour = 12;
 			fireMinute = 0;
 				// increment currN if the current date being tested is included
 				// on the calendar
 				if ((calendar == null) 
-						|| (calendar.isTimeIncluded(currCal.getTimeInMillis()))) {
+						|| (calendar.isTimeIncluded(currCal.getTime().getTime()))) {
 					currN++;
 				}
 
 				// increment currN if the current date being tested is included
 				// on the calendar
 				if ((calendar == null) 
-						|| (calendar.isTimeIncluded(currCal.getTimeInMillis()))) {
+						|| (calendar.isTimeIncluded(currCal.getTime().getTime()))) {
 					currN++;
 				}
 

src/java/org/quartz/TriggerUtils.java

 
 import java.util.Calendar;
 import java.util.Date;
+import java.util.GregorianCalendar;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.TimeZone;
 
         Date newDate = new Date();
 
-        int offset = (dest.getOffset(date.getTime()) - src.getOffset(date
-                .getTime()));
+        int offset = (getOffset(date.getTime(), dest) - getOffset(date.getTime(), src));
 
         newDate.setTime(date.getTime() - offset);
 
         return newDate;
-
     }
     
+    /**
+     * Gets the offset from UT for the given date in the given timezone, 
+     * taking into account daylight savings.
+     * 
+     * <p>
+     * Equivalent of TimeZone.getOffset(date) in JDK 1.4, but Quartz is trying
+     * to support JDK 1.3.
+     * </p>
+     */
+    public static int getOffset(long date, TimeZone tz) {
+        
+        if (tz.inDaylightTime(new Date(date))) {
+            return tz.getRawOffset() + getDSTSavings(tz);
+        }
+        
+        return tz.getRawOffset();
+    }
+
+    /**
+     * <p>
+     * Equivalent of TimeZone.getDSTSavings() in JDK 1.4, but Quartz is trying
+     * to support JDK 1.3.
+     * </p>
+     */
+    public static int getDSTSavings(TimeZone tz) {
+        
+        if (tz.useDaylightTime()) {
+            return 3600000;
+        }
+        return 0;
+    }
 }

src/java/org/quartz/ee/servlet/QuartzInitializerServlet.java

 			 * the scheduler will be started. This is to maintain backwards
 			 * compatability.
 			 */
-			if (startOnLoad == null
-					|| (startOnLoad != null && Boolean
-							.parseBoolean(startOnLoad))) {
+			if (startOnLoad == null || (Boolean.getBoolean(startOnLoad))) {
 				// Start now
 				scheduler = factory.getScheduler();
 				scheduler.start();

src/java/org/quartz/helpers/TriggerUtils.java

      * the right date & time.
      * 
      * @deprecated use org.quartz.TriggerUtils instead!
-     * 
      */      
     public static Date translateTime(Date date, TimeZone src, TimeZone dest) {
 
         Date newDate = new Date();
 
-        int offset = (dest.getOffset(date.getTime()) - src.getOffset(date
-                .getTime()));
+        int offset = (getOffset(date.getTime(), dest) - getOffset(date.getTime(), src));
 
         newDate.setTime(date.getTime() - offset);
 
         return newDate;
+    }
+    
+    /**
+     * Gets the offset from UT for the given date in the given timezone, 
+     * taking into account daylight savings.
+     * 
+     * <p>
+     * Equivalent of TimeZone.getOffset(date) in JDK 1.4, but Quartz is trying
+     * to support JDK 1.3.
+     * </p>
+     * 
+     * 
+     * @deprecated use org.quartz.TriggerUtils instead!
+     */
+    public static int getOffset(long date, TimeZone tz) {
+        
+        if (tz.inDaylightTime(new Date(date))) {
+            return tz.getRawOffset() + getDSTSavings(tz);
+        }
+        
+        return tz.getRawOffset();
+    }
 
+    /**
+     * <p>
+     * Equivalent of TimeZone.getDSTSavings() in JDK 1.4, but Quartz is trying
+     * to support JDK 1.3.
+     * </p>
+     * 
+     * @deprecated use org.quartz.TriggerUtils instead!
+     */
+    public static int getDSTSavings(TimeZone tz) {
+        
+        if (tz.useDaylightTime()) {
+            return 3600000;
+        }
+        return 0;
     }
     
 }

src/java/org/quartz/plugins/xml/JobInitializationPlugin.java

         if (!file.exists()) {
             URL url = classLoadHelper.getResource(getFileName());
             if(url != null) {
-                try {
-                    furl = URLDecoder.decode(url.getPath(), "UTF-8");
-                } catch (UnsupportedEncodingException e) {
-                    furl = url.getPath();
-                }
+// we need jdk 1.3 compatibility, so we abandon this code...
+//                try {
+//                    furl = URLDecoder.decode(url.getPath(), "UTF-8");
+//                } catch (UnsupportedEncodingException e) {
+//                    furl = url.getPath();
+//                }
+                furl = URLDecoder.decode(url.getPath()); 
                 file = new File(furl); 
                 try {
                     f = url.openStream();

src/java/org/quartz/plugins/xml/JobInitializationPluginMultiple.java

 import java.net.URL;
 import java.util.Date;
 import java.util.Iterator;
+import java.util.StringTokenizer;
 import java.util.Vector;
 
 import org.apache.commons.logging.Log;
     }
     
     private void updateJobFileList() {
-    	String[] fileNames = fileName.split(",");
+        StringTokenizer stok = new StringTokenizer(fileName, ",");
 
-    	for (int i=0; i<fileNames.length; i++) {
-    		JobFile jobFile = new JobFile(fileNames[i]);
+    	while(stok.hasMoreTokens()) {
+    		JobFile jobFile = new JobFile(stok.nextToken());
     		files.add(jobFile);
     	}
     }
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.