Search in sources :

Example 31 with StringTokenizer

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

the class CreditsLoader method load.

public CreditsLoader load() {
    String configProperty = AppContext.getProperty("cuba.creditsConfig");
    if (StringUtils.isBlank(configProperty)) {
        log.info("Property cuba.creditsConfig is empty");
        return this;
    }
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] locations = tokenizer.getTokenArray();
    for (String location : locations) {
        Resources resources = AppBeans.get(Resources.NAME);
        String xml = resources.getResourceAsString(location);
        if (xml == null) {
            log.debug("Resource {} not found, ignore it", location);
            continue;
        }
        Element rootElement = AppBeans.get(Dom4jTools.class).readDocument(xml).getRootElement();
        loadLicenses(rootElement);
        loadConfig(rootElement);
    }
    Collections.sort(items);
    return this;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) Element(org.dom4j.Element) Resources(com.haulmont.cuba.core.global.Resources)

Example 32 with StringTokenizer

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

the class WebExternalUIComponentsSource method _registerAppComponents.

protected void _registerAppComponents() {
    String configNames = AppContext.getProperty(WEB_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 33 with StringTokenizer

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

the class CubaDispatcherServlet method getContextConfigLocation.

@Override
public String getContextConfigLocation() {
    String configProperty = AppContext.getProperty(SPRING_CONTEXT_CONFIG);
    if (StringUtils.isBlank(configProperty)) {
        throw new IllegalStateException("Missing " + SPRING_CONTEXT_CONFIG + " application property");
    }
    File baseDir = new File(AppContext.getProperty("cuba.confDir"));
    StringTokenizer tokenizer = new StringTokenizer(configProperty);
    String[] tokenArray = tokenizer.getTokenArray();
    StringBuilder locations = new StringBuilder();
    for (String token : tokenArray) {
        String location;
        if (ResourceUtils.isUrl(token)) {
            location = token;
        } else {
            if (token.startsWith("/"))
                token = token.substring(1);
            File file = new File(baseDir, token);
            if (file.exists()) {
                location = file.toURI().toString();
            } else {
                location = "classpath:" + token;
            }
        }
        locations.append(location).append(" ");
    }
    return locations.toString();
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) File(java.io.File)

Example 34 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 35 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project hl7v2-fhir-converter by LinuxForHealth.

the class HL7Segment method createHL7Segment.

private static HL7Segment createHL7Segment(String rawSegment) {
    StringTokenizer stk = new StringTokenizer(rawSegment, ".");
    String segment = null;
    List<String> group = new ArrayList<>();
    List<String> tokens = stk.getTokenList();
    if (tokens.size() > 1) {
        group.addAll(tokens.subList(0, tokens.size() - 1));
        segment = tokens.get(tokens.size() - 1);
    } else if (tokens.size() == 1) {
        segment = tokens.get(0);
    } else {
        throw new IllegalArgumentException("rawSegment cannot be parsed:" + rawSegment);
    }
    return new HL7Segment(group, segment, false);
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) ArrayList(java.util.ArrayList)

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