ContentHandler.java revision 0
0N/A * Copyright 1995-2006 Sun Microsystems, Inc. All Rights Reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 0N/A * This code is free software; you can redistribute it and/or modify it 0N/A * under the terms of the GNU General Public License version 2 only, as 0N/A * published by the Free Software Foundation. Sun designates this 0N/A * particular file as subject to the "Classpath" exception as provided 0N/A * by Sun in the LICENSE file that accompanied this code. 0N/A * This code is distributed in the hope that it will be useful, but WITHOUT 0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 0N/A * version 2 for more details (a copy is included in the LICENSE file that 0N/A * accompanied this code). 0N/A * You should have received a copy of the GNU General Public License version 0N/A * 2 along with this work; if not, write to the Free Software Foundation, 0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 0N/A * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, 0N/A * CA 95054 USA or visit www.sun.com if you need additional information or 0N/A * have any questions. 0N/A * The abstract class <code>ContentHandler</code> is the superclass 0N/A * of all classes that read an <code>Object</code> from a 0N/A * <code>URLConnection</code>. 0N/A * An application does not generally call the 0N/A * <code>getContent</code> method in this class directly. Instead, an 0N/A * application calls the <code>getContent</code> method in class 0N/A * <code>URL</code> or in <code>URLConnection</code>. 0N/A * The application's content handler factory (an instance of a class that 0N/A * implements the interface <code>ContentHandlerFactory</code> set 0N/A * up by a call to <code>setContentHandler</code>) is 0N/A * called with a <code>String</code> giving the MIME type of the 0N/A * object being received on the socket. The factory returns an 0N/A * instance of a subclass of <code>ContentHandler</code>, and its 0N/A * <code>getContent</code> method is called to create the object. 0N/A * If no content handler could be found, URLConnection will 0N/A * look for a content handler in a user-defineable set of places. 0N/A * By default it looks in sun.net.www.content, but users can define a 0N/A * vertical-bar delimited set of class prefixes to search through in 0N/A * addition by defining the java.content.handler.pkgs property. 0N/A * The class name must be of the form: 0N/A * {package-prefix}.{major}.{minor} 0N/A * YoyoDyne.experimental.text.plain 0N/A * If the loading of the content handler class would be performed by 0N/A * a classloader that is outside of the delegation chain of the caller, 0N/A * the JVM will need the RuntimePermission "getClassLoader". 0N/A * @author James Gosling 0N/A * @see java.net.ContentHandler#getContent(java.net.URLConnection) 0N/A * @see java.net.ContentHandlerFactory 0N/A * @see java.net.URL#getContent() 0N/A * @see java.net.URLConnection 0N/A * @see java.net.URLConnection#getContent() 0N/A * @see java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory) 0N/A * Given a URL connect stream positioned at the beginning of the 0N/A * representation of an object, this method reads that stream and 0N/A * creates an object from it. 0N/A * @param urlc a URL connection. 0N/A * @return the object read by the <code>ContentHandler</code>. 0N/A * @exception IOException if an I/O error occurs while reading the object. 0N/A * Given a URL connect stream positioned at the beginning of the 0N/A * representation of an object, this method reads that stream and 0N/A * creates an object that matches one of the types specified. 0N/A * The default implementation of this method should call getContent() 0N/A * and screen the return type for a match of the suggested types. 0N/A * @param urlc a URL connection. 0N/A * @param classes an array of types requested 0N/A * @return the object read by the <code>ContentHandler</code> that is 0N/A * the first match of the suggested types. 0N/A * null if none of the requested are supported. 0N/A * @exception IOException if an I/O error occurs while reading the object.