Exemple #1
0
  /**
   * Splits the input string into strings separated by the delimiter and put them into a Vector.
   *
   * @param delimiter splitting delimiter
   * @param input input string
   * @return returns a Vector containing the substrings of the input that occur between delimiter.
   *     Returns the Vector with original string as only the element when the delimiter is not found
   *     in the input string.
   * @exception throws a FrameworkException when either input/delimiter is null.
   */
  public static Vector split(String delimiter, String input) throws FrameworkException {
    if (input == null || delimiter == null) {
      throw new FrameworkException(
          "RegexUtils: split(): input or delimiter is null."
              + "input ="
              + input
              + ", "
              + "delimiter = "
              + delimiter);
    }

    Perl5Util util = new Perl5Util();
    Vector result = new Vector();

    // convert the delimiter to the perl5 format
    delimiter = makePerl5MatchPattern(delimiter);

    try {
      // Populate the vector argument with split strings
      util.split(result, delimiter, input, util.SPLIT_ALL);
    } catch (MalformedPerl5PatternException e) {
      throw new FrameworkException("RegexUtils: split():" + e.getMessage());
    }

    return result;
  }