Package org.apache.commons.httpclient.util

Examples of org.apache.commons.httpclient.util.ParameterFormatter


    private final ParameterFormatter formatter;
   
    /** Default constructor */   
    public RFC2109Spec() {
        super();
        this.formatter = new ParameterFormatter();
        this.formatter.setAlwaysUseQuotes(true);
    }
View Full Code Here


     * @since 3.0
     */
    public DigestScheme() {
        super();
        this.complete = false;
        this.formatter = new ParameterFormatter();
        this.formatter.setAlwaysUseQuotes(true);
    }
View Full Code Here

  throws IOException {
    doPostMethod(FileLocationDBServlet.REMOVE_OPERATION, arcName, arcUrl);
  }
 
  private String doGetMethod(NameValuePair[] data) throws IOException {
    ParameterFormatter formatter = new ParameterFormatter();
    formatter.setAlwaysUseQuotes(false);
    StringBuilder finalUrl = new StringBuilder(serverUrl);
    if(data.length > 0) {
      finalUrl.append("?");
    }
    for(int i = 0; i < data.length; i++) {
      if(i == 0) {
        finalUrl.append("?");
      } else {
        finalUrl.append("&");
      }
      finalUrl.append(formatter.format(data[i]));
    }

    GetMethod method = new GetMethod(finalUrl.toString());
   
        int statusCode = client.executeMethod(method);
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestParameterFormatter.class);
    }

    public void testBasicValueFormatting() throws Exception {
        ParameterFormatter formatter = new ParameterFormatter();
       
        NameValuePair param1 = new NameValuePair("param", "regular_stuff");
        NameValuePair param2 = new NameValuePair("param", "this\\that");
        NameValuePair param3 = new NameValuePair("param", "this,that");
        NameValuePair param4 = new NameValuePair("param", "quote marks (\") must be escaped");
        NameValuePair param5 = new NameValuePair("param", "back slash (\\) must be escaped too");
        NameValuePair param6 = new NameValuePair("param", "values with\tblanks must always be quoted");
       
        formatter.setAlwaysUseQuotes(false);
        assertEquals("param=regular_stuff", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));

        formatter.setAlwaysUseQuotes(true);
        assertEquals("param=\"regular_stuff\"", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));
    }
View Full Code Here

     * @since 3.0
     */
    public DigestScheme() {
        super();
        this.complete = false;
        this.formatter = new ParameterFormatter();
    }
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestParameterFormatter.class);
    }

    public void testBasicValueFormatting() throws Exception {
        ParameterFormatter formatter = new ParameterFormatter();
       
        NameValuePair param1 = new NameValuePair("param", "regular_stuff");
        NameValuePair param2 = new NameValuePair("param", "this\\that");
        NameValuePair param3 = new NameValuePair("param", "this,that");
        NameValuePair param4 = new NameValuePair("param", "quote marks (\") must be escaped");
        NameValuePair param5 = new NameValuePair("param", "back slash (\\) must be escaped too");
        NameValuePair param6 = new NameValuePair("param", "values with\tblanks must always be quoted");
       
        formatter.setAlwaysUseQuotes(false);
        assertEquals("param=regular_stuff", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));

        formatter.setAlwaysUseQuotes(true);
        assertEquals("param=\"regular_stuff\"", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));
    }
View Full Code Here

     * @since 3.0
     */
    public DigestScheme() {
        super();
        this.complete = false;
        this.formatter = new ParameterFormatter();
    }
View Full Code Here

    public static Test suite() {
        return new TestSuite(TestParameterFormatter.class);
    }

    public void testBasicValueFormatting() throws Exception {
        ParameterFormatter formatter = new ParameterFormatter();
       
        NameValuePair param1 = new NameValuePair("param", "regular_stuff");
        NameValuePair param2 = new NameValuePair("param", "this\\that");
        NameValuePair param3 = new NameValuePair("param", "this,that");
        NameValuePair param4 = new NameValuePair("param", "quote marks (\") must be escaped");
        NameValuePair param5 = new NameValuePair("param", "back slash (\\) must be escaped too");
        NameValuePair param6 = new NameValuePair("param", "values with\tblanks must always be quoted");
       
        formatter.setAlwaysUseQuotes(false);
        assertEquals("param=regular_stuff", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));

        formatter.setAlwaysUseQuotes(true);
        assertEquals("param=\"regular_stuff\"", formatter.format(param1));
        assertEquals("param=\"this\\\\that\"", formatter.format(param2));
        assertEquals("param=\"this,that\"", formatter.format(param3));
        assertEquals("param=\"quote marks (\\\") must be escaped\"", formatter.format(param4));
        assertEquals("param=\"back slash (\\\\) must be escaped too\"", formatter.format(param5));
        assertEquals("param=\"values with\tblanks must always be quoted\"", formatter.format(param6));
    }
View Full Code Here

    private final ParameterFormatter formatter;
   
    /** Default constructor */   
    public RFC2109Spec() {
        super();
        this.formatter = new ParameterFormatter();
        this.formatter.setAlwaysUseQuotes(true);
    }
View Full Code Here

     * @since 3.0
     */
    public DigestScheme() {
        super();
        this.complete = false;
        this.formatter = new ParameterFormatter();
    }
View Full Code Here

TOP

Related Classes of org.apache.commons.httpclient.util.ParameterFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.