From a8ada98685bc94b7bbde2865fd685464a18d160d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 19 Apr 2003 21:17:50 +0000 Subject: [PATCH] Date.java, [...]: New versions from Classpath. * java/sql/Date.java, java/sql/DriverManager.java, java/sql/Time.java, java/sql/Timestamp.java: New versions from Classpath. From-SVN: r65831 --- libjava/ChangeLog | 4 ++ libjava/java/sql/Date.java | 81 ++++++++++++++++++++++++-- libjava/java/sql/DriverManager.java | 13 +++-- libjava/java/sql/Time.java | 89 +++++++++++++++++++++++++++-- libjava/java/sql/Timestamp.java | 11 +++- 5 files changed, 181 insertions(+), 17 deletions(-) diff --git a/libjava/ChangeLog b/libjava/ChangeLog index c68224c2da89..04a8937a40df 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,5 +1,9 @@ 2003-04-19 Tom Tromey + * java/sql/Date.java, java/sql/DriverManager.java, + java/sql/Time.java, java/sql/Timestamp.java: New versions from + Classpath. + * Makefile.in: Rebuilt. * Makefile.am (ordinary_java_source_files): Added new files. * java/security/AlgorithmParameterGenerator.java, diff --git a/libjava/java/sql/Date.java b/libjava/java/sql/Date.java index 360376c25181..67d5eb7af013 100644 --- a/libjava/java/sql/Date.java +++ b/libjava/java/sql/Date.java @@ -1,5 +1,5 @@ /* Date.java -- Wrapper around java.util.Date - Copyright (C) 1999, 2000 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -37,6 +37,7 @@ exception statement from your version. */ package java.sql; +import java.text.ParseException; import java.text.SimpleDateFormat; /** @@ -81,6 +82,72 @@ public class Date extends java.util.Date super(date); } + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getHours() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getMinutes() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getSeconds() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setHours(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setMinutes(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setSeconds(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + /** * This method returns a new instance of this class by parsing a * date in JDBC format into a Java date. @@ -92,14 +159,18 @@ public class Date extends java.util.Date */ public static Date valueOf (String str) { - try + try { java.util.Date d = (java.util.Date) sdf.parseObject(str); - return(new Date(d.getTime())); + + if (d == null) + throw new IllegalArgumentException(str); + else + return new Date(d.getTime()); } - catch(Exception e) + catch (ParseException e) { - return(null); + throw new IllegalArgumentException(str); } } diff --git a/libjava/java/sql/DriverManager.java b/libjava/java/sql/DriverManager.java index 229450ad0572..649c5ae7339f 100644 --- a/libjava/java/sql/DriverManager.java +++ b/libjava/java/sql/DriverManager.java @@ -1,5 +1,5 @@ /* DriverManager.java -- Manage JDBC drivers - Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2001, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -103,7 +103,10 @@ public class DriverManager { Class.forName(driver_classname); // The driver registers itself } - catch (Exception e) { ; } // Ignore not founds + catch (Exception e) + { + // Ignore not founds + } } } @@ -209,9 +212,9 @@ public class DriverManager * @param url The JDBC URL string to find a driver for. * * @return A Driver that can connect to the specified - * URL, or null if a suitable driver cannot be found. + * URL. * - * @exception SQLException If an error occurs. + * @exception SQLException If an error occurs, or no suitable driver can be found. */ public static Driver getDriver(String url) throws SQLException { @@ -224,7 +227,7 @@ public class DriverManager return d; } - return null; + throw new SQLException("No driver found for " + url); } /** diff --git a/libjava/java/sql/Time.java b/libjava/java/sql/Time.java index 7d515c25c3b4..9200ee3cadf9 100644 --- a/libjava/java/sql/Time.java +++ b/libjava/java/sql/Time.java @@ -1,5 +1,5 @@ /* Time.java -- Wrapper around java.util.Date - Copyright (C) 1999, 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 1999, 2000, 2002, 2003 Free Software Foundation, Inc. This file is part of GNU Classpath. @@ -38,6 +38,7 @@ exception statement from your version. */ package java.sql; +import java.text.ParseException; import java.text.SimpleDateFormat; /** @@ -55,6 +56,82 @@ public class Time extends java.util.Date */ private static SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss"); + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getDate() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getDay() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getMonth() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public int getYear() throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setDate(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setMonth(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } + + /** + * This method always throws an IllegalArgumentException. + * + * @throws IllegalArgumentException when it's called. + * @deprecated + */ + public void setYear(int newValue) throws IllegalArgumentException + { + throw new IllegalArgumentException(); + } /** * This method returns a new instance of this class by parsing a @@ -70,11 +147,15 @@ public class Time extends java.util.Date try { java.util.Date d = (java.util.Date) sdf.parseObject(str); - return new Time(d.getTime()); + + if (d == null) + throw new IllegalArgumentException(str); + else + return new Time(d.getTime()); } - catch (Exception e) + catch (ParseException e) { - return null; + throw new IllegalArgumentException(str); } } diff --git a/libjava/java/sql/Timestamp.java b/libjava/java/sql/Timestamp.java index 0f8b44c43a60..b5f0523dfd93 100644 --- a/libjava/java/sql/Timestamp.java +++ b/libjava/java/sql/Timestamp.java @@ -38,6 +38,7 @@ exception statement from your version. */ package java.sql; +import java.text.ParseException; import java.text.SimpleDateFormat; /** @@ -81,11 +82,15 @@ public class Timestamp extends java.util.Date try { Date d = (Date) parse_sdf.parseObject(str); - return new Timestamp(d.getTime()); + + if (d == null) + throw new IllegalArgumentException(str); + else + return new Timestamp(d.getTime()); } - catch (Exception e) + catch (ParseException e) { - return null; + throw new IllegalArgumentException(str); } }