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:ch.systemsx.cisd.openbis.generic.server.business.bo.ExternalDataTableTest.java
private String generateDataSetCode(int codeLength, int codeIndex) { String result = "-" + (codeIndex + 1); String sequence = StringUtils.repeat("1234567890", (codeLength / 10) + 1); return sequence.substring(0, codeLength - result.length()) + result; }
From source file:com.piketec.jenkins.plugins.tpt.publisher.TrendGraph.java
/** * Minor function from generateJson().//from w ww . j a v a2 s .c o m * * @param total * The total number of test cases * @param failed * The number of failed test cases * @param inconclusive * The number of inconclusive test cases * @param error * The number of test cases with execution errors * @param passed * the number of passed test cases * @param buildNummer * the build number of the Jenkins build * @param indent * indentation. Just for formating the json output * @param withComma * should the last line end with a comma * @return The part of the json output containing the numbers of test cases foreach result and teh * build number */ private static String getResultStruct(int total, int failed, int inconclusive, int error, int passed, int buildNummer, int indent, boolean withComma) { StringBuffer buf = new StringBuffer(); buf.append(StringUtils.repeat(INDENT, indent + 1) + "[" + LF); buf.append(getJSONIntEntry("buildNummer", buildNummer, indent + 1, true)); buf.append(getJSONIntEntry("total", total, indent + 1, true)); buf.append(getJSONIntEntry("failed", failed, indent + 1, true)); buf.append(getJSONIntEntry("inconclusive", inconclusive, indent + 1, true)); buf.append(getJSONIntEntry("error", error, indent + 1, true)); buf.append(getJSONIntEntry("passed", passed, indent + 1)); // append comma if needed if (withComma) { buf.append(StringUtils.repeat(INDENT, indent + 1) + "]," + LF); } else { buf.append(StringUtils.repeat(INDENT, indent + 1) + "]" + LF); } return buf.toString(); }
From source file:ca.nengo.model.impl.ProjectionImpl.java
String getTransformScript(DecodedTermination dTermination, int offset) throws ScriptGenException { StringBuilder transformString = new StringBuilder(); float[][] transform = dTermination.getTransform(); for (int i = 0; i < transform.length; i++) { if (i != 0) transformString.append(",\n " + StringUtils.repeat(" ", offset)); transformString.append("["); for (int j = 0; j < transform[i].length; j++) { if (j != 0) transformString.append(", "); transformString.append(transform[i][j]); }/*from ww w . j a v a 2s .c o m*/ transformString.append("]"); } return transformString.toString(); }
From source file:com.cloudbees.jenkins.support.SupportPlugin.java
private static void appendManifestHeader(StringBuilder manifest) { SupportPlugin plugin = SupportPlugin.getInstance(); SupportProvider supportProvider = plugin == null ? null : plugin.getSupportProvider(); String bundleName = (supportProvider == null ? "Support" : supportProvider.getDisplayName()) + " Bundle Manifest"; manifest.append(bundleName).append('\n').append(StringUtils.repeat("=", bundleName.length())) .append("\n\n"); SimpleDateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ"); f.setTimeZone(TimeZone.getTimeZone("UTC")); manifest.append("Generated on ").append(f.format(new Date())).append("\n\n"); }
From source file:com.redhat.rhn.taskomatic.task.DailySummary.java
private StringBuffer renderActionTree(int longestActionLength, int longestStatusLength, LinkedHashSet<String> statusSet, TreeMap<String, Map<String, Integer>> actionTree) { StringBuffer formattedActions = new StringBuffer(); for (String actionName : actionTree.keySet()) { formattedActions/*from ww w. j a v a2 s . c om*/ .append(actionName + StringUtils.repeat(" ", (longestActionLength - (actionName.length())))); for (String status : statusSet) { Map<String, Integer> counts = actionTree.get(actionName); Integer theCount = counts.get(status); if (counts.containsKey(status)) { theCount = counts.get(status); } else { theCount = 0; } formattedActions.append(theCount); formattedActions.append(StringUtils.repeat(" ", longestStatusLength + ERRATA_SPACER - theCount.toString().length())); } formattedActions.append("\n"); } return formattedActions; }
From source file:com.conversantmedia.mapreduce.tool.ToolContext.java
@Override public String toString() { int lc = getLeftColumnWidth(), rc = getRightColumnWidth(); StringBuffer buf = new StringBuffer(); buf.append("\n").append(getClass().getSimpleName()).append(":\n"); buf.append(StringUtils.repeat("=", lc + rc)); buf.append("\n"); argsToString(buf, lc, rc);// w w w. jav a 2 s . c om buf.append(StringUtils.repeat("=", lc + rc)); buf.append("\n"); return buf.toString(); }
From source file:com.piketec.jenkins.plugins.tpt.publisher.TrendGraph.java
private static String getJSONIntEntry(String name, int value, int indent, boolean withComma) { if (withComma) { return StringUtils.repeat(INDENT, indent + 1) + "{\"" + name + "\" : " + value + "}," + LF; } else {/*from w w w. j av a 2s . co m*/ return StringUtils.repeat(INDENT, indent + 1) + "{\"" + name + "\" : " + value + "}" + LF; } }
From source file:com.sonyericsson.jenkins.plugins.bfa.tokens.Token.java
/** * @param indentLevel the indent level/*from w w w . jav a 2s.c o m*/ * @return a whitespace string with an appropriate with for the specified indent level */ private static String indentForDepth(final int indentLevel) { return StringUtils.repeat(" ", indentLevel); }
From source file:com.opentok.test.OpenTokTest.java
@Test public void testTokenConnectionData() throws OpenTokException, SignatureException, NoSuchAlgorithmException, InvalidKeyException, UnsupportedEncodingException { int apiKey = 123456; String apiSecret = "1234567890abcdef1234567890abcdef1234567890"; String sessionId = "1_MX4xMjM0NTZ-flNhdCBNYXIgMTUgMTQ6NDI6MjMgUERUIDIwMTR-MC40OTAxMzAyNX4"; OpenTok opentok = new OpenTok(apiKey, apiSecret); // purposely contains some exotic characters String actualData = "{\"name\":\"%foo &\"}"; Exception tooLongException = null; String defaultToken = opentok.generateToken(sessionId); String dataBearingToken = opentok.generateToken(sessionId, new TokenOptions.Builder().data(actualData).build()); try {/* w w w . j a v a 2s .c om*/ String dataTooLongToken = opentok.generateToken(sessionId, new TokenOptions.Builder().data(StringUtils.repeat("x", 1001)).build()); } catch (InvalidArgumentException e) { tooLongException = e; } assertNotNull(defaultToken); assertNotNull(dataBearingToken); assertTrue(Helpers.verifyTokenSignature(defaultToken, apiSecret)); assertTrue(Helpers.verifyTokenSignature(dataBearingToken, apiSecret)); Map<String, String> defaultTokenData = Helpers.decodeToken(defaultToken); assertNull(defaultTokenData.get("connection_data")); Map<String, String> dataBearingTokenData = Helpers.decodeToken(dataBearingToken); assertEquals(actualData, dataBearingTokenData.get("connection_data")); assertEquals(InvalidArgumentException.class, tooLongException.getClass()); }
From source file:adalid.util.doclet.MetaDoclet.java
private static void println(String string) { if (string != null) { System.out.println(StringUtils.repeat(TAB, margin) + string); } }