nu.staldal.lsp.framework
Class Utils

java.lang.Object
  extended by nu.staldal.lsp.framework.Utils

public final class Utils
extends java.lang.Object

Miscellaneous static utility methods.


Method Summary
static java.lang.String escapeJavascriptString(java.lang.CharSequence s)
          Escape a string for a Javascript literal.
static int parseInteger(java.lang.String s, int err)
          Parse a string as an integer.
static java.util.List<java.lang.String> splitString(java.lang.CharSequence s, char delim)
          Split a string into a list of substrings using a specified character as delimiter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

parseInteger

public static int parseInteger(java.lang.String s,
                               int err)
Parse a string as an integer. Does not throw any exception, not even if the string is null.

Parameters:
s - the string to parse
err - the integer to return if the string does not contain any valid integer
Returns:
err if the string cannot be parsed as an integer.

splitString

public static java.util.List<java.lang.String> splitString(java.lang.CharSequence s,
                                                           char delim)
Split a string into a list of substrings using a specified character as delimiter. Will return empty strings in the list if the there are several adjacent delimiter characters.

Parameters:
s - the string to split
delim - the delimiter character
Returns:
the splitted string

escapeJavascriptString

public static java.lang.String escapeJavascriptString(java.lang.CharSequence s)
Escape a string for a Javascript literal. Uses backslash escapes like Java. Escapes \ " ' and newline (\n), CR (\r) is ignored.

Parameters:
s - the string to escape
Returns:
the escaped string