PushbackInputStream.java, [...]: Merged new versions from classpath.
2003-05-25 Michael Koch <konqueror@gmx.de> * java/io/PushbackInputStream.java, java/net/Authenticator.java, java/net/ContentHandler.java, java/net/ContentHandlerFactory.java, java/net/DatagramSocket.java, java/net/DatagramSocketImpl.java, java/net/DatagramSocketImplFactory.java, java/net/FileNameMap.java, java/net/SocketImplFactory.java, java/net/SocketOptions.java, java/net/URLStreamHandlerFactory.java: Merged new versions from classpath. From-SVN: r67165
This commit is contained in:
parent
eceea3010f
commit
c7684ffe55
12 changed files with 386 additions and 393 deletions
|
@ -1,5 +1,5 @@
|
|||
/* ContentHandler.java -- Abstract class for handling content from URL's
|
||||
Copyright (C) 1998, 1999 2000, 2001 Free Software Foundation, Inc.
|
||||
Copyright (C) 1998, 1999, 2000, 2001, 2003 Free Software Foundation, Inc.
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
|
@ -59,65 +59,69 @@ import java.io.IOException;
|
|||
*/
|
||||
public abstract class ContentHandler
|
||||
{
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
|
||||
/*************************************************************************/
|
||||
/**
|
||||
* Default, no-argument constructor.
|
||||
*/
|
||||
public ContentHandler()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
* Constructors
|
||||
*/
|
||||
/*
|
||||
* Instance Methods
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default, no-argument constructor.
|
||||
*/
|
||||
public ContentHandler() { }
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param urlc A <code>URLConnection</code> object to read data from.
|
||||
*
|
||||
* @return An object representing the data read
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
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. This method uses the list of
|
||||
* supplied classes as candidate types. If the data read doesn't match
|
||||
* any of the supplied type, <code>null</code> is returned.
|
||||
*
|
||||
* @param urlc A <code>URLConnection</code> object to read data from.
|
||||
* @param classes An array of types of objects that are candidate types
|
||||
* for the data to be read.
|
||||
*
|
||||
* @return An object representing the data read, or <code>null</code>
|
||||
* if the data does not match any of the candidate types.
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
*
|
||||
* @since 1.3
|
||||
*/
|
||||
public Object getContent(URLConnection urlc, Class[] classes)
|
||||
throws IOException
|
||||
{
|
||||
Object obj = getContent (urlc);
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param urlc A <code>URLConnection</code> object to read data from.
|
||||
*
|
||||
* @return An object representing the data read
|
||||
*
|
||||
* @exception IOException If an error occurs
|
||||
*/
|
||||
public abstract Object getContent(URLConnection urlc) throws IOException;
|
||||
for (int i = 0; i < classes.length; i++)
|
||||
{
|
||||
if (classes [i].isInstance (obj))
|
||||
return obj;
|
||||
}
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
} // class ContentHandler
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue