net.sourceforge.ajaxtags.tags
Class OptionsBuilder

java.lang.Object
  extended by net.sourceforge.ajaxtags.tags.OptionsBuilder

public final class OptionsBuilder
extends Object

Helper class to assist in building options passed to JavaScript method. This class makes no guarantees as to the order of the options; in particular, it does not guarantee that the order will remain constant over time.


Method Summary
 OptionsBuilder add(String parameter, boolean value)
          Add boolean option.
 OptionsBuilder add(String parameter, int value)
          Add integer option.
 OptionsBuilder add(String parameter, String value, boolean quoted)
          Add option.
 OptionsBuilder add(String parameter, String value, boolean quoted, boolean forceWrite)
          Add option.
static OptionsBuilder getOptionsBuilder()
          Get new empty OptionsBuilder.
static OptionsBuilder getOptionsBuilder(OptionsBuilder opt)
          Get new OptionsBuilder with initial options.
 String getOptionsDelimiter()
           
 OptionsBuilder remove(String parameter)
          Remove option.
 void setOptionsDelimiter(String optionsDelimiter)
           
 String toString()
          Create string representation of options (in JSON format).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

getOptionsBuilder

public static OptionsBuilder getOptionsBuilder(OptionsBuilder opt)
Get new OptionsBuilder with initial options.

Parameters:
opt - initial options
Returns:
new empty OptionsBuilder

getOptionsBuilder

public static OptionsBuilder getOptionsBuilder()
Get new empty OptionsBuilder.

Returns:
new empty OptionsBuilder

getOptionsDelimiter

public String getOptionsDelimiter()
Returns:
the optionsDelimiter

setOptionsDelimiter

public void setOptionsDelimiter(String optionsDelimiter)
Parameters:
optionsDelimiter - the optionsDelimiter to set

add

public OptionsBuilder add(String parameter,
                          boolean value)
Add boolean option. Option with given name is added only once.

Parameters:
parameter - name of option
value - value of option
Returns:
updated OptionsBuilder

add

public OptionsBuilder add(String parameter,
                          int value)
Add integer option. Option with given name is added only once.

Parameters:
parameter - name of option
value - value of option
Returns:
updated OptionsBuilder

add

public OptionsBuilder add(String parameter,
                          String value,
                          boolean quoted)
Add option. Option is added only once and only when value is not null. If OptionsBuilder already contains option with given name, it will stay unchanged.

Parameters:
parameter - name of option
value - value of option
quoted - true if value must be surrounded with quotes
Returns:
updated OptionsBuilder

add

public OptionsBuilder add(String parameter,
                          String value,
                          boolean quoted,
                          boolean forceWrite)
Add option. Overwrite previous value if it exists.

Parameters:
parameter - name of option
value - value of option
quoted - true if value must be surrounded with quotes
forceWrite - boolean flag to indicate that previous value must be overwritten
Returns:
updated OptionsBuilder

remove

public OptionsBuilder remove(String parameter)
Remove option.

Parameters:
parameter - name of option
Returns:
updated OptionsBuilder

toString

public String toString()
Create string representation of options (in JSON format).

Overrides:
toString in class Object
Returns:
options as string


Copyright © 2005-2010 The Ajaxtags Team. All Rights Reserved.