com.ibm.xsp.util
Class JSUtil

java.lang.Object
  extended by com.ibm.xsp.util.JSUtil

public class JSUtil
extends java.lang.Object

Some basic client side JavaScript utilities.


Field Summary
static int ASCII_MAX
          Maximum printable ASCII character
static int ASCII_MIN
          Minimum printable ASCII character
 
Constructor Summary
JSUtil()
           
 
Method Summary
static void addBoolean(java.lang.StringBuilder b, boolean value)
          Add a boolean value as part of the string your building
static void addDouble(java.lang.StringBuilder b, double value)
          Add a number as part of the string your building
static void addInt(java.lang.StringBuilder b, int value)
          Add a number as part of the string your building
static void addLong(java.lang.StringBuilder b, long value)
          Add a number as part of the string your building
static void addMessage(java.lang.StringBuilder b, java.lang.String s)
          Same as addString except the string is translated text which will not contain any backslashes (\)
static void addNumber(java.lang.StringBuilder b, java.lang.Number value)
          Add a number as part of the string your building
static void addSingleQuoteString(java.lang.StringBuilder b, java.lang.String s)
          Like addString(StringBuilder, String) except using ' instead of ".
static void addString(java.lang.StringBuilder b, java.lang.String s)
          Add a string to a javascript string being constructed
static void addVariable(java.lang.StringBuilder buildingString, java.lang.String variableName)
          Adds a variable parameter for passing to a javascript function
static void appendJavaScriptString(java.lang.StringBuilder b, java.lang.String s)
          Utility for changing a string so that its compatible in JavaScript and does not prevent backslashes.
static void appendJavaScriptString(java.lang.StringBuilder b, java.lang.String s, boolean preventBackslash)
          Utility for changing a string so that its compatbile in javascript Note, this does not handle null values - it will throw a NullPointerException if the value to be appended is null.
static java.lang.String toJavaScriptString(java.lang.String s)
          Utility for changing a string so that its compatbile in javascript Note, this does not handle null values - it will throw a NullPointerException if the value to be appended is null.
static void writeln(javax.faces.context.ResponseWriter writer)
          Writes out a "/n"
static void writelnAfterStartTag(javax.faces.context.ResponseWriter writer)
          Writes out a "/n", differs from writeln because it closes the start tag,
static void writeTextBlank(javax.faces.context.ResponseWriter writer)
          Used to emit a space
static void writeTextBlank(javax.faces.context.ResponseWriter writer, int count)
          Used to emit a space
static void writeTextln(javax.faces.context.ResponseWriter writer)
          Just calls writelnAfterStartTag
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ASCII_MIN

public static final int ASCII_MIN
Minimum printable ASCII character

See Also:
Constant Field Values

ASCII_MAX

public static final int ASCII_MAX
Maximum printable ASCII character

See Also:
Constant Field Values
Constructor Detail

JSUtil

public JSUtil()
Method Detail

addMessage

public static void addMessage(java.lang.StringBuilder b,
                              java.lang.String s)
Same as addString except the string is translated text which will not contain any backslashes (\)

Parameters:
buildingString - String being constructed
String - string to be added when its translated

addString

public static void addString(java.lang.StringBuilder b,
                             java.lang.String s)
Add a string to a javascript string being constructed

Parameters:
buildingString - String being constructed
String - string to be added when its converted

addSingleQuoteString

public static void addSingleQuoteString(java.lang.StringBuilder b,
                                        java.lang.String s)
Like addString(StringBuilder, String) except using ' instead of ". Only used for strings in javascript: values in HTML attributes.

Parameters:
b -
s -

addVariable

public static void addVariable(java.lang.StringBuilder buildingString,
                               java.lang.String variableName)
Adds a variable parameter for passing to a javascript function

Parameters:
buildingString - String being constructed
variableName - Name of variable to add

addInt

public static void addInt(java.lang.StringBuilder b,
                          int value)
Add a number as part of the string your building

Parameters:
buildingString - String being constructed
integer - you want to add

addLong

public static void addLong(java.lang.StringBuilder b,
                           long value)
Add a number as part of the string your building

Parameters:
buildingString - String being constructed
Long - you want to add

addDouble

public static void addDouble(java.lang.StringBuilder b,
                             double value)
Add a number as part of the string your building

Parameters:
buildingString - String being constructed
double - you want to add

addBoolean

public static void addBoolean(java.lang.StringBuilder b,
                              boolean value)
Add a boolean value as part of the string your building

Parameters:
buildingString - String being constructed
boolean - you want to add

addNumber

public static void addNumber(java.lang.StringBuilder b,
                             java.lang.Number value)
Add a number as part of the string your building

Parameters:
buildingString - String being constructed
Number - the number you want to add

appendJavaScriptString

public static void appendJavaScriptString(java.lang.StringBuilder b,
                                          java.lang.String s)
Utility for changing a string so that its compatible in JavaScript and does not prevent backslashes. Note, this does not handle null values - it will throw a NullPointerException if the value to be appended is null.

Parameters:
StringBuilder -
string - converted to comply with javascript

appendJavaScriptString

public static void appendJavaScriptString(java.lang.StringBuilder b,
                                          java.lang.String s,
                                          boolean preventBackslash)
Utility for changing a string so that its compatbile in javascript Note, this does not handle null values - it will throw a NullPointerException if the value to be appended is null.

Parameters:
buildingString - String being constructed
string - converted to comply with javascript
preventBackslash -

toJavaScriptString

public static java.lang.String toJavaScriptString(java.lang.String s)
Utility for changing a string so that its compatbile in javascript Note, this does not handle null values - it will throw a NullPointerException if the value to be appended is null.

Parameters:
String - to convert
Returns:
string converted to comply with javascript

writeln

public static void writeln(javax.faces.context.ResponseWriter writer)
                    throws java.io.IOException
Writes out a "/n"

Parameters:
writer - ResponseWriter
Throws:
java.io.IOException

writelnAfterStartTag

public static void writelnAfterStartTag(javax.faces.context.ResponseWriter writer)
                                 throws java.io.IOException
Writes out a "/n", differs from writeln because it closes the start tag,

Parameters:
writer - ResponseWriter
Throws:
java.io.IOException

writeTextln

public static void writeTextln(javax.faces.context.ResponseWriter writer)
                        throws java.io.IOException
Just calls writelnAfterStartTag

Parameters:
writer - ResponseWriter
Throws:
java.io.IOException

writeTextBlank

public static void writeTextBlank(javax.faces.context.ResponseWriter writer)
                           throws java.io.IOException
Used to emit a space

Parameters:
writer - ResponseWriter
Throws:
java.io.IOException

writeTextBlank

public static void writeTextBlank(javax.faces.context.ResponseWriter writer,
                                  int count)
                           throws java.io.IOException
Used to emit a space

Parameters:
writer - ResponseWriter
count -
Throws:
java.io.IOException