ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / plugins / maven / src / main / java / org / jetbrains / idea / maven / utils / Strings.java
blob05c16e75bdbe75c8ec6dc5d6cfe4623474b29809
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package org.jetbrains.idea.maven.utils;
18 import org.jetbrains.annotations.NonNls;
20 import java.util.ArrayList;
21 import java.util.Collection;
22 import java.util.List;
23 import java.util.StringTokenizer;
25 /**
26 * @author Vladislav.Kaznacheev
28 public class Strings {
29 @NonNls public static final String WHITESPACE = " \t\n\r\f";
31 public static List<String> tokenize(final String string, final String delim) {
32 final List<String> tokens = new ArrayList<String>();
33 for ( StringTokenizer tokenizer = new StringTokenizer(string, delim); tokenizer.hasMoreTokens();) {
34 tokens.add(tokenizer.nextToken());
36 return tokens;
39 public static String detokenize(final Collection<String> list, final char delim) {
40 final StringBuilder buffer = new StringBuilder();
41 for ( String goal : list) {
42 if(buffer.length()!=0){
43 buffer.append(delim);
45 buffer.append(goal);
47 return buffer.toString();
50 public static String translateMasks(final Collection<String> masks) {
51 final StringBuilder patterns = new StringBuilder();
52 for (String mask : masks) {
53 if (patterns.length() != 0) {
54 patterns.append('|');
56 patterns.append(translateToRegex(mask));
58 return patterns.toString();
61 private static String translateToRegex(final String mask) {
62 return mask.replaceAll("\\.", "\\.").replaceAll("\\*", ".*").replaceAll("\\?", ".");