HttpURLConnection.java, [...]: Reworked import statements.
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. From-SVN: r68198
This commit is contained in:
parent
3580a7d585
commit
a05f6447e3
9 changed files with 155 additions and 141 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue