common/src/main/java/HTTPClient/Codecs.java
/**
     * This method decodes the given urlencoded string.
     *
     * @param  str the url-encoded string
     * @return the decoded string
     * @exception ParseException If a '%' is not followed by a valid
     *                           2-digit hex number.
     */
This method decodes the given urlencoded string.
@param  str the url-encoded string
@return the decoded string
@exception ParseException If a '%' is not followed by a valid
2-digit hex number.
This method decodes the given urlencoded string . @param str the url - encoded string @return the decoded string @exception ParseException If a ' % ' is not followed by a valid 2 - digit hex number .
public final static String URLDecode(String str) throws ParseException
    {
	if (str == null)  return  null;
	char[] res  = new char[str.length()];
	int    didx = 0;
	for (int sidx=0; sidx<str.length(); sidx++)
	{
	    char ch = str.charAt(sidx);
	    if (ch == '+')
		res[didx++] = ' ';
	    else if (ch == '%')
	    {
		try
		{
		    res[didx++] = (char)
			Integer.parseInt(str.substring(sidx+1,sidx+3), 16);
		    sidx += 2;
		}
		catch (NumberFormatException e)
		{
		    throw new ParseException(str.substring(sidx,sidx+3) +
					    " is an invalid code");
		}
	    }
	    else
		res[didx++] = ch;
	}
	return String.valueOf(res, 0, didx);
    }
public final static String URLDecode ( String str ) throws ParseException { if ( str == null ) return null ; char [ ] res = new char [ str . length ( ) ] ; int didx = 0 ; for ( int sidx = 0 ; sidx < str . length ( ) ; sidx ++ ) { char ch = str . charAt ( sidx ) ; if ( ch == '+' ) res [ didx ++ ] = ' ' ; else if ( ch == '%' ) { try { res [ didx ++ ] = ( char ) Integer . parseInt ( str . substring ( sidx + 1 , sidx + 3 ) , 16 ) ; sidx += 2 ; } catch ( NumberFormatException e ) { throw new ParseException ( str . substring ( sidx , sidx + 3 ) + " is an invalid code" ) ; } } else res [ didx ++ ] = ch ; } return String . valueOf ( res , 0 , didx ) ; }
This method decodes the given urlencoded string.
This method decodes the given urlencoded string .