diff options
author | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-19 15:08:22 +0000 |
---|---|---|
committer | mkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4> | 2003-06-19 15:08:22 +0000 |
commit | 8db76ca933c641a7b60834003cd77e4ee4b99c49 (patch) | |
tree | 79455d0849bdbde550daa14a232718f903499cff /libjava/java/net/URLConnection.java | |
parent | 208f6aa90d7709852c3c07ac158a0f9cc0a410b4 (diff) | |
download | ppe42-gcc-8db76ca933c641a7b60834003cd77e4ee4b99c49.tar.gz ppe42-gcc-8db76ca933c641a7b60834003cd77e4ee4b99c49.zip |
2003-06-19 Michael Koch <konqueror@gmx.de>
* java/net/HttpURLConnection.java,
java/net/Inet4Address.java,
java/net/Inet6Address.java,
java/net/SocketImpl.java,
java/net/URLClassLoader.java:
Reworked import statements.
* java/net/InetAddress.java
(getByAddress): Simplified.
* java/net/ServerSocket.java
(ServerSocket): Moved special handling during bind operation to
bind().
(bind): Handle different cases when trying to bind a socket.
* java/net/URLConnection.java
(getHeaderFieldDate): Merged with classpath.
(getHeaderFieldInt): Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@68198 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/java/net/URLConnection.java')
-rw-r--r-- | libjava/java/net/URLConnection.java | 44 |
1 files changed, 24 insertions, 20 deletions
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java index 7d2ab44f6c5..3b8a85be139 100644 --- a/libjava/java/net/URLConnection.java +++ b/libjava/java/net/URLConnection.java @@ -331,20 +331,19 @@ public abstract class URLConnection */ public int getHeaderFieldInt(String name, int defaultValue) { - String str = getHeaderField(name); - int result = defaultValue; + String value = getHeaderField (name); + if (value == null) + return defaultValue; + try { - if (str != null) - result = Integer.parseInt (str); + return Integer.parseInt (value); } catch (NumberFormatException e) { - ; // Do nothing; defaultValue is the default. + return defaultValue; } - - return result; } /** @@ -353,27 +352,32 @@ public abstract class URLConnection * value if the field is not present or cannot be converted to a date. * * @param name The name of the header field - * @param val The dafault date + * @param defaultValue The default date if the header field is not found + * or can't be converted. * * @return Returns the date value of the header filed or the default value * if the field is missing or malformed */ - public long getHeaderFieldDate(String name, long val) + public long getHeaderFieldDate (String name, long defaultValue) { if (! dateformats_initialized) - initializeDateFormats(); - String str = getHeaderField(name); + initializeDateFormats (); + + long result = defaultValue; + String str = getHeaderField (name); + if (str != null) { - Date date; - if ((date = dateFormat1.parse(str, new ParsePosition(0))) != null) - val = date.getTime(); - else if ((date = dateFormat2.parse(str, new ParsePosition(0))) != null) - val = date.getTime(); - else if ((date = dateFormat3.parse(str, new ParsePosition(0))) != null) - val = date.getTime(); + Date date; + if ((date = dateFormat1.parse (str, new ParsePosition (0))) != null) + result = date.getTime (); + else if ((date = dateFormat2.parse (str, new ParsePosition (0))) != null) + result = date.getTime (); + else if ((date = dateFormat3.parse (str, new ParsePosition (0))) != null) + result = date.getTime (); } - return val; + + return result; } /** @@ -387,7 +391,7 @@ public abstract class URLConnection * @return The header field key or null if index is past the end * of the headers. */ - public String getHeaderFieldKey(int index) + public String getHeaderFieldKey (int index) { // Subclasses for specific protocols override this. return null; |