use of org.apache.commons.text.TextStringBuilder in project iaf by ibissource.
the class MessageStoreSender method sendMessage.
@Override
public Message sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException {
try {
Message messageToStore = message;
if (sessionKeys != null) {
List<String> list = new ArrayList<>();
list.add(StringEscapeUtils.escapeCsv(message.asString()));
StringTokenizer tokenizer = new StringTokenizer(sessionKeys, ",");
while (tokenizer.hasMoreElements()) {
String sessionKey = (String) tokenizer.nextElement();
Message msg = session.getMessage(sessionKey);
if (!msg.isEmpty()) {
list.add(StringEscapeUtils.escapeCsv(msg.asString()));
}
}
TextStringBuilder sb = new TextStringBuilder();
sb.appendWithSeparators(list, ",");
messageToStore = Message.asMessage(sb.toString());
}
// the messageId to be inserted in the messageStore defaults to the messageId of the session
String messageId = session.getMessageId();
String correlationID = messageId;
if (paramList != null && paramList.findParameter(PARAM_MESSAGEID) != null) {
try {
// the messageId to be inserted can also be specified via the parameter messageId
messageId = paramList.getValues(message, session).get(PARAM_MESSAGEID).asStringValue();
} catch (ParameterException e) {
throw new SenderException("Could not resolve parameter messageId", e);
}
}
return new Message(storeMessage(messageId, correlationID, new Date(), null, null, messageToStore.asString()));
} catch (IOException e) {
throw new SenderException(getLogPrefix(), e);
}
}
use of org.apache.commons.text.TextStringBuilder in project incubator-gobblin by apache.
the class AutomaticTroubleshooterImpl method getIssueSummaryMessage.
@Override
public String getIssueSummaryMessage() throws TroubleshooterException {
List<Issue> issues = issueRepository.getAll();
TextStringBuilder sb = new TextStringBuilder();
sb.appendln("");
sb.appendln("vvvvv============= Issues (summary) =============vvvvv");
for (int i = 0; i < issues.size(); i++) {
Issue issue = issues.get(i);
sb.appendln("%s) %s %s %s | source: %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary(), issue.getSourceClass());
}
sb.append("^^^^^=============================================^^^^^");
return sb.toString();
}
use of org.apache.commons.text.TextStringBuilder in project incubator-gobblin by apache.
the class AutomaticTroubleshooterImpl method getIssueDetailsMessage.
@Override
public String getIssueDetailsMessage() throws TroubleshooterException {
List<Issue> issues = issueRepository.getAll();
TextStringBuilder sb = new TextStringBuilder();
sb.appendln("");
sb.appendln("vvvvv============= Issues (detailed) =============vvvvv");
for (int i = 0; i < issues.size(); i++) {
Issue issue = issues.get(i);
sb.appendln("%s) %s %s %s", i + 1, issue.getSeverity().toString(), issue.getCode(), issue.getSummary());
sb.appendln("\tsource: %s", issue.getSourceClass());
if (issue.getDetails() != null) {
sb.appendln("\t" + issue.getDetails().replaceAll(System.lineSeparator(), System.lineSeparator() + "\t"));
}
if (issue.getProperties() != null) {
issue.getProperties().forEach((key, value) -> {
sb.appendln("\t%s: %s", key, value);
});
}
}
sb.append("^^^^^================================================^^^^^");
return sb.toString();
}
use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.
the class BukkitPartBuilder method hover.
@Override
public MessageBuilder hover(Collection<String> lines) {
ComponentBuilder hoverMsg = new ComponentBuilder("");
hoverMsg.append(new TextStringBuilder().appendWithSeparators(lines, "\n").build());
part.event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverMsg.create()));
return this;
}
use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.
the class ItemNameFormatter method apply.
@Override
public String apply(String name) {
String[] parts = StringUtils.split(name, '_');
TextStringBuilder builder = new TextStringBuilder();
builder.appendWithSeparators(Arrays.stream(parts).map(StringUtils::lowerCase).map(StringUtils::capitalize).iterator(), " ");
return builder.toString();
}
Aggregations