List of usage examples for org.apache.commons.codec.net URLCodec decode
public String decode(String pString, String charset) throws DecoderException, UnsupportedEncodingException
From source file:jp.co.worksap.message.decoder.HeaderDecoder.java
private String decodeTextByUrl(String encodedText, String charset) throws UnsupportedEncodingException, DecoderException { URLCodec codec = new URLCodec(); return codec.decode(encodedText, charset); }
From source file:jp.maju.wifiserver.client.ClientActivity.java
@Override public void onClickLink(String url) { if (url.startsWith(CustomWebView.URL_RESULT_REGISTER) || url.startsWith(CustomWebView.URL_RESULT_LOGIN)) { url = url + "&uuid=" + PreferenceUtil.getUUID(getApplication()); }//from ww w .j av a2 s. c o m if (url.startsWith(CustomWebView.URL_TWEET)) { String query = url.substring(CustomWebView.URL_TWEET.length()); String[] params = query.split("&"); String kind = params[0].substring("name=".length()); String msg = params[1].substring("href=".length()); String login = params[2].substring("login=".length()); boolean isLogin = login.equals("true"); Twitter twitter = TwitterUtils.getRegisteredTwitterInstance(getApplication(), false); try { URLCodec codec = new URLCodec(); kind = codec.decode(kind, "UTF-8"); kind = kind.substring(0, kind.length() - 2).toString(); String storedKind = PreferenceUtil.getAnchor(getApplication()); if (storedKind == null) { storedKind = kind; } Logger.d(TAG, kind + "/" + storedKind); if (!kind.equals(storedKind)) { finish(); return; } PreferenceUtil.setAnchor(getApplication(), kind); } catch (UnsupportedEncodingException e) { Logger.e(TAG, e); } catch (DecoderException e) { Logger.e(TAG, e); } if (twitter != null) { Logger.d(TAG, "Twitter is not null"); Logger.d(TAG, "isLogin from server is " + isLogin); Logger.d(TAG, "isLogin from prefs is " + PreferenceUtil.getPreference(getApplication()).getBoolean("isLogin", false)); if (isLogin != PreferenceUtil.getPreference(getApplication()).getBoolean("isLogin", false)) { PreferenceUtil.getPreference(getApplication()).edit().putLong(kind + isLogin, -1L).commit(); } if (PreferenceUtil.isDifferentDate(getApplication(), kind + isLogin)) { PreferenceUtil.getPreference(getApplication()).edit().putBoolean("isLogin", isLogin).commit(); TweetTask tTask = new TweetTask(twitter, isLogin); tTask.setOnTweetResultListener(this); long time = System.currentTimeMillis(); URLCodec codec = new URLCodec(); try { msg = codec.decode(msg, "UTF-8"); PreferenceUtil.setClientMessage(getApplication(), msg, kind + isLogin); msg = msg.replace("${client}", "").replace("${date}", CommonUtil.formatDate(time)) .toString(); Logger.d(TAG, msg); StatusUpdate su = new StatusUpdate(msg); tTask.exec(su); } catch (UnsupportedEncodingException e) { Logger.e(TAG, e); } catch (DecoderException e) { Logger.e(TAG, e); } } } } else { Logger.d(TAG, "Twitter is null"); } sendMessage(url); }
From source file:com.fujitsu.dc.client.DcContext.java
/** * TODO This is not a feature of the original JAVA DAO. There is a need to move to a different class. * @param str String decoded/*from www .j a va2 s . c o m*/ * @return Dedoded URI * @throws UnsupportedEncodingException exception * @throws DecoderException exception */ public final String decodeURI(final String str) throws UnsupportedEncodingException, DecoderException { URLCodec codec = new URLCodec(); return codec.decode(str, "utf-8"); }
From source file:com.fujitsu.dc.client.DcContext.java
/** * TODO This is not a feature of the original JAVA DAO. There is a need to move to a different class. * @param str String decoded//ww w . j a va 2s .c o m * @param charset Character Code * @return Dedoded URI * @throws UnsupportedEncodingException exception * @throws DecoderException exception */ public final String decodeURI(final String str, final String charset) throws UnsupportedEncodingException, DecoderException { URLCodec codec = new URLCodec(); return codec.decode(str, charset); }
From source file:org.apache.hadoop.gateway.util.Urls.java
public static String decode(String str) { URLCodec codec = new URLCodec(); try {/*from ww w. j a va 2s .co m*/ return codec.decode(str, "UTF-8"); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException(e); } catch (DecoderException e) { throw new IllegalArgumentException(e); } }
From source file:org.owasp.jbrofuzz.encode.EncoderHashCore.java
private static String decodeUrlCodec(final String decodeText) { final URLCodec codec = new URLCodec(); try {/*from w ww . ja va 2 s .c om*/ return codec.decode(decodeText, "UTF-8"); } catch (final DecoderException e) { return "Error: www-form-urlencoded value cannot be decoded..."; } catch (final UnsupportedEncodingException e) { return "Error: www-form-urlencoded value cannot be decoded..."; } }