use of org.apache.commons.text.TextStringBuilder in project sda-dropwizard-commons by SDA-SE.
the class SystemPropertyAndEnvironmentSubstitutorTest method shouldNotThrowExceptionIfNotStrict.
@Test
void shouldNotThrowExceptionIfNotStrict() {
final String input = "this is a ${UNKNOWN_PROPERTY}";
final TextStringBuilder builder = new TextStringBuilder(input);
final SystemPropertyAndEnvironmentSubstitutor substitutor = new SystemPropertyAndEnvironmentSubstitutor(false);
final int length = input.length();
assertThatCode(() -> substitutor.substitute(builder, 0, length)).doesNotThrowAnyException();
}
use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.
the class RequestHandler method getRequestHeaders.
private Map<String, String> getRequestHeaders(HttpExchange exchange) {
Map<String, String> headers = new HashMap<>();
for (Map.Entry<String, List<String>> e : exchange.getRequestHeaders().entrySet()) {
List<String> value = e.getValue();
headers.put(e.getKey(), new TextStringBuilder().appendWithSeparators(value, ";").build());
}
return headers;
}
use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.
the class ResourceSvc method addStylesToResource.
@Override
public void addStylesToResource(String pluginName, String fileName, Position position, String... cssSources) {
checkParams(pluginName, fileName, position, cssSources);
String snippet = new TextStringBuilder("<link href=\"").appendWithSeparators(cssSources, "\" rel=\"stylesheet\"></link><link href=\"").append("\" rel=\"stylesheet\">").build();
snippets.add(new Snippet(pluginName, fileName, position, snippet));
if (!"Plan".equals(pluginName)) {
logger.info(locale.getString(PluginLang.API_ADD_RESOURCE_CSS, pluginName, fileName, position.cleanName()));
}
}
use of org.apache.commons.text.TextStringBuilder in project Plan by plan-player-analytics.
the class BungeePartBuilder 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 HelpFormatter method addInDepthSubcommands.
public MessageBuilder addInDepthSubcommands(MessageBuilder message) {
MessageBuilder toReturn = message;
String m = colors.getMainColor();
String s = colors.getSecondaryColor();
String asString = subcommands.stream().filter(cmd -> cmd.getDescription() != null).map(cmd -> {
TextStringBuilder builder = new TextStringBuilder(m + mainCommand + " " + cmd.getPrimaryAlias());
for (String description : cmd.getInDepthDescription()) {
builder.append("***").append(s).append(description).append('\n');
}
for (Subcommand.ArgumentDescriptor argument : cmd.getArguments()) {
builder.append(" ***").append(m).append(argument.isRequired() ? '<' + argument.getName() + '>' : '[' + argument.getName() + ']').append(s).append(" ").append(argument.getDescription()).append('\n');
}
return builder.toString();
}).collect(StringBuilder::new, StringBuilder::append, StringBuilder::append).toString();
List<String[]> table = sender.getFormatter().tableAsParts(asString, "***");
for (String[] row : table) {
if (sender.isPlayer()) {
toReturn = toReturn.addPart(m + "/");
}
toReturn = toReturn.addPart(row[0]);
if (row.length > 1)
toReturn = toReturn.addPart(row[1]);
toReturn = toReturn.newLine();
}
return toReturn;
}
Aggregations