hudson.plugins.collabnet.util
Class CommonUtil

java.lang.Object
  extended by hudson.plugins.collabnet.util.CommonUtil

public class CommonUtil
extends java.lang.Object

Class for methods that are useful across Hudson plugins.


Method Summary
static boolean getBoolean(java.lang.String key, net.sf.json.JSONObject formData)
          Returns true if the string value of the key in the form is "true".
static java.lang.String getInterpreted(java.util.Map<java.lang.String,java.lang.String> envVars, java.lang.String str)
          Translates a string that may contain build vars like ${BUILD_VAR} to a string with those vars interpreted.
static void logRE(java.util.logging.Logger logger, java.lang.String methodName, java.rmi.RemoteException re)
          Convenience method to log RemoteExceptions.
static java.util.Collection<java.lang.String> sanitizeForJS(java.util.Collection<java.lang.String> collection)
          Escape characters that may make javascript error (like quotes or backslashes).
static java.lang.String[] splitCommaStr(java.lang.String commaStr)
          Given a comma-delimited string, split it into an array of strings, removing unneccessary whitespace.
static java.lang.String stripSlashes(java.lang.String str)
          String leading and trailing '/'s from a String.
protected static boolean unset(java.lang.String value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getBoolean

public static boolean getBoolean(java.lang.String key,
                                 net.sf.json.JSONObject formData)
Returns true if the string value of the key in the form is "true". If it's missing, returns false.

Parameters:
key - to find value for.
formData - that holds key/value.
Returns:
true if the string value of this key is "true".

getInterpreted

public static java.lang.String getInterpreted(java.util.Map<java.lang.String,java.lang.String> envVars,
                                              java.lang.String str)
Translates a string that may contain build vars like ${BUILD_VAR} to a string with those vars interpreted.

Parameters:
build - the Hudson build.
str - the string to be interpreted.
Returns:
the interpreted string.
Throws:
java.lang.IllegalArgumentException - if the env var is not found.

logRE

public static void logRE(java.util.logging.Logger logger,
                         java.lang.String methodName,
                         java.rmi.RemoteException re)
Convenience method to log RemoteExceptions.

Parameters:
log - to log this message to.
methodName - in progress on when this exception occurred.
re - The RemoteException that was thrown.

sanitizeForJS

public static java.util.Collection<java.lang.String> sanitizeForJS(java.util.Collection<java.lang.String> collection)
Escape characters that may make javascript error (like quotes or backslashes).

Parameters:
collection - list of strings to sanitize
Returns:
collection of sanitized strings.

stripSlashes

public static java.lang.String stripSlashes(java.lang.String str)
String leading and trailing '/'s from a String.

Parameters:
str - string to strip.
Returns:
string without leading or trailing '/'s.

unset

protected static boolean unset(java.lang.String value)
Parameters:
value - string to test.
Returns:
true if a String value is null or empty.

splitCommaStr

public static java.lang.String[] splitCommaStr(java.lang.String commaStr)
Given a comma-delimited string, split it into an array of strings, removing unneccessary whitespace. Also will remove empty values (i.e. only whitespace).

Parameters:
commaStr -
Returns:
an array of the strings, with leading and trailing whitespace removed.


Copyright © 2010. All Rights Reserved.