KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > osgi > framework > internal > protocol > MultiplexingContentHandler


1 /*******************************************************************************
2  * Copyright (c) 2006 Cognos Incorporated, IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  *******************************************************************************/

9 package org.eclipse.osgi.framework.internal.protocol;
10
11 import java.io.IOException JavaDoc;
12 import java.net.ContentHandler JavaDoc;
13 import java.net.URLConnection JavaDoc;
14
15 public class MultiplexingContentHandler extends ContentHandler JavaDoc {
16
17     private String JavaDoc contentType;
18     private ContentHandlerFactory factory;
19
20     public MultiplexingContentHandler(String JavaDoc contentType, ContentHandlerFactory factory) {
21         this.contentType = contentType;
22         this.factory = factory;
23     }
24
25     public Object JavaDoc getContent(URLConnection JavaDoc uConn) throws IOException JavaDoc {
26         ContentHandler JavaDoc handler = factory.findAuthorizedContentHandler(contentType);
27         if (handler != null)
28             return handler.getContent(uConn);
29
30         return uConn.getInputStream();
31     }
32
33 }
34
Popular Tags