public static Map<String, String[]> createParameterMap(String query, boolean decodeParameters, String encoding) {

        if (CmsStringUtil.isEmpty(query)) {
            // empty query
            return new HashMap<String, String[]>();
        }
        if (query.charAt(0) == URL_DELIMITER.charAt(0)) {
            // remove leading '?' if required
            query = query.substring(1);
        }
        // cut along the different parameters
        String[] params = CmsStringUtil.splitAsArray(query, PARAMETER_DELIMITER);
        Map<String, String[]> parameters = new HashMap<String, String[]>(params.length);
        for (int i = 0; i < params.length; i++) {
            String key = null;
            String value = null;
            // get key and value, separated by a '='
            int pos = params[i].indexOf(PARAMETER_ASSIGNMENT);
            if (pos > 0) {
                key = params[i].substring(0, pos);
                value = params[i].substring(pos + 1);
            } else if (pos < 0) {
                key = params[i];
                value = "";
            }
            // adjust the key if it starts with "amp;"
            // this happens when "&amp;" is used instead of a simple "&"
            if ((key != null) && (key.startsWith(AMP))) {
                key = key.substring(AMP.length());
            }
            // now make sure the values are of type String[]
            if (key != null) {
                if (decodeParameters) {
                    key = CmsEncoder.decode(key, encoding);
                    value = CmsEncoder.decode(value, encoding);
                }
                String[] values = parameters.get(key);
                if (values == null) {
                    // this is the first value, create new array
                    values = new String[] {value};
                } else {
                    // append to the existing value array
                    String[] copy = new String[values.length + 1];
                    System.arraycopy(values, 0, copy, 0, values.length);
                    copy[copy.length - 1] = value;
                    values = copy;
                }
                parameters.put(key, values);
            }
        }
        return parameters;
    }
public static Map < String , String [ ] > createParameterMap ( String query , boolean decodeParameters , String encoding ) { if ( CmsStringUtil . isEmpty ( query ) ) { return new HashMap < String , String [ ] > ( ) ; } if ( query . charAt ( 0 ) == URL_DELIMITER . charAt ( 0 ) ) { query = query . substring ( 1 ) ; } String [ ] params = CmsStringUtil . splitAsArray ( query , PARAMETER_DELIMITER ) ; Map < String , String [ ] > parameters = new HashMap < String , String [ ] > ( params . length ) ; for ( int i = 0 ; i < params . length ; i ++ ) { String key = null ; String value = null ; int pos = params [ i ] . indexOf ( PARAMETER_ASSIGNMENT ) ; if ( pos > 0 ) { key = params [ i ] . substring ( 0 , pos ) ; value = params [ i ] . substring ( pos + 1 ) ; } else if ( pos < 0 ) { key = params [ i ] ; value = "" ; } if ( ( key != null ) && ( key . startsWith ( AMP ) ) ) { key = key . substring ( AMP . length ( ) ) ; } if ( key != null ) { if ( decodeParameters ) { key = CmsEncoder . decode ( key , encoding ) ; value = CmsEncoder . decode ( value , encoding ) ; } String [ ] values = parameters . get ( key ) ; if ( values == null ) { values = new String [ ] { value } ; } else { String [ ] copy = new String [ values . length + 1 ] ; System . arraycopy ( values , 0 , copy , 0 , values . length ) ; copy [ copy . length - 1 ] = value ; values = copy ; } parameters . put ( key , values ) ; } } return parameters ; }
Parses the parameters of the given request query part, optionally decodes them, and creates a parameter map out of them.<p>

Please note: This does not parse a full request URI/URL, only the query part that
starts after the "?". For example, in the URI <code>/system/index.html?a=b&amp;c=d</code>,
the query part is <code>a=b&amp;c=d</code>.<p>

If the given String is empty, an empty map is returned.<p>

@param query the query to parse
@param decodeParameters a flag, indicating if the parameters should be decoded.
@param encoding the character encoding used while decoding. If <code>null</code>, the default character encoding is used.
@return the parameter map created from the query