コード例 #1
0
ファイル: TextUtil.java プロジェクト: olivierlamotte/afc
	/** Split the given string according to separators.
	 * The separators are used to delimit the groups
	 * of characters.
	 * <p>
	 * Examples:
	 * <ul>
	 * <li><code>split('{','}',"{a}{b}{cd}")</code> returns the array
	 * <code>["a","b","cd"]</code></li>
	 * <li><code>split('{','}',"abcd")</code> returns the array
	 * <code>["abcd"]</code></li>
	 * <li><code>split('{','}',"a{bcd")</code> returns the array
	 * <code>["a","bcd"]</code></li>
	 * <ul>
	 * 
	 * @param leftSeparator is the left separator.
	 * @param rightSeparator is the right separator.
	 * @param str is the elements enclosed by backets.
	 * @return the groups of strings
	 */
	public static List<String> splitAsList(char leftSeparator, char rightSeparator, String str) {
		List<String> list = new ArrayList<String>();
		splitSeparatorAlgorithm(
				leftSeparator, rightSeparator, str,
				new SplitSeparatorToListAlgorithm(list));
		return list;
	}
コード例 #2
0
ファイル: TextUtil.java プロジェクト: olivierlamotte/afc
	/** Split the given string according to separators.
	 * The separators are used to delimit the groups
	 * of characters.
	 * <p>
	 * Examples:
	 * <ul>
	 * <li><code>split('{','}',"{a}{b}{cd}")</code> returns the array
	 * <code>["a","b","cd"]</code></li>
	 * <li><code>split('{','}',"abcd")</code> returns the array
	 * <code>["abcd"]</code></li>
	 * <li><code>split('{','}',"a{bcd")</code> returns the array
	 * <code>["a","bcd"]</code></li>
	 * <ul>
	 * 
	 * @param leftSeparator is the left separator.
	 * @param rightSeparator is the right separator.
	 * @param str is the elements enclosed by backets.
	 * @return the groups of strings
	 * @since 4.0
	 */
	public static List<UUID> splitAsUUIDs(char leftSeparator, char rightSeparator, String str) {
		List<UUID> list = new ArrayList<UUID>();
		splitSeparatorAlgorithm(leftSeparator, rightSeparator, str, new UUIDSplitSeparatorAlgorithm(list));
		return list;
	}
コード例 #3
0
ファイル: TextUtil.java プロジェクト: olivierlamotte/afc
	/** Split the given string according to the separators.
	 * The separators are used to delimit the groups
	 * of characters.
	 * <p>
	 * Examples:
	 * <ul>
	 * <li><code>split('{','}',"{a}{b}{cd}")</code> returns the array
	 * <code>["a","b","cd"]</code></li>
	 * <li><code>split('{','}',"abcd")</code> returns the array
	 * <code>["abcd"]</code></li>
	 * <li><code>split('{','}',"a{bcd")</code> returns the array
	 * <code>["a","bcd"]</code></li>
	 * <ul>
	 * 
	 * @param leftSeparator is the left separator.
	 * @param rightSeparator is the right separator.
	 * @param str is the strig with brackets.
	 * @return the groups of strings
	 * @since 4.0
	 */
	public static String[] split(char leftSeparator, char rightSeparator, String str) {
		SplitSeparatorToArrayAlgorithm algo = new SplitSeparatorToArrayAlgorithm();
		splitSeparatorAlgorithm(leftSeparator, rightSeparator, str, algo);
		return algo.toArray();
	}