List of usage examples for org.apache.commons.lang StringUtils repeat
public static String repeat(String str, int repeat)
Repeat a String repeat
times to form a new String.
From source file:com.legit.globalrep.chat.Message.java
private static void printLine(Player player) { if (player.isOnline()) { player.sendMessage(ChatColor.AQUA + "m" + StringUtils.repeat(" ", 80)); }//from ww w . j a va 2 s.c o m }
From source file:com.piketec.jenkins.plugins.tpt.publisher.TrendGraph.java
/** * Minor function from generateJson()//from w w w . j a va 2 s .c o m * * @param data * The data to create the graph from * @return */ private static String getResultArray(ArrayList<ResultData> data) { StringBuffer buf = new StringBuffer(); int indent = 1; buf.append(StringUtils.repeat(INDENT, indent + 1) + " { \"data\" : [" + LF); for (int i = 0; i < data.size(); i++) { ResultData currentData = data.get(i); if (i == data.size() - 1) { buf.append(getResultStruct(currentData.total, currentData.failed, currentData.inconclusive, currentData.error, currentData.passed, currentData.buildNummer, indent + 1, false)); } else { buf.append(getResultStruct(currentData.total, currentData.failed, currentData.inconclusive, currentData.error, currentData.passed, currentData.buildNummer, indent + 1, true)); } } buf.append(StringUtils.repeat(INDENT, indent + 1) + "]" + LF); buf.append("}"); return buf.toString(); }
From source file:br.com.ingenieux.mojo.aws.AbstractAWSMojo.java
protected void displayResults(Object result, int level) { if (null == result) { return;/* w w w . j ava 2 s. c o m*/ } String prefix = StringUtils.repeat(" ", level * 2) + " * "; if (Collection.class.isAssignableFrom(result.getClass())) { @SuppressWarnings("unchecked") Collection<Object> coll = Collection.class.cast(result); for (Object o : coll) { displayResults(o, 1 + level); } return; } else if ("java.lang".equals(result.getClass().getPackage().getName())) { getLog().info(prefix + CredentialsUtil.redact("" + result) + " [class: " + result.getClass().getSimpleName() + "]"); return; } BeanMap beanMap = new BeanMap(result); for (Iterator<?> itProperty = beanMap.keyIterator(); itProperty.hasNext();) { String propertyName = "" + itProperty.next(); Object propertyValue = beanMap.get(propertyName); if ("class".equals(propertyName)) { continue; } if (null == propertyValue) { continue; } Class<?> propertyClass = null; try { propertyClass = beanMap.getType(propertyName); } catch (Exception e) { getLog().warn("Failure on property " + propertyName, e); } if (null == propertyClass) { getLog().info(prefix + propertyName + ": " + CredentialsUtil.redact("" + propertyValue)); } else { getLog().info(prefix + propertyName + ": " + CredentialsUtil.redact("" + propertyValue) + " [class: " + propertyClass.getSimpleName() + "]"); } } }
From source file:adalid.core.Display.java
@Override protected String fieldsToString(int n, String key, boolean verbose, boolean fields, boolean maps) { String tab = verbose ? StringUtils.repeat(" ", 4) : ""; String fee = verbose ? StringUtils.repeat(tab, n) : ""; String faa = " = "; String foo = verbose ? EOL : ", "; String string = super.fieldsToString(n, key, verbose, fields, maps); if (fields || verbose) { if (verbose) { if (_entity != null) { string += fee + tab + "entity" + faa + _entity + foo; }//from w ww . j a v a 2 s . c om if (_reference != null) { string += fee + tab + "_reference" + faa + _reference + foo; } if (_master != null) { string += fee + tab + "_master" + faa + _master + foo; } string += fee + tab + "displayType" + faa + _displayType + foo; string += fee + tab + "displayMode" + faa + _displayMode + foo; string += fee + tab + "displayFormat" + faa + _displayFormat + foo; } } return string; }
From source file:fr.ritaly.dungeonmaster.Position.java
public static void main(String[] args) { for (int radius = 1; radius <= 15; radius++) { final int width, height = width = (2 * radius) + 1; final Position center = new Position((width - 1) / 2, (height - 1) / 2, 1); final StringBuilder builder = new StringBuilder(); int insideCount = 0; int outsideCount = 0; for (int x = 0; x < width; x++) { builder.append("+"); builder.append(StringUtils.repeat("---+", width)); builder.append("\n"); builder.append("|"); for (int y = 0; y < height; y++) { final Position position = new Position(x, y, 1); if (center.equals(position)) { builder.append(" P |"); continue; }//from www . j av a2 s .c o m final double distance = Utils.distance(center.x, center.y, position.x, position.y); final boolean inside = (distance <= radius + 0.5d); if (inside) { builder.append(" ").append(Integer.toHexString((int) Math.floor(distance))).append(" |"); insideCount++; } else { builder.append(" |"); outsideCount++; } // System.out.println("Position " + position + " (d: " // + distance + ") -> " + inside); } builder.append("\n"); } builder.append("+"); builder.append(StringUtils.repeat("---+", width)); builder.append("\n"); System.out.println(builder); System.out.println(); System.out.println("Radius: " + radius + " -> Inside: " + insideCount + ", Outside: " + outsideCount); } // for (int j = 0; j < 10; j++) { // final long start = System.nanoTime(); // // final Position position = new Position(1,1,1); // // for (int i = 0; i < 10000; i++) { // position.getSurroundingPositions(6); // } // // System.out.println("Elapsed: " // + ((System.nanoTime() - start) / 1000000) + " ms"); // } }
From source file:com.redhat.rhn.taskomatic.task.DailySummary.java
/** * DO NOT CALL FROM OUTSIDE THIS CLASS. Renders the actions email message * @param actions list of recent actions * @return the actions email message/*w w w.j a v a2 s. c o m*/ */ public String renderActionsMessage(List<ActionMessage> actions) { int longestActionLength = HEADER_SPACER; int longestStatusLength = 0; StringBuilder hdr = new StringBuilder(); StringBuilder body = new StringBuilder(); StringBuilder legend = new StringBuilder(); StringBuilder msg = new StringBuilder(); LinkedHashSet<String> statusSet = new LinkedHashSet(); TreeMap<String, Map<String, Integer>> nonErrataActions = new TreeMap(); TreeMap<String, Map<String, Integer>> errataActions = new TreeMap(); TreeMap<String, String> errataSynopsis = new TreeMap(); legend.append(LocalizationService.getInstance().getMessage("taskomatic.daily.errata")); legend.append("\n\n"); for (ActionMessage am : actions) { if (!statusSet.contains(am.getStatus())) { statusSet.add(am.getStatus()); if (am.getStatus().length() > longestStatusLength) { longestStatusLength = am.getStatus().length(); } } if (am.getType().equals(ERRATA_UPDATE)) { String advisoryKey = ERRATA_INDENTION + am.getAdvisory(); if (!errataActions.containsKey(advisoryKey)) { errataActions.put(advisoryKey, new HashMap()); if (advisoryKey.length() + HEADER_SPACER > longestActionLength) { longestActionLength = advisoryKey.length() + HEADER_SPACER; } } Map<String, Integer> counts = errataActions.get(advisoryKey); counts.put(am.getStatus(), am.getCount()); if (am.getAdvisory() != null && !errataSynopsis.containsKey(am.getAdvisory())) { errataSynopsis.put(am.getAdvisory(), am.getSynopsis()); } } else { if (!nonErrataActions.containsKey(am.getType())) { nonErrataActions.put(am.getType(), new HashMap()); if (am.getType().length() + HEADER_SPACER > longestActionLength) { longestActionLength = am.getType().length() + HEADER_SPACER; } } Map<String, Integer> counts = nonErrataActions.get(am.getType()); counts.put(am.getStatus(), am.getCount()); } } hdr.append(StringUtils.repeat(" ", longestActionLength)); for (String status : statusSet) { hdr.append(status + StringUtils.repeat(" ", (longestStatusLength + ERRATA_SPACER) - status.length())); } if (!errataActions.isEmpty()) { body.append(ERRATA_UPDATE + ":" + "\n"); } StringBuffer formattedErrataActions = renderActionTree(longestActionLength, longestStatusLength, statusSet, errataActions); body.append(formattedErrataActions); for (String advisory : errataSynopsis.keySet()) { legend.append(ERRATA_INDENTION + advisory + ERRATA_INDENTION + errataSynopsis.get(advisory) + "\n"); } StringBuffer formattedNonErrataActions = renderActionTree(longestActionLength, longestStatusLength, statusSet, nonErrataActions); body.append(formattedNonErrataActions); // finally put all this together msg.append(hdr.toString()); msg.append("\n"); msg.append(body.toString()); msg.append("\n\n"); if (!errataSynopsis.isEmpty()) { msg.append(legend.toString()); } return msg.toString(); }
From source file:de.tudarmstadt.ukp.dkpro.core.treetagger.TreeTaggerPosLemmaTT4JTest.java
/** * Test using the same AnalysisEngine multiple times. */// w w w .ja v a2 s. co m @Test public void longTokenTest() throws Exception { checkModelsAndBinary("en"); AnalysisEngine engine = createEngine(TreeTaggerPosLemmaTT4J.class); JCas jcas = engine.newJCas(); try { for (int n = 99990; n < 100000; n++) { System.out.println(n); jcas.setDocumentLanguage("en"); JCasBuilder builder = new JCasBuilder(jcas); builder.add("Start", Token.class); builder.add("with", Token.class); builder.add("good", Token.class); builder.add("tokens", Token.class); builder.add(".", Token.class); builder.add(StringUtils.repeat("b", n), Token.class); builder.add("End", Token.class); builder.add("with", Token.class); builder.add("some", Token.class); builder.add("good", Token.class); builder.add("tokens", Token.class); builder.add(".", Token.class); builder.close(); engine.process(jcas); jcas.reset(); } } finally { engine.destroy(); } }
From source file:adalid.util.velocity.MavenArchetypeBuilder.java
private void writeArchetypeDescriptor() { final String LF = "\n"; final String HT = StringUtils.repeat(" ", 4); final String L1 = "<archetype" + LF + HT + "xmlns=\"http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0\"" + LF + HT + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" + LF + HT + "xsi:schemaLocation=\"http://maven.apache.org/plugins/maven-archetype-plugin/archetype/1.0.0" + LF + HT + "http://maven.apache.org/xsd/archetype-1.0.0.xsd\">"; String target = velocityArchetypeTargetFolderPath + FS + "archetype.xml"; List<String> targetLines = new ArrayList<>(); targetLines.add(L1);// ww w .ja va 2 s . co m targetLines.add(HT + "<id>adalid-" + artifact + "-archetype</id>"); targetLines.add(HT + "<sources>"); for (String path : sources) { if (path.startsWith("src/main/java/")) { targetLines.add(HT + HT + "<source>" + path + "</source>"); } } targetLines.add(HT + "</sources>"); targetLines.add(HT + "<resources>"); for (String path : resources) { if (path.startsWith("src/main/resources/")) { targetLines.add(HT + HT + "<resource>" + path + "</resource>"); } } targetLines.add(HT + "</resources>"); targetLines.add("</archetype>"); write(target, targetLines, StandardCharsets.UTF_8); }
From source file:me.taylorkelly.mywarp.bukkit.util.FormattingUtils.java
/** * Creates a two-column-layout from the given strings, using the given character as padding in between with the given * total width. The left column will be aligned on the left, the right column on the right of the given width. *// ww w. j a v a2 s.c o m * @param leftColumn the contents of the left column * @param rightColumn the contents of the right column * @param pad the padding character * @param totalWidth the horizontal width that should be covered by the layout * @return the formatted string */ public static String twoColumnAlign(String leftColumn, String rightColumn, char pad, int totalWidth) { int leftWidth = getWidth(leftColumn); int rightWidth = getWidth(rightColumn); totalWidth -= leftWidth + rightWidth; if (totalWidth > 0) { return leftColumn + StringUtils.repeat(Character.toString(pad), totalWidth / getWidth(pad)) + rightColumn; } // If both columns together are larger than the totalWidth, the larger // one is trimmed until it fits. int separatorWidth = getWidth(pad); totalWidth -= separatorWidth; if (leftWidth > rightWidth) { leftColumn = trim(leftColumn, leftWidth + totalWidth); } else { rightColumn = trim(rightColumn, rightWidth + totalWidth); } return leftColumn + pad + rightColumn; }
From source file:edu.cornell.mannlib.vitro.utilities.containerneutral.CheckContainerNeutrality.java
/** * Dump the first 20 nodes of an XML context, excluding comments and blank * text nodes.// w w w.j av a 2s .co m */ @SuppressWarnings("unused") private int dumpXml(Node xmlNode, int... parms) { int remaining = (parms.length == 0) ? 20 : parms[0]; int level = (parms.length < 2) ? 1 : parms[1]; Node n = xmlNode; if (Node.COMMENT_NODE == n.getNodeType()) { return 0; } if (Node.TEXT_NODE == n.getNodeType()) { if (StringUtils.isBlank(n.getTextContent())) { return 0; } } int used = 1; System.out.println(StringUtils.repeat("-->", level) + n); NodeList nl = n.getChildNodes(); for (int i = 0; (i < nl.getLength() && remaining > used); i++) { used += dumpXml(nl.item(i), remaining - used, level + 1); } return used; }