Search in sources :

Example 11 with TextStringBuilder

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();
}
Also used : TextStringBuilder(org.apache.commons.text.TextStringBuilder) Test(org.junit.jupiter.api.Test)

Example 12 with TextStringBuilder

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;
}
Also used : TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 13 with TextStringBuilder

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()));
    }
}
Also used : TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 14 with TextStringBuilder

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;
}
Also used : HoverEvent(net.md_5.bungee.api.chat.HoverEvent) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Example 15 with TextStringBuilder

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;
}
Also used : List(java.util.List) TextStringBuilder(org.apache.commons.text.TextStringBuilder) Set(java.util.Set) ArrayList(java.util.ArrayList) TextStringBuilder(org.apache.commons.text.TextStringBuilder)

Aggregations

TextStringBuilder (org.apache.commons.text.TextStringBuilder)37 PreparedStatement (java.sql.PreparedStatement)4 ResultSet (java.sql.ResultSet)4 ArrayList (java.util.ArrayList)4 List (java.util.List)4 Issue (org.apache.gobblin.runtime.troubleshooter.Issue)4 QueryStatement (com.djrapitops.plan.storage.database.queries.QueryStatement)3 Nullable (javax.annotation.Nullable)3 StringTokenizer (org.apache.commons.text.StringTokenizer)3 Test (org.junit.jupiter.api.Test)3 ServerUUID (com.djrapitops.plan.identification.ServerUUID)2 com.haulmont.cuba.core.global (com.haulmont.cuba.core.global)2 SecurityJpqlGenerator (com.haulmont.cuba.core.global.filter.SecurityJpqlGenerator)2 ConditionsTree (com.haulmont.cuba.gui.components.filter.ConditionsTree)2 FakeFilterSupport (com.haulmont.cuba.gui.components.filter.FakeFilterSupport)2 FilterParser (com.haulmont.cuba.gui.components.filter.FilterParser)2 FilterEditor (com.haulmont.cuba.gui.components.filter.edit.FilterEditor)2 FilterEntity (com.haulmont.cuba.security.entity.FilterEntity)2 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)2 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)2