Search in sources :

Example 41 with StringTokenizer

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);
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 42 with StringTokenizer

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();
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 43 with StringTokenizer

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();
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStreamReader(java.io.InputStreamReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Aggregations

StringTokenizer (org.apache.commons.text.StringTokenizer)43 IOException (java.io.IOException)9 Resource (org.springframework.core.io.Resource)9 ArrayList (java.util.ArrayList)8 InputStream (java.io.InputStream)7 Element (org.dom4j.Element)5 AppContextInitializedEvent (com.haulmont.cuba.core.sys.events.AppContextInitializedEvent)3 File (java.io.File)3 TextStringBuilder (org.apache.commons.text.TextStringBuilder)3 Events (com.haulmont.cuba.core.global.Events)2 Properties (java.util.Properties)2 Nullable (javax.annotation.Nullable)2 Preconditions (com.google.common.base.Preconditions)1 Resources (com.haulmont.cuba.core.global.Resources)1 CubaClassPathXmlApplicationContext (com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext)1 DesktopResources (com.haulmont.cuba.desktop.DesktopResources)1 ComponentDecorator (com.haulmont.cuba.desktop.theme.ComponentDecorator)1 Specification (io.github.linuxforhealth.api.Specification)1 Stores (io.jmix.core.Stores)1 Sequence (io.jmix.data.Sequence)1