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;
}
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);
}
}
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");
}
}
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);
}
}
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;
}
Aggregations