Source Code Cross Referenced for ContentHandler.java in  » 6.0-JDK-Modules » j2me » java » net » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » java.net 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * @(#)ContentHandler.java	1.20 06/10/10
003:         *
004:         * Copyright  1990-2006 Sun Microsystems, Inc. All Rights Reserved.  
005:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER  
006:         *   
007:         * This program is free software; you can redistribute it and/or  
008:         * modify it under the terms of the GNU General Public License version  
009:         * 2 only, as published by the Free Software Foundation.   
010:         *   
011:         * This program is distributed in the hope that it will be useful, but  
012:         * WITHOUT ANY WARRANTY; without even the implied warranty of  
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU  
014:         * General Public License version 2 for more details (a copy is  
015:         * included at /legal/license.txt).   
016:         *   
017:         * You should have received a copy of the GNU General Public License  
018:         * version 2 along with this work; if not, write to the Free Software  
019:         * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  
020:         * 02110-1301 USA   
021:         *   
022:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa  
023:         * Clara, CA 95054 or visit www.sun.com if you need additional  
024:         * information or have any questions. 
025:         *
026:         */
027:
028:        package java.net;
029:
030:        import java.io.IOException;
031:
032:        /**
033:         * The abstract class <code>ContentHandler</code> is the superclass 
034:         * of all classes that read an <code>Object</code> from a 
035:         * <code>URLConnection</code>. 
036:         * <p>
037:         * An application does not generally call the 
038:         * <code>getContent</code> method in this class directly. Instead, an 
039:         * application calls the <code>getContent</code> method in class 
040:         * <code>URL</code> or in <code>URLConnection</code>.
041:         * The application's content handler factory (an instance of a class that 
042:         * implements the interface <code>ContentHandlerFactory</code> set 
043:         * up by a call to <code>setContentHandler</code>) is 
044:         * called with a <code>String</code> giving the MIME type of the 
045:         * object being received on the socket. The factory returns an 
046:         * instance of a subclass of <code>ContentHandler</code>, and its 
047:         * <code>getContent</code> method is called to create the object. 
048:         * <p>
049:         * If no content handler could be found, URLConnection will 
050:         * look for a content handler in a user-defineable set of places.
051:         * By default it looks in sun.net.www.content, but users can define a 
052:         * vertical-bar delimited set of class prefixes to search through in 
053:         * addition by defining the java.content.handler.pkgs property.
054:         * The class name must be of the form:
055:         * <pre>
056:         *     {package-prefix}.{major}.{minor}
057:         * e.g.
058:         *     YoyoDyne.experimental.text.plain
059:         * </pre>
060:         * If the loading of the content handler class would be performed by 
061:         * a classloader that is outside of the the delegation chain of the caller,
062:         * the JVM will need the RuntimePermission "getClassLoader".
063:         * 
064:         * @author  James Gosling
065:         * @version 1.14, 02/02/00
066:         * @see     java.net.ContentHandler#getContent(java.net.URLConnection)
067:         * @see     java.net.ContentHandlerFactory
068:         * @see     java.net.URL#getContent()
069:         * @see     java.net.URLConnection
070:         * @see     java.net.URLConnection#getContent()
071:         * @see     java.net.URLConnection#setContentHandlerFactory(java.net.ContentHandlerFactory)
072:         * @since   JDK1.0
073:         */
074:        abstract public class ContentHandler {
075:            /** 
076:             * Given a URL connect stream positioned at the beginning of the 
077:             * representation of an object, this method reads that stream and 
078:             * creates an object from it. 
079:             *
080:             * @param      urlc   a URL connection.
081:             * @return     the object read by the <code>ContentHandler</code>.
082:             * @exception  IOException  if an I/O error occurs while reading the object.
083:             */
084:            abstract public Object getContent(URLConnection urlc)
085:                    throws IOException;
086:
087:            /** 
088:             * Given a URL connect stream positioned at the beginning of the 
089:             * representation of an object, this method reads that stream and 
090:             * creates an object that matches one of the types specified. 
091:             *
092:             * The default implementation of this method should call getContent()
093:             * and screen the return type for a match of the suggested types.
094:             *
095:             * @param      urlc   a URL connection.
096:             * @param      classes	an array of types requested  
097:             * @return     the object read by the <code>ContentHandler</code> that is 
098:             *                 the first match of the suggested types. 
099:             *                 null if none of the requested  are supported.
100:             * @exception  IOException  if an I/O error occurs while reading the object.
101:             */
102:            public Object getContent(URLConnection urlc, Class[] classes)
103:                    throws IOException {
104:                Object obj = getContent(urlc);
105:
106:                for (int i = 0; i < classes.length; i++) {
107:                    if (classes[i].isInstance(obj)) {
108:                        return obj;
109:                    }
110:                }
111:                return null;
112:            }
113:
114:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.