List of usage examples for org.apache.commons.lang StringUtils abbreviate
public static String abbreviate(String str, int maxWidth)
Abbreviates a String using ellipses.
From source file:org.sonar.plugins.web.markup.rules.MarkupRuleRepository.java
@Override public List<Rule> createRules() { List<Rule> rules = new ArrayList<Rule>(); XStream xstream = new XStream(); xstream.setClassLoader(getClass().getClassLoader()); xstream.processAnnotations(HtmlMarkupRules.class); HtmlMarkupRules markupRules = (HtmlMarkupRules) xstream .fromXML(MarkupRuleRepository.class.getClassLoader().getResourceAsStream(ALL_RULES)); for (HtmlMarkupRule htmlMarkupRule : markupRules.rules) { Rule rule = Rule.create(REPOSITORY_KEY, htmlMarkupRule.getKey(), StringUtils.abbreviate(htmlMarkupRule.getRemark(), RULENAME_MAX_LENGTH)); if (htmlMarkupRule.getExplanation() != null) { rule.setDescription(StringEscapeUtils.escapeHtml(htmlMarkupRule.getExplanation())); }//from w w w . j a va 2 s. c o m rule.setSeverity(htmlMarkupRule.getPriority()); rules.add(rule); } return rules; }
From source file:org.sonar.server.configuration.ConfigurationLogger.java
static String getTruncatedProperty(Configuration configuration, String key) { String property = StringUtils.join(configuration.getStringArray(key), ","); return StringUtils.abbreviate(property, 100); }
From source file:org.sonarsource.sonarlint.core.container.connected.update.check.GlobalSettingsUpdateChecker.java
static String formatValue(String key, String value) { if (key.endsWith(".secured")) { return "******"; }// w w w. j a v a 2 s . c o m return StringUtils.abbreviate(value, MAX_VALUE_LENGTH); }
From source file:org.sonarsource.sonarlint.core.container.connected.validate.ServerVersionAndStatusChecker.java
private ServerInfos fetchServerInfos() { try (WsResponse response = wsClient.rawGet("api/system/status")) { if (!response.isSuccessful()) { if (response.code() == HttpURLConnection.HTTP_NOT_FOUND) { return tryFromDeprecatedApi(response); } else { throw SonarLintWsClient.handleError(response); }//from w w w . j a v a 2 s .co m } else { String responseStr = response.content(); try { ServerInfos.Builder builder = ServerInfos.newBuilder(); JsonFormat.parser().merge(responseStr, builder); return builder.build(); } catch (InvalidProtocolBufferException e) { throw new IllegalStateException( "Unable to parse server infos from: " + StringUtils.abbreviate(responseStr, 100), e); } } } }