Search in sources :

Example 16 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project synopsys-detect by blackducksoftware.

the class CommandParser method parseCommandString.

public List<String> parseCommandString(String commandString) {
    logger.trace(String.format("origCommand         : %s", commandString));
    String quotesRemovedCommand = encodeQuotedWhitespace(commandString);
    logger.trace(String.format("quotesRemovedCommand: %s", quotesRemovedCommand));
    StringTokenizer tokenizer = new StringTokenizer(quotesRemovedCommand);
    tokenizer.setQuoteMatcher(StringMatcherFactory.INSTANCE.quoteMatcher());
    List<String> commandList = new ArrayList<>();
    while (tokenizer.hasNext()) {
        String token = tokenizer.nextToken();
        String part = restoreWhitespace(token);
        commandList.add(part);
    }
    return commandList;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) ArrayList(java.util.ArrayList)

Example 17 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class DesktopExternalUIComponentsSource method _registerAppComponents.

protected void _registerAppComponents() {
    String configNames = AppContext.getProperty(DESKTOP_COMPONENTS_CONFIG_XML_PROP);
    if (Strings.isNullOrEmpty(configNames)) {
        return;
    }
    log.debug("Loading UI components from {}", configNames);
    StringTokenizer tokenizer = new StringTokenizer(configNames);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                _registerComponent(stream);
            } catch (ClassNotFoundException | IOException e) {
                throw new RuntimeException("Unable to load components config " + location, e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource {} not found, ignore it", location);
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Example 18 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class TestContainer method initAppContext.

protected void initAppContext() {
    EclipseLinkCustomizer.initTransientCompatibleAnnotations();
    String configProperty = AppContext.getProperty(AbstractAppContextLoader.SPRING_CONTEXT_CONFIG);
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    List<String> locations = tokenizer.getTokenList();
    StringTokenizer configTokenizer = new StringTokenizer(getSpringConfig());
    locations.addAll(configTokenizer.getTokenList());
    springAppContext = new CubaClassPathXmlApplicationContext(locations.toArray(new String[0]));
    AppContext.Internals.setApplicationContext(springAppContext);
    Events events = springAppContext.getBean(Events.NAME, Events.class);
    events.publish(new AppContextInitializedEvent(springAppContext));
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) Events(com.haulmont.cuba.core.global.Events) AppContextInitializedEvent(com.haulmont.cuba.core.sys.events.AppContextInitializedEvent) CubaClassPathXmlApplicationContext(com.haulmont.cuba.core.sys.CubaClassPathXmlApplicationContext)

Example 19 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class DefaultPermissionValuesConfig method init.

protected void init() {
    permissionValues.clear();
    String configName = AppContext.getProperty("cuba.defaultPermissionValuesConfig");
    if (!StringUtils.isBlank(configName)) {
        StringTokenizer tokenizer = new StringTokenizer(configName);
        for (String fileName : tokenizer.getTokenArray()) {
            parseConfigFile(fileName);
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 20 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project cuba by cuba-platform.

the class AppPropertiesTest method testEmptyStringSubstitution.

@Test
public void testEmptyStringSubstitution() {
    AppProperties appProperties = new AppProperties(new AppComponents("test"));
    appProperties.setProperty("refapp.myConfig", "1.xml ${ext.myConfig} 2.xml");
    appProperties.setProperty("ext.myConfig", "");
    String propValue = appProperties.getProperty("refapp.myConfig");
    log.debug("Property value: '" + propValue + "'");
    StringTokenizer tokenizer = new StringTokenizer(propValue);
    String[] locations = tokenizer.getTokenArray();
    Assertions.assertArrayEquals(new String[] { "1.xml", "2.xml" }, locations);
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) Test(org.junit.jupiter.api.Test)

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