Package java.net

Examples of java.net.ContentHandler


        // IMPLEMENTATION NOTE: Caching is not strictly necessary for
        // stream handlers since the Java runtime caches them. Caching is
        // performed for code consistency between stream and content
        // handlers and also because caching behavior may not be guaranteed
        // across different JRE implementations.
        ContentHandler handler = getFromContentCache(mimeType);

        if (handler != null)
        {
            return handler;
        }
View Full Code Here


     *        java.lang.Class[])
     */
    public void test_getContent() throws IOException {
        URLConnection conn = new URL("http://www.apache.org").openConnection();
        Class[] classes = { Foo.class, String.class, };
        ContentHandler handler = new ContentHandlerImpl();
        ((ContentHandlerImpl) handler).setContent(new Foo());
        Object content = handler.getContent(conn, classes);
        assertEquals("Foo", ((Foo) content).getFoo());

        ((ContentHandlerImpl) handler).setContent(new FooSub());
        content = handler.getContent(conn, classes);
        assertEquals("FooSub", ((Foo) content).getFoo());

        Class[] classes2 = { FooSub.class, String.class, };
        ((ContentHandlerImpl) handler).setContent(new Foo());
        content = handler.getContent(conn, classes2);
        assertNull(content);
    }
View Full Code Here

    public ContentHandler createContentHandler(final String mimeType) {
        for (Module module : modules) {
            ServiceLoader<ContentHandlerFactory> loader = module.loadService(ContentHandlerFactory.class);
            for (ContentHandlerFactory factory : loader) try {
                final ContentHandler handler = factory.createContentHandler(mimeType);
                if (handler != null) {
                    return handler;
                }
            } catch (RuntimeException e) {
                // ignored
View Full Code Here

    public ContentHandler createContentHandler(final String mimeType) {
        for (Module module : modules) {
            ServiceLoader<ContentHandlerFactory> loader = module.loadService(ContentHandlerFactory.class);
            for (ContentHandlerFactory factory : loader) try {
                final ContentHandler handler = factory.createContentHandler(mimeType);
                if (handler != null) {
                    return handler;
                }
            } catch (RuntimeException e) {
                // ignored
View Full Code Here

TOP

Related Classes of java.net.ContentHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.