1 18 package org.apache.beehive.netui.core; 19 20 import java.io.UnsupportedEncodingException ; 21 22 import org.apache.commons.codec.EncoderException; 23 import org.apache.commons.codec.DecoderException; 24 25 import org.apache.beehive.netui.util.Bundle; 26 27 30 public final class URLCodec { 31 32 private final static org.apache.commons.codec.net.URLCodec s_codec = 33 new org.apache.commons.codec.net.URLCodec(); 34 35 41 public static String encode(final String decoded, final String charset) 42 throws UnsupportedEncodingException { 43 return s_codec.encode(decoded, charset); 44 } 45 46 51 public static String encode(final String decoded) { 52 try { 53 return s_codec.encode(decoded); 54 } catch (EncoderException e) { 55 throw new IllegalStateException (Bundle.getErrorString("URLCodec_encodeException", new String [] {e.getMessage()}), e); 56 } 57 } 58 59 65 public static String decode(final String encoded, final String charset) 66 throws UnsupportedEncodingException { 67 try { 68 return s_codec.decode(encoded, charset); 69 } catch (DecoderException e) { 70 throw new IllegalStateException (Bundle.getErrorString("URLCodec_decodeException", new String [] {e.getMessage()}), e); 71 } 72 } 73 74 75 80 public static String decode(final String encoded) { 81 try { 82 return s_codec.decode(encoded); 83 } catch (DecoderException e) { 84 throw new IllegalStateException (Bundle.getErrorString("URLCodec_decodeException", new String [] {e.getMessage()}), e); 85 } 86 } 87 } 88 | Popular Tags |