org.ferris.net
Class UrlStringBuilder

java.lang.Object
  extended by org.ferris.net.UrlStringBuilder

public class UrlStringBuilder
extends Object

The purpose of this class is to take a URL object convert it to a String, then allow the addition of request query parameters (fname=michael,lname=remijan) and then convert the String back to a URL object. This class will use URLEncoder to make sure special characters are escaped properly.

Author:
mjremij

Constructor Summary
UrlStringBuilder()
          Default constructor
UrlStringBuilder(URL url)
          Get url.toString() put it in a StringBuilder then append the "?" character.
 
Method Summary
 void append(boolean value)
          Regular StringBuilder append
 void append(byte value)
          Regular StringBuilder append
 void append(char value)
          Regular StringBuilder append
 void append(double value)
          Regular StringBuilder append
 void append(float value)
          Regular StringBuilder append
 void append(int value)
          Regular StringBuilder append
 void append(long value)
          Regular StringBuilder append
 void append(Object value)
          Regular StringBuilder append
 void append(short value)
          Regular StringBuilder append
 void append(String value)
          Regular StringBuilder append
 void append(String name, boolean value)
          Append name/value pair when value is a boolean.
 void append(String name, byte value)
          Append name/value pair when value is a byte.
 void append(String name, char value)
          Append name/value pair when value is a char.
 void append(String name, double value)
          Append name/value pair when value is a double.
 void append(String name, float value)
          Append name/value pair when value is a float.
 void append(String name, int value)
          Append name/value pair when value is an int.
 void append(String name, long value)
          Append name/value pair when value is a long.
 void append(String name, Object value)
          Append name/value pair when value is a Object using Object.toString() and then using URLEncoder to encode using encoding UTF-8 to make sure special characters are handled correctly.
 void append(String name, short value)
          Append name/value pair when value is an short.
 void append(String name, String value)
          Append name/value pair when value is a String, use URLEncoder to encode using encoding UTF-8 to make sure special characters are handled correctly.
 String toString()
          Return what's been appended to this builder
 URL toUrl()
          Get a new URL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UrlStringBuilder

public UrlStringBuilder()
Default constructor


UrlStringBuilder

public UrlStringBuilder(URL url)
Get url.toString() put it in a StringBuilder then append the "?" character. After this call the append(..) methods to add request query parameters after the "?". If you're URL already has request query parameters in it that's ok, this class will just append more on. When done, call the toUrl() method to get a new URL object.

Parameters:
url -
Throws:
NetException
Method Detail

toUrl

public URL toUrl()
Get a new URL


append

public void append(String name,
                   double value)
Append name/value pair when value is a double.


append

public void append(String name,
                   int value)
Append name/value pair when value is an int.


append

public void append(String name,
                   short value)
Append name/value pair when value is an short.


append

public void append(String name,
                   boolean value)
Append name/value pair when value is a boolean.


append

public void append(String name,
                   char value)
Append name/value pair when value is a char.


append

public void append(String name,
                   byte value)
Append name/value pair when value is a byte.


append

public void append(String name,
                   long value)
Append name/value pair when value is a long.


append

public void append(String name,
                   float value)
Append name/value pair when value is a float.


append

public void append(String name,
                   String value)
Append name/value pair when value is a String, use URLEncoder to encode using encoding UTF-8 to make sure special characters are handled correctly. if value == null do not include in the query string.


append

public void append(String name,
                   Object value)
Append name/value pair when value is a Object using Object.toString() and then using URLEncoder to encode using encoding UTF-8 to make sure special characters are handled correctly. if value == null do not include in the query string.


append

public void append(boolean value)
Regular StringBuilder append


append

public void append(char value)
Regular StringBuilder append


append

public void append(byte value)
Regular StringBuilder append


append

public void append(short value)
Regular StringBuilder append


append

public void append(int value)
Regular StringBuilder append


append

public void append(long value)
Regular StringBuilder append


append

public void append(float value)
Regular StringBuilder append


append

public void append(double value)
Regular StringBuilder append


append

public void append(String value)
Regular StringBuilder append


append

public void append(Object value)
Regular StringBuilder append


toString

public String toString()
Return what's been appended to this builder

Overrides:
toString in class Object


Copyright © Jun 11, 2009-2011 The Ferris Foundation. All Rights Reserved.