com.getsnappy.snappyj
Class StringUtil

java.lang.Object
  extended by com.getsnappy.snappyj.StringUtil

public class StringUtil
extends java.lang.Object


Field Summary
static java.lang.String JAVA_SCRIPT_PREFIX
           
 
Constructor Summary
StringUtil()
           
 
Method Summary
static java.lang.String dontQuote(java.lang.String in)
          When passing Strings into js<...> methods, they will be passed through jsQuote to be properly quoted.
static java.lang.String jsQuote(java.lang.Boolean b)
          Returns either undefined, true or false
static java.lang.String jsQuote(java.lang.Integer i)
          Currently to calls the String version
static java.lang.String jsQuote(java.lang.Long l)
          Currently to calls the String version
static java.lang.String jsQuote(java.lang.String string)
          Take the given string and return a string in a format suitable for JavaScript.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JAVA_SCRIPT_PREFIX

public static final java.lang.String JAVA_SCRIPT_PREFIX
See Also:
Constant Field Values
Constructor Detail

StringUtil

public StringUtil()
Method Detail

dontQuote

public static java.lang.String dontQuote(java.lang.String in)
When passing Strings into js<...> methods, they will be passed through jsQuote to be properly quoted. Wrap the String with this function call, and jsQuote will return the String as is. This is useful when passing JavaScript to one of the js<...> methods.

For Example (this example will set and persist the value the input element (haha) to the calendarBean attribute TYPE):
out.write("haha\" onclick=\"" + calendarBean.jsSet(CategoryChooserBean.TYPE, StringUtil.dontQuote("this.value")) + "\">\n");

Parameters:
in -
Returns:

jsQuote

public static java.lang.String jsQuote(java.lang.String string)
Take the given string and return a string in a format suitable for JavaScript. Heres the algoritm. If the string was passed through of StringUtiluote, then it is returned as is. If the string begin and ends with the single quote char, then is is returned as is. Otherwise this function adds a leading and trailing single qoute and escapes both single quotes and double quotes with a forward slash.

If you literally want the result to be a single quoted string ("'fdsdfsdfd'" or '\'fsdfsdfd\''), you must pass explicitly pass '\'fsdfsdfd\''.

Parameters:
queryString -
Returns:
a string suitable for use in javascript.

jsQuote

public static java.lang.String jsQuote(java.lang.Long l)
Currently to calls the String version

Parameters:
string -
Returns:

jsQuote

public static java.lang.String jsQuote(java.lang.Integer i)
Currently to calls the String version

Parameters:
string -
Returns:

jsQuote

public static java.lang.String jsQuote(java.lang.Boolean b)
Returns either undefined, true or false

Parameters:
string -
Returns: