KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > api > engine > jasperreports > util > repo > Handler


1 /*
2  * Copyright (C) 2006 JasperSoft http://www.jaspersoft.com
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed WITHOUT ANY WARRANTY; and without the
10  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11  * See the GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, see http://www.gnu.org/licenses/gpl.txt
15  * or write to:
16  *
17  * Free Software Foundation, Inc.,
18  * 59 Temple Place - Suite 330,
19  * Boston, MA USA 02111-1307
20  */

21 package com.jaspersoft.jasperserver.api.engine.jasperreports.util.repo;
22
23 import java.io.IOException JavaDoc;
24 import java.net.URL JavaDoc;
25 import java.net.URLConnection JavaDoc;
26 import java.net.URLStreamHandler JavaDoc;
27
28 import com.jaspersoft.jasperserver.api.engine.jasperreports.util.RepositoryUtil;
29
30
31 /**
32  * @author Lucian Chirita (lucianc@users.sourceforge.net)
33  * @version $Id: Handler.java 2995 2006-04-07 14:05:32Z tdanciu $
34  */

35 public class Handler extends URLStreamHandler JavaDoc
36 {
37     public final static String JavaDoc REPOSITORY_PROTOCOL = "repo";
38     public final static String JavaDoc URL_PROTOCOL_PREFIX = REPOSITORY_PROTOCOL + ':';
39     
40     public Handler()
41     {
42         super();
43     }
44     
45     protected void parseURL(URL JavaDoc u, String JavaDoc spec, int start, int limit)
46     {
47         spec = spec.trim();
48         
49         String JavaDoc protocol = null;
50         String JavaDoc path;
51         if (spec.startsWith(URL_PROTOCOL_PREFIX))
52         {
53             protocol = REPOSITORY_PROTOCOL;
54             path = spec.substring(URL_PROTOCOL_PREFIX.length());
55         }
56         else
57         {
58             path = spec;
59         }
60
61         setURL(u, protocol, null, -1, null, null, path, null, null);
62     }
63
64     protected URLConnection JavaDoc openConnection(URL JavaDoc url) throws IOException JavaDoc
65     {
66         return new RepositoryConnection(RepositoryUtil.getThreadRepositoryContext(), url);
67     }
68 }
69
Popular Tags