Search in sources :

Example 6 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project jmix by jmix-framework.

the class RestJsonTransformations method init.

protected void init() {
    String configName = environment.getProperty(JMIX_REST_JSON_TRANSFORMATION_CONFIG_PROP_NAME);
    StringTokenizer tokenizer = new StringTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException(e);
            } finally {
                IOUtils.closeQuietly(stream);
            }
        } else {
            log.warn("Resource " + location + " not found, ignore it");
        }
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) InputStream(java.io.InputStream) Resource(org.springframework.core.io.Resource) IOException(java.io.IOException)

Example 7 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project jmix by jmix-framework.

the class RestQueriesConfiguration method init.

protected void init() {
    String configName = environment.getProperty(JMIX_REST_QUERIES_CONFIG_PROP_NAME);
    StringTokenizer tokenizer = new StringTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            InputStream stream = null;
            try {
                stream = resource.getInputStream();
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException(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 8 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project jmix by jmix-framework.

the class RestServicesConfiguration method init.

protected void init() {
    String configName = environment.getProperty(JMIX_REST_SERVICES_CONFIG_PROP_NAME);
    StringTokenizer tokenizer = new StringTokenizer(configName);
    for (String location : tokenizer.getTokenArray()) {
        Resource resource = resources.getResource(location);
        if (resource.exists()) {
            try (InputStream stream = resource.getInputStream()) {
                loadConfig(Dom4j.readDocument(stream).getRootElement());
            } catch (IOException e) {
                throw new RuntimeException("Error on parsing rest services config", e);
            }
        } 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 9 with StringTokenizer

use of org.apache.commons.text.StringTokenizer in project jmix by jmix-framework.

the class CubaMessages method searchMessage.

@Nullable
protected String searchMessage(String packs, String key, Locale locale, Locale truncatedLocale, Set<String> passedPacks) {
    StringTokenizer tokenizer = new StringTokenizer(packs);
    // noinspection unchecked
    List<String> list = tokenizer.getTokenList();
    Collections.reverse(list);
    for (String pack : list) {
        if (!enterPack(pack, locale, truncatedLocale, passedPacks))
            continue;
        String msg = searchOnePack(pack, key, locale, truncatedLocale, passedPacks);
        if (msg != null)
            return msg;
        Locale tmpLocale = truncatedLocale;
        while (tmpLocale != null) {
            tmpLocale = truncateLocale(tmpLocale);
            msg = searchOnePack(pack, key, locale, tmpLocale, passedPacks);
            if (msg != null)
                return msg;
        }
    }
    if (log.isTraceEnabled()) {
        String packName = new TextStringBuilder().appendWithSeparators(list, ",").toString();
        log.trace("Resource '{}' not found", makeCacheKey(packName, key, locale, locale));
    }
    return null;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) TextStringBuilder(org.apache.commons.text.TextStringBuilder) Nullable(javax.annotation.Nullable)

Example 10 with StringTokenizer

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

the class DesktopThemeImpl method applyStyle.

@Override
public void applyStyle(Object component, String styleNameString, Set<String> state) {
    // split string into individual style names
    StringTokenizer tokenizer = new StringTokenizer(styleNameString);
    String[] styleNames = tokenizer.getTokenArray();
    for (String styleName : styleNames) {
        applyStyleName(component, state, styleName);
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

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