org.arquillian.droidium.container.utils.StringUtils Maven / Gradle / Ivy
/*
* JBoss, Home of Professional Open Source
* Copyright 2011, Red Hat Middleware LLC, and individual contributors
* by the @authors tag. See the copyright.txt in the distribution for a
* full listing of individual contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.arquillian.droidium.container.utils;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Utility class to parse a list of strings
*
* @author tokenize(String stringToBeParsed) {
final String TOKEN = "\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"|\\S+";
final String QUOTED_TOKEN = "^\"(.*)\"$";
List options = new ArrayList();
if (stringToBeParsed != null && stringToBeParsed.length() != 0) {
Pattern p = Pattern.compile(TOKEN, Pattern.DOTALL);
Matcher m = p.matcher(stringToBeParsed);
while (m.find()) {
if (!(m.group().trim().equals(""))) {
options.add(Pattern.compile(QUOTED_TOKEN, Pattern.DOTALL).matcher(m.group().trim()).replaceAll("$1"));
}
}
}
return options;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy