use of org.apache.commons.text.StringTokenizer in project igloo-parent by igloo-project.
the class FieldPath method fromString.
public static final FieldPath fromString(String string) {
if (StringUtils.isBlank(string)) {
return null;
} else {
List<FieldPathComponent> components = Lists.newLinkedList();
StringTokenizer tokenizer = new StringTokenizer(string, DELIMITER_MATCHER);
for (String token : tokenizer.getTokenList()) {
if (ITEM_TOKEN.equals(token)) {
components.add(FieldPathComponent.ITEM);
} else {
components.add(new FieldPathPropertyComponent(token));
}
}
return new FieldPath(components);
}
}
use of org.apache.commons.text.StringTokenizer in project jmix by jmix-framework.
the class ThemeConstantsRepository method init.
protected void init() {
String configName = environment.getProperty("jmix.ui.theme-config");
if (!StringUtils.isBlank(configName)) {
Map<String, Map<String, String>> themeProperties = new HashMap<>();
StringTokenizer tokenizer = new StringTokenizer(configName);
for (String fileName : tokenizer.getTokenArray()) {
String themeName = parseThemeName(fileName);
if (StringUtils.isNotBlank(themeName)) {
Map<String, String> themeMap = themeProperties.computeIfAbsent(themeName, k -> new HashMap<>());
loadThemeProperties(fileName, themeMap);
}
}
Map<String, ThemeConstants> themes = new LinkedHashMap<>();
for (Map.Entry<String, Map<String, String>> entry : themeProperties.entrySet()) {
themes.put(entry.getKey(), new ThemeConstants(entry.getValue()));
}
this.themeConstantsMap = Collections.unmodifiableMap(themes);
} else {
this.themeConstantsMap = Collections.emptyMap();
}
}
use of org.apache.commons.text.StringTokenizer in project neo4j by neo4j.
the class Config method executeCommand.
private static String executeCommand(String command, Duration timeout) {
Process process = null;
try {
String[] commands = new StringTokenizer(command, StringMatcherFactory.INSTANCE.splitMatcher(), StringMatcherFactory.INSTANCE.quoteMatcher()).getTokenArray();
process = new ProcessBuilder(commands).start();
BufferedReader out = new BufferedReader(new InputStreamReader(process.getInputStream()));
BufferedReader err = new BufferedReader(new InputStreamReader(process.getErrorStream()));
if (!process.waitFor(timeout.toMillis(), TimeUnit.MILLISECONDS)) {
throw new IllegalArgumentException(format("Timed out executing command `%s`", command));
}
String output = out.lines().collect(Collectors.joining(lineSeparator()));
int exitCode = process.exitValue();
if (exitCode != 0) {
String errOutput = err.lines().collect(Collectors.joining(lineSeparator()));
throw new IllegalArgumentException(format("Command `%s` failed with exit code %s.%n%s%n%s", command, exitCode, output, errOutput));
}
return output;
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IllegalArgumentException("Interrupted while executing command", e);
} catch (IOException e) {
throw new IllegalArgumentException(e);
} finally {
if (process != null && process.isAlive()) {
process.destroyForcibly();
}
}
}
Aggregations