Author: cziegeler Date: Mon Nov 1 02:24:09 2004 New Revision: 56222 Modified: cocoon/trunk/src/java/org/apache/cocoon/util/NetUtils.java Log: 1.4 is required
Modified: cocoon/trunk/src/java/org/apache/cocoon/util/NetUtils.java ============================================================================== --- cocoon/trunk/src/java/org/apache/cocoon/util/NetUtils.java (original) +++ cocoon/trunk/src/java/org/apache/cocoon/util/NetUtils.java Mon Nov 1 02:24:09 2004 @@ -17,15 +17,12 @@ import org.apache.cocoon.environment.Request; import org.apache.commons.lang.StringUtils; -import org.apache.commons.lang.SystemUtils; import org.apache.excalibur.source.SourceParameters; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.net.URLDecoder; import java.net.URLEncoder; import java.util.BitSet; @@ -485,43 +482,12 @@ return uri; } - // FIXME Remove when JDK1.3 support is removed. - private static Method urlEncode; - private static Method urlDecode; - - static { - if (SystemUtils.isJavaVersionAtLeast(140)) { - try { - urlEncode = URLEncoder.class.getMethod("encode", new Class[]{String.class, String.class}); - urlDecode = URLDecoder.class.getMethod("decode", new Class[]{String.class, String.class}); - } catch (NoSuchMethodException e) { - // EMPTY - } - } else { - urlEncode = null; - urlDecode = null; - } - } - /** * Pass through to the [EMAIL PROTECTED] java.net.URLEncoder}. If running under JDK < 1.4, * default encoding will always be used. */ public static String encode(String s, String enc) throws UnsupportedEncodingException { - if (urlEncode != null) { - try { - return (String)urlEncode.invoke(s, new Object[]{ s, enc } ); - } catch (IllegalAccessException e) { - // EMPTY - } catch (InvocationTargetException e) { - if (e.getTargetException() instanceof UnsupportedEncodingException) { - throw (UnsupportedEncodingException)e.getTargetException(); - } else if (e.getTargetException() instanceof RuntimeException) { - throw (RuntimeException)e.getTargetException(); - } - } - } - return URLEncoder.encode(s); + return URLEncoder.encode(s, enc); } /** @@ -529,19 +495,6 @@ * default encoding will always be used. */ public static String decode(String s, String enc) throws UnsupportedEncodingException { - if (urlDecode != null) { - try { - return (String)urlDecode.invoke(s, new Object[]{ s, enc } ); - } catch (IllegalAccessException e) { - // EMPTY - } catch (InvocationTargetException e) { - if (e.getTargetException() instanceof UnsupportedEncodingException) { - throw (UnsupportedEncodingException)e.getTargetException(); - } else if (e.getTargetException() instanceof RuntimeException) { - throw (RuntimeException)e.getTargetException(); - } - } - } - return URLDecoder.decode(s); + return URLDecoder.decode(s, enc); } }