Search in sources :

Example 36 with StringTokenizer

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

the class ExpressionAttributes method getSpecList.

public static List<Specification> getSpecList(String inputString, boolean useGroup, boolean generateMultiple) {
    ExpressionModifiers exp = extractExpressionModifiers(inputString, generateMultiple);
    List<Specification> specs = new ArrayList<>();
    if (StringUtils.isNotBlank(exp.expression)) {
        StringTokenizer st = new StringTokenizer(exp.expression, "|").setIgnoreEmptyTokens(true).setTrimmerMatcher(StringMatcherFactory.INSTANCE.spaceMatcher());
        st.getTokenList().forEach(s -> specs.add(SpecificationParser.parse(s, exp.extractMultiple, useGroup, exp.retainEmpty)));
    }
    return specs;
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer) ArrayList(java.util.ArrayList) Specification(io.github.linuxforhealth.api.Specification)

Example 37 with StringTokenizer

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

the class JexlEngineUtil method validateExpression.

private void validateExpression(String jexlExp) {
    StringTokenizer stk = new StringTokenizer(jexlExp, ".").setIgnoreEmptyTokens(true);
    String tok = stk.nextToken();
    // if only one part is specified like Function then this is not a valid expression.
    if (stk.getTokenList().size() < 2 || functions.get(tok) == null) {
        throw new IllegalArgumentException("Expression has unsupported function: " + tok);
    }
    if (jexlExp.contains(";")) {
        throw new IllegalArgumentException("Expression cannot contain character ; Expression: " + jexlExp);
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 38 with StringTokenizer

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

the class ConditionUtil method createSimpleCondition.

private static Condition createSimpleCondition(String conditionString, boolean useGroup) {
    StringTokenizer stk = new StringTokenizer(conditionString);
    stk.setQuoteChar('\'');
    if (stk.getTokenList().size() == 2) {
        String var1 = stk.nextToken();
        String var2 = stk.nextToken();
        if (var2.equalsIgnoreCase(CheckNotNull.NOT_NULL)) {
            return new CheckNotNull(var1, useGroup);
        } else if (var2.equalsIgnoreCase(CheckNull.NULL)) {
            return new CheckNull(var1, useGroup);
        } else {
            throw new IllegalArgumentException("Condition string incorrect format");
        }
    } else if (stk.getTokenList().size() == 3) {
        String var1 = stk.nextToken();
        String operator = stk.nextToken();
        String var2 = stk.nextToken();
        return new SimpleBiCondition(var1, var2, operator);
    } else {
        throw new IllegalArgumentException("Condition string incorrect format");
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 39 with StringTokenizer

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

the class ConditionUtil method createCondition.

public static Condition createCondition(String conditionString, boolean useGroup) {
    Preconditions.checkArgument(StringUtils.isNotBlank(conditionString), "conditionString cannot be blank or null.");
    StringTokenizer ors = new StringTokenizer(conditionString, "||");
    StringTokenizer ands = new StringTokenizer(conditionString, "&&");
    if (ors.getTokenList().size() > 1) {
        return getListOrConditions(ors, useGroup);
    } else if (ands.getTokenList().size() > 1) {
        return getListAndConditions(ands, useGroup);
    } else {
        return createSimpleCondition(conditionString, useGroup);
    }
}
Also used : StringTokenizer(org.apache.commons.text.StringTokenizer)

Example 40 with StringTokenizer

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

the class VariableUtils method getVarName.

public static String getVarName(String name) {
    String varName = name;
    if (isVar(name) && StringUtils.contains(name, ".")) {
        StringTokenizer stk = new StringTokenizer(name, ".");
        varName = StringUtils.removeStart(stk.nextToken(), "$");
    } else if (isVar(name)) {
        varName = StringUtils.removeStart(name, "$");
    }
    if (StringUtils.endsWith(varName, "?")) {
        varName = StringUtils.removeEnd(varName, "?");
    }
    return varName;
}
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