common/src/main/java/HTTPClient/Codecs.java
/**
     * Turns a string of the form "name1=value1&name2=value2&name3=value3"
     * into an array of name/value pairs. The names and values are
     * urldecoded. The query string is in the form in which form-data is
     * received in a cgi script.
     *
     * @param query the query string containing the encoded name/value pairs
     * @return an array of NVPairs
     * @exception ParseException If the '=' is missing in any field, or if
     *				 the urldecoding of the name or value fails
     */
Turns a string of the form "name1=value1&name2=value2&name3=value3"
into an array of name/value pairs. The names and values are
urldecoded. The query string is in the form in which form-data is
received in a cgi script.

@param query the query string containing the encoded name/value pairs
@return an array of NVPairs
@exception ParseException If the '=' is missing in any field, or if
the urldecoding of the name or value fails
Turns a string of the form " name1 = value1&name2 = value2&name3 = value3 " into an array of name / value pairs . The names and values are urldecoded . The query string is in the form in which form - data is received in a cgi script . @param query the query string containing the encoded name / value pairs @return an array of NVPairs @exception ParseException If the ' = ' is missing in any field or if the urldecoding of the name or value fails
public final static NVPair[] query2nv(String query)  throws ParseException
    {
	if (query == null) return null;
	int idx = -1,
	    cnt = 1;
	while ((idx = query.indexOf('&', idx+1)) != -1)  cnt ++;
	NVPair[] pairs = new NVPair[cnt];
	for (idx=0, cnt=0; cnt<pairs.length; cnt++)
	{
	    int eq  = query.indexOf('=', idx);
	    int end = query.indexOf('&', idx);
	    if (end == -1)  end = query.length();
	    if (eq == -1  ||  eq >= end)
		throw new ParseException("'=' missing in " +
					 query.substring(idx, end));
	    pairs[cnt] =
		    new  NVPair(URLDecode(query.substring(idx,eq)),
				URLDecode(query.substring(eq+1,end)));
	    idx = end + 1;
	}
	return pairs;
    }
public final static NVPair [ ] query2nv ( String query ) throws ParseException { if ( query == null ) return null ; int idx = - 1 , cnt = 1 ; while ( ( idx = query . indexOf ( '&' , idx + 1 ) ) != - 1 ) cnt ++ ; NVPair [ ] pairs = new NVPair [ cnt ] ; for ( idx = 0 , cnt = 0 ; cnt < pairs . length ; cnt ++ ) { int eq = query . indexOf ( '=' , idx ) ; int end = query . indexOf ( '&' , idx ) ; if ( end == - 1 ) end = query . length ( ) ; if ( eq == - 1 || eq >= end ) throw new ParseException ( "'=' missing in " + query . substring ( idx , end ) ) ; pairs [ cnt ] = new NVPair ( URLDecode ( query . substring ( idx , eq ) ) , URLDecode ( query . substring ( eq + 1 , end ) ) ) ; idx = end + 1 ; } return pairs ; }
Turns a string of the form "name1=value1&name2=value2&name3=value3"
 into an array of name/value pairs.
Turns a string of the form " name1 = value1&name2 = value2&name3 = value3 " into an array of name / value pairs .