Search in sources :

Example 1 with MessageString

use of org.apache.ofbiz.base.util.MessageString in project ofbiz-framework by apache.

the class StringToList method exec.

@Override
public boolean exec(MethodContext methodContext) throws MiniLangException {
    String valueStr = stringFse.expandString(methodContext.getEnvMap());
    List<? extends Object> argList = argListFma.get(methodContext.getEnvMap());
    if (argList != null) {
        try {
            valueStr = MessageFormat.format(valueStr, argList.toArray());
        } catch (IllegalArgumentException e) {
            throw new MiniLangRuntimeException("Exception thrown while formatting the string attribute: " + e.getMessage(), this);
        }
    }
    Object value;
    if (UtilValidate.isNotEmpty(this.messageFieldName)) {
        value = new MessageString(valueStr, this.messageFieldName, true);
    } else {
        value = valueStr;
    }
    List<Object> toList = listFma.get(methodContext.getEnvMap());
    if (toList == null) {
        toList = new LinkedList<Object>();
        listFma.put(methodContext.getEnvMap(), toList);
    }
    toList.add(value);
    return true;
}
Also used : MiniLangRuntimeException(org.apache.ofbiz.minilang.MiniLangRuntimeException) MessageString(org.apache.ofbiz.base.util.MessageString) MessageString(org.apache.ofbiz.base.util.MessageString)

Aggregations

MessageString (org.apache.ofbiz.base.util.MessageString)1 MiniLangRuntimeException (org.apache.ofbiz.minilang.MiniLangRuntimeException)1