public String toQueryString()
   {
      StringBuilder result = new StringBuilder();

      if ((null != parameters) && !parameters.isEmpty())
      {
         result.append("?");
         Iterator<Entry<String, List<String>>> iterator = parameters.entrySet().iterator();
         while (iterator.hasNext())
         {
            Entry<String, List<String>> entry = iterator.next();
            String key = entry.getKey();
            List<String> values = entry.getValue();

            if ((key != null) && !"".equals(key))
            {
               result.append(key);

               if ((values != null) && !values.isEmpty())
               {
                  for (int i = 0; i < values.size(); i++)
                  {
                     String value = values.get(i);
                     if ((value != null) && !"".equals(value))
                     {
                        result.append("=" + value);
                     }
                     else if ((value != null) && "".equals(value))
                     {
                        result.append("=");
                     }

                     if (i < (values.size() - 1))
                     {
                        result.append("&" + key);
                     }
                  }
               }
            }

            if (iterator.hasNext())
            {
               result.append("&");
            }
         }
      }

      return result.toString();
   }
public String toQueryString()
   {
      StringBuilder result = new StringBuilder();

      if ((null != parameters) && !parameters.isEmpty())
      {
         result.append("?");
         Iterator<Entry<String, List<String>>> iterator = parameters.entrySet().iterator();
         while (iterator.hasNext())
         {
            Entry<String, List<String>> entry = iterator.next();
            String key = entry.getKey();
            List<String> values = entry.getValue();

            if ((key != null) && !"".equals(key))
            {
               result.append(key);

               if ((values != null) && !values.isEmpty())
               {
                  for (int i = 0; i < values.size(); i++)
                  {
                     String value = values.get(i);
                     if ((value != null) && !"".equals(value))
                     {
                        result.append("=" + value);
                     }
                     else if ((value != null) && "".equals(value))
                     {
                        result.append("=");
                     }

                     if (i < (values.size() - 1))
                     {
                        result.append("&" + key);
                     }
                  }
               }
            }

            if (iterator.hasNext())
            {
               result.append("&");
            }
         }
      }

      return result.toString();
   }
public String toQueryString ( ) { StringBuilder result = new StringBuilder ( ) ; if ( ( null != parameters ) && ! parameters . isEmpty ( ) ) { result . append ( "?" ) ; Iterator < Entry < String , List < String > > > iterator = parameters . entrySet ( ) . iterator ( ) ; while ( iterator . hasNext ( ) ) { Entry < String , List < String > > entry = iterator . next ( ) ; String key = entry . getKey ( ) ; List < String > values = entry . getValue ( ) ; if ( ( key != null ) && ! "" . equals ( key ) ) { result . append ( key ) ; if ( ( values != null ) && ! values . isEmpty ( ) ) { for ( int i = 0 ; i < values . size ( ) ; i ++ ) { String value = values . get ( i ) ; if ( ( value != null ) && ! "" . equals ( value ) ) { result . append ( "=" + value ) ; } else if ( ( value != null ) && "" . equals ( value ) ) { result . append ( "=" ) ; } if ( i < ( values . size ( ) - 1 ) ) { result . append ( "&" + key ) ; } } } } if ( iterator . hasNext ( ) ) { result . append ( "&" ) ; } } } return result . toString ( ) ; }
Convert the current parameters to a valid query string, including the leading '?' character.
<p>

For example, a {@link QueryStringBuilder} with the values [key=>value, name=>value1,value2,value3] will become:

<pre>

?key=value&name=value1&name=value2&name=value3
</pre>

@return If parameters exist, return a valid query string with leading '?' character. If no parameters exist,
return an empty string.
Convert the current parameters to a valid query string including the leading ? character . <p >