use of com.centurylink.mdw.common.utilities.StringHelper.StringParseException in project mdw-designer by CenturyLinkCloud.
the class MappingEditor method serializeMapping.
/**
* Converts a list of variable bindings to a string value to be stored with
* the activity attribute.
*/
public String serializeMapping(List<VariableBinding> bindings) {
if (getProject().checkRequiredVersion(6, 0, 4)) {
if (bindings.isEmpty())
return "";
JSONObject json = new JSONObject();
try {
for (VariableBinding variableBinding : bindings) {
json.put(variableBinding.getVariableVO().getVariableName(), variableBinding.getExpression());
}
} catch (JSONException ex) {
throw new StringParseException(ex.getMessage(), ex);
}
return json.toString();
} else {
StringBuffer sb = new StringBuffer();
boolean first = true;
for (VariableBinding variableBinding : bindings) {
if (first)
first = false;
else
sb.append(getRowDelimiter());
sb.append(variableBinding.getVariableVO().getVariableName());
sb.append(getColumnDelimiter());
sb.append(StringHelper.escapeWithBackslash(variableBinding.getExpression() == null ? "" : variableBinding.getExpression(), ";"));
}
return sb.toString();
}
}
Aggregations