Exemple #1
0
 /**
  * Tests if obj is javaScript function header.<br>
  * Obj must be a non-null String and match "^function[ ]?\\(.*\\)$"
  */
 public static boolean isFunctionHeader(Object obj) {
   if (obj instanceof String) {
     String str = (String) obj;
     return str.startsWith(FUNCTION_PREFIX)
         && RegexpUtils.getMatcher(FUNCTION_HEADER_PATTERN, true).matches(str);
   }
   return false;
 }
Exemple #2
0
 /** Returns the params of a function literal. */
 public static String getFunctionParams(String function) {
   return RegexpUtils.getMatcher(FUNCTION_PARAMS_PATTERN, true).getGroupIfMatches(function, 1);
 }
Exemple #3
0
 /** Returns the body of a function literal. */
 public static String getFunctionBody(String function) {
   return RegexpUtils.getMatcher(FUNCTION_BODY_PATTERN, true).getGroupIfMatches(function, 1);
 }