KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > update > internal > configurator > UpdateURLDecoder


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.update.internal.configurator;
12
13 import java.io.UnsupportedEncodingException JavaDoc;
14 import java.net.URLDecoder JavaDoc;
15
16 public class UpdateURLDecoder {
17     static boolean init=false;
18     static boolean useEnc=true;
19     
20     public static String JavaDoc decode(String JavaDoc s, String JavaDoc enc) throws UnsupportedEncodingException JavaDoc {
21         if (!init) {
22             init = true;
23             try {
24                 return URLDecoder.decode(s, enc);
25             } catch (NoSuchMethodError JavaDoc e) {
26                 useEnc=false;
27             }
28         }
29         
30         if (useEnc) {
31             return URLDecoder.decode(s, enc);
32         }
33         return URLDecoder.decode(s);
34     }
35
36 }
37
Popular Tags