summaryrefslogtreecommitdiff
path: root/libjava
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-28 11:02:35 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-09-28 11:02:35 +0000
commitc83777a4d9ad65fbba3ce638107d293cf4065731 (patch)
treeefb4af35b0764ce908ae970f7c912407f60277e9 /libjava
parent06450f587e08804bbb126066c1458f8965e154f7 (diff)
downloadgcc-c83777a4d9ad65fbba3ce638107d293cf4065731.tar.gz
2004-09-28 Michael Koch <konqueror@gmx.de>
* java/net/URLConnection.java: Reformatted. * java/net/URLClassLoader.java: Reformatted. (getContent): Reordered return of content. (getContentHandler): Don't check for null explicitely. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@88226 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava')
-rw-r--r--libjava/ChangeLog7
-rw-r--r--libjava/java/net/URLClassLoader.java4
-rw-r--r--libjava/java/net/URLConnection.java69
3 files changed, 47 insertions, 33 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 41ba9314b5f..3a60a56f84c 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,10 @@
+2004-09-28 Michael Koch <konqueror@gmx.de>
+
+ * java/net/URLConnection.java: Reformatted.
+ * java/net/URLClassLoader.java: Reformatted.
+ (getContent): Reordered return of content.
+ (getContentHandler): Don't check for null explicitely.
+
2004-09-27 Michael Koch <konqueror@gmx.de>
* java/io/BufferedInputStream.java
diff --git a/libjava/java/net/URLClassLoader.java b/libjava/java/net/URLClassLoader.java
index 064114989fd..b991be8addf 100644
--- a/libjava/java/net/URLClassLoader.java
+++ b/libjava/java/net/URLClassLoader.java
@@ -858,7 +858,7 @@ public class URLClassLoader extends SecureClassLoader
// Just try to read it in all at once
data = new byte[length];
int pos = 0;
- while(length - pos > 0)
+ while (length - pos > 0)
{
int len = in.read(data, pos, length - pos);
if (len == -1)
@@ -872,7 +872,7 @@ public class URLClassLoader extends SecureClassLoader
// We don't know the data length.
// Have to read it in chunks.
ByteArrayOutputStream out = new ByteArrayOutputStream(4096);
- byte b[] = new byte[4096];
+ byte[] b = new byte[4096];
int l = 0;
while (l != -1)
{
diff --git a/libjava/java/net/URLConnection.java b/libjava/java/net/URLConnection.java
index 4bf52b860cd..3b3355cc11e 100644
--- a/libjava/java/net/URLConnection.java
+++ b/libjava/java/net/URLConnection.java
@@ -35,6 +35,7 @@ this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version. */
+
package java.net;
import java.io.IOException;
@@ -87,8 +88,8 @@ import gnu.gcj.io.MimeTypes;
* by the actual content handlers as described in the description of that
* method.
*
- * @author Aaron M. Renn <arenn@urbanophile.com>
- * @author Warren Levy <warrenl@cygnus.com>
+ * @author Aaron M. Renn (arenn@urbanophile.com)
+ * @author Warren Levy (warrenl@cygnus.com)
*/
public abstract class URLConnection
{
@@ -370,7 +371,7 @@ public abstract class URLConnection
{
if (! dateformats_initialized)
initializeDateFormats();
-
+
if (position == null)
position = new ParsePosition(0);
@@ -411,23 +412,29 @@ public abstract class URLConnection
}
/**
- * This method returns the content of the document pointed to by the URL
- * as an Object. The type of object depends on the MIME type of the
- * object and particular content hander loaded. Most text type content
- * handlers will return a subclass of InputStream. Images usually return
- * a class that implements ImageProducer. There is not guarantee what
- * type of object will be returned, however.
- * <p>
- * This class first determines the MIME type of the content, then creates
- * a ContentHandler object to process the input. If the ContentHandlerFactory
- * is set, then that object is called to load a content handler, otherwise
- * a class called gnu.java.net.content.&lt;content_type&gt; is tried.
- * The default class will also be used if the content handler factory returns
- * a null content handler.
- *
- * @exception IOException If an error occurs
+ * This method returns the content of the document pointed to by the
+ * URL as an Object. The type of object depends on the MIME type of
+ * the object and particular content hander loaded. Most text type
+ * content handlers will return a subclass of
+ * <code>InputStream</code>. Images usually return a class that
+ * implements <code>ImageProducer</code>. There is not guarantee
+ * what type of object will be returned, however.
+ *
+ * <p>This class first determines the MIME type of the content, then
+ * creates a ContentHandler object to process the input. If the
+ * <code>ContentHandlerFactory</code> is set, then that object is
+ * called to load a content handler, otherwise a class called
+ * gnu.java.net.content.&lt;content_type&gt; is tried. If this
+ * handler does not exist, the method will simple return the
+ * <code>InputStream</code> returned by
+ * <code>getInputStream()</code>. Note that the default
+ * implementation of <code>getInputStream()</code> throws a
+ * <code>UnknownServiceException</code> so subclasses are encouraged
+ * to override this method.</p>
+ *
+ * @exception IOException If an error with the connection occurs.
* @exception UnknownServiceException If the protocol does not support the
- * content type
+ * content type at all.
*/
public Object getContent() throws IOException
{
@@ -441,10 +448,10 @@ public abstract class URLConnection
String type = getContentType();
ContentHandler ch = getContentHandler(type);
- if (ch == null)
- return getInputStream();
+ if (ch != null)
+ return ch.getContent(this);
- return ch.getContent(this);
+ return getInputStream();
}
/**
@@ -888,20 +895,20 @@ public abstract class URLConnection
*/
public static String guessContentTypeFromName(String filename)
{
- int dot = filename.lastIndexOf (".");
+ int dot = filename.lastIndexOf(".");
if (dot != -1)
{
if (dot == filename.length())
- return ("application/octet-stream");
+ return "application/octet-stream";
else
- filename = filename.substring (dot + 1);
+ filename = filename.substring(dot + 1);
}
- String type = MimeTypes.getMimeTypeFromExtension (filename);
+ String type = MimeTypes.getMimeTypeFromExtension(filename);
if (type == null)
- return("application/octet-stream");
+ return"application/octet-stream";
return type;
}
@@ -957,7 +964,7 @@ public abstract class URLConnection
*/
public static void setFileNameMap(FileNameMap map)
{
- // Throw an exception if an extant security mgr precludes
+ // Throw an exception if an extant security manager precludes
// setting the factory.
SecurityManager s = System.getSecurityManager();
if (s != null)
@@ -968,12 +975,12 @@ public abstract class URLConnection
private ContentHandler getContentHandler(String contentType)
{
- ContentHandler handler;
-
// No content type so just handle it as the default.
if (contentType == null || contentType.equals(""))
return null;
+ ContentHandler handler;
+
// See if a handler has been cached for this content type.
// For efficiency, if a content type has been searched for but not
// found, it will be in the hash table but as the contentType String
@@ -1039,7 +1046,7 @@ public abstract class URLConnection
}
// Update the hashtable with the new content handler.
- if (handler != null && handler instanceof ContentHandler)
+ if (handler instanceof ContentHandler)
{
handlers.put(contentType, handler);
return handler;