This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
java.net.ContentHandler
- From: Michael Koch <konqueror at gmx dot de>
- To: java-patches at gcc dot gnu dot org
- Date: Tue, 20 Aug 2002 11:25:14 +0200
- Subject: java.net.ContentHandler
Hello list.
Here another patch for java.net.*. Please review.
This patch can go into classpath too.
Greetings,
Michael
Index: java/net/ContentHandler.java
===================================================================
RCS file: /cvsroot/gcc/gcc/libjava/java/net/ContentHandler.java,v
retrieving revision 1.5
diff -u -b -r1.5 ContentHandler.java
--- java/net/ContentHandler.java 22 Jan 2002 22:40:23 -0000 1.5
+++ java/net/ContentHandler.java 20 Aug 2002 09:23:07 -0000
@@ -88,4 +88,36 @@
*/
public abstract Object getContent(URLConnection urlc) throws IOException;
+/*************************************************************************/
+
+/**
+ * This method reads from the <code>InputStream</code> of the passed in URL
+ * connection and uses the data downloaded to create an <code>Object</code>
+ * represening the content. For example, if the URL is pointing to a GIF
+ * file, this method might return an <code>Image</code> object. This method
+ * must be implemented by subclasses. If the object doesnt match any type in
+ * classes it returns null.
+ *
+ * @param urlc A <code>URLConnection</code> object to read data from.
+ *
+ * @return An object representing the data read
+ *
+ * @exception IOException If an error occurs
+ *
+ * @since 1.3
+ */
+public Object getContent(URLConnection urlc, Class[] classes)
+ throws IOException
+{
+ Object obj = getContent (urlc);
+
+ for (int i = 0; i < classes.length; i++)
+ {
+ if (classes [i].isInstance (obj))
+ return obj;
+ }
+
+ return null;
+}
+
} // class ContentHandler