2 * Svjatoslav Commons - shared library of common functionality.
3 * Copyright ©2012-2014, Svjatoslav Agejenko, svjatoslav@svjatoslav.eu
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of version 3 of the GNU Lesser General Public License
7 * or later as published by the Free Software Foundation.
10 package eu.svjatoslav.commons.network;
12 public class UrlParamEncoder {
14 public static String decode(final String source) {
16 final String result = source.replaceAll("%20", " ");
21 public static String encode(final String source) {
23 final StringBuffer buffer = new StringBuffer();
24 for (int i = 0; i < source.length(); i++) {
25 boolean replaced = false;
26 final char character = source.charAt(i);
28 if (character == ' ') {
33 if (character == '?') {
38 if (character == ',') {
43 if (character == ':') {
49 buffer.append(character);
52 return buffer.toString();