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.qcadoo.model.integration.FieldModuleIntegrationTest.java
License:asdf
@Test public void shouldCallAndPassDefaultTextFieldValidators() throws Exception { // given/* w w w .j a va2 s .c om*/ String textValue = StringUtils.repeat("a", 2048); // when & then performFieldValidationTestOnPart("description", textValue, true); }
From source file:ffx.potential.extended.ExtUtils.java
public static void printTreeFromNode(MSNode target) { StringBuilder sb = new StringBuilder(); sb.append(format(" Tree Hierarchy for %s\n", target.getName())); sb.append(format(" ===================%s\n", StringUtils.repeat("=", target.getName().length()))); TreeNode root = target;/* w w w. j a v a 2s . c o m*/ while (root.getParent() != null) { root = root.getParent(); } Enumeration fromRoot = target.pathFromAncestorEnumeration(root); List<MSNode> toLeaves = target.getDescendants(MSNode.class); boolean init = false; for (MSNode node : toLeaves) { if (!init) { sb.append(format(" %s> %s\n", StringUtils.repeat(">", node.getLevel()), node.getName())); init = true; continue; } if (!node.getName().isEmpty()) { sb.append(format(" %s> %s\n", StringUtils.repeat("-", node.getLevel()), node.getName())); } } logger.info(sb.toString()); }
From source file:edu.utah.further.ds.impl.advice.QpMonitorAdvice.java
/** * @param queryContext// w w w .j av a 2 s . c o m * @param queryFailed */ private void logQueryStatus(final QueryContext queryContext, final DsMetaData dsMetaData, final boolean queryFailed) { if (log.isDebugEnabled()) { final String mark = queryFailed ? "%" : "*"; log.debug(StringUtils.repeat(mark, 40)); final StatusMetaData status = queryContext.getCurrentStatus(); log.debug(status != null ? (dsMetaData.getName() + ": " + status.getStatus()) : Strings.NULL_TO_STRING); log.debug(StringUtils.repeat(mark, 40)); } }
From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java
License:asdf
@Test public void shouldCallAndFailDefaultTextFieldValidators() throws Exception { // given/*from w w w .j a v a 2 s.c om*/ String textValue = StringUtils.repeat("a", 2049); // when & then performFieldValidationTestOnPart("description", textValue, false); }
From source file:com.redhat.rhn.taskomatic.task.DailySummary.java
/** * DO NOT CALL FROM OUTSIDE THIS CLASS. Renders the awol servers message * @param servers list of awol servers//from w ww . j a va2 s . c om * @return the awol servers message */ public String renderAwolServersMessage(List servers) { if (servers == null || servers.isEmpty()) { return ""; } /* * The Awol message is going to be a table containing a list of systems * that have gone AWOL. * * All the calculation crap for tables will be done... how many spaces * between columns and the column width for the given data. * This means that we will read through the data twice, once to find the * longest entries and again to build the return string. * * Since this will be going in an email, if the receiver doesn't use * monospace fonts *ever* than all this calculation is for nothing. */ LocalizationService ls = LocalizationService.getInstance(); String sid = ls.getMessage("taskomatic.daily.sid"); //System Id column String sname = ls.getMessage("taskomatic.daily.systemname"); //System Name column String checkin = ls.getMessage("taskomatic.daily.checkin"); //Last Checkin column //First we need to figure out how long the width of the columns should be. int minDiff = 4; //this is the minimum spaces between header elements int sidLength = sid.length() + minDiff; int snameLength = sid.length() + minDiff; //Find the longest entry in the table for both sid and sname. for (Iterator itr = servers.iterator(); itr.hasNext();) { AwolServer as = (AwolServer) itr.next(); String currentId = as.getId().toString(); if (currentId.length() >= sidLength) { //extra space so the longest entry doesn't connect to the next column sidLength = currentId.length() + 1; } String currentName = as.getName(); if (currentName.length() >= snameLength) { //extra space so the longest entry doesn't connect to the next column snameLength = currentName.length() + 1; } } //render the header-- System Id System Name LastCheckin StringBuilder buf = new StringBuilder(); buf.append(sid); buf.append(StringUtils.repeat(" ", sidLength - sid.length())); buf.append(sname); buf.append(StringUtils.repeat(" ", snameLength - sname.length())); buf.append(checkin); buf.append("\n"); //Now render the data in the table for (Iterator itr = servers.iterator(); itr.hasNext();) { AwolServer as = (AwolServer) itr.next(); String currentId = as.getId().toString(); buf.append(currentId); buf.append(StringUtils.repeat(" ", sidLength - currentId.length())); String currentName = as.getName(); buf.append(currentName); buf.append(StringUtils.repeat(" ", snameLength - currentName.length())); buf.append(as.getCheckin()); buf.append("\n"); } //Lastly, create the url for the link in the email. StringBuilder url = new StringBuilder(); if (Config.get().getBoolean(ConfigDefaults.SSL_AVAILABLE)) { url.append("https://"); } else { url.append("http://"); } url.append(getHostname()); url.append("/rhn/systems/Inactive.do"); return LocalizationService.getInstance().getMessage("taskomatic.msg.awolservers", buf.toString(), url); }
From source file:com.alibaba.doris.client.DataStoreTest.java
/** * Test Name: key256, Expected Result: client *//*from w w w. ja v a2 s . com*/ public void testPutValueMoreThan1M() { String key = "ABC"; String value = StringUtils.repeat("A", 1024 * 1024 + 1); System.out.println(key.length()); try { DataStore dataStore0 = dataStoreFactory.getDataStore("NotcompressUser"); dataStore0.put(key, value); fail("Out of Length Value, 1M!"); } catch (IllegalArgumentException e) { } }
From source file:com.zimbra.qa.unittest.TestImap.java
@Test public void testDeepNestedAndSearch() throws IOException, ServiceException { int nesting = LC.imap_max_nesting_in_search_request.intValue() - 1; connection = connect();//from w w w . j a v a 2 s . co m connection.select("INBOX"); connection.search((Object[]) new String[] { StringUtils.repeat("(", nesting) + "ANSWERED UNDELETED" + StringUtils.repeat(")", nesting) }); }
From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java
License:asdf
@Test public void shouldCallAndPassTextFieldMaxLenValidators() throws Exception { // given//ww w . java2 s . co m String textValue = StringUtils.repeat("a", 4096); // when & then performFieldValidationTestOnPart("longDescription", textValue, true); }
From source file:com.opengamma.component.ComponentManager.java
/** * Logs the properties to be used./*from ww w . ja v a2 s.co m*/ */ protected void logProperties() { _logger.logDebug("--- Using merged properties ---"); Map<String, String> properties = new TreeMap<String, String>(getProperties()); for (String key : properties.keySet()) { if (key.contains("password")) { _logger.logDebug(" " + key + " = " + StringUtils.repeat("*", properties.get(key).length())); } else { _logger.logDebug(" " + key + " = " + properties.get(key)); } } }
From source file:cc.kune.core.server.utils.StringW.java
/** * Word-wrap a string./* w ww. ja v a2s .c o m*/ * * @param str * String to word-wrap * @param width * int to wrap at * @param delim * String to use to separate lines * @param split * String to use to split a word greater than width long * @param delimInside * wheter or not delim should be included in chunk before length * reaches width. * * @return String that has been word wrapped */ // @PMD:REVIEWED:AvoidReassigningParameters: by vjrj on 21/05/09 14:13 static public String wordWrap(final String str, int width, final String delim, final String split, final boolean delimInside) { final int sz = str.length(); // System.err.println( ">>>> inside: " + delimInside + " sz : " + sz ); // / shift width up one. mainly as it makes the logic easier width++; // our best guess as to an initial size final StringBuffer buffer = new StringBuffer(sz / width * delim.length() + sz); // every line might include a delim on the end // System.err.println( "width before: "+ width ); if (delimInside) { width = width - delim.length(); } else { width--; } // System.err.println( "width after: "+ width ); int idx = -1; String substr = null; // beware: i is rolled-back inside the loop for (int i = 0; i < sz; i += width) { // on the last line if (i > sz - width) { buffer.append(str.substring(i)); // System.err.print("LAST-LINE: "+str.substring(i)); break; } // System.err.println("loop[i] is: "+i); // the current line substr = str.substring(i, i + width); // System.err.println( "substr: " + substr ); // is the delim already on the line idx = substr.indexOf(delim); // System.err.println( "i: " + i + " idx : " + idx ); if (idx != -1) { buffer.append(substr.substring(0, idx)); // System.err.println("Substr: '"substr.substring(0,idx)+"'"); buffer.append(delim); i -= width - idx - delim.length(); // System.err.println("loop[i] is now: "+i); // System.err.println("ounfd-whitespace: '"+substr.charAt(idx+1)+"'."); // Erase a space after a delim. Is this too obscure? if (substr.length() > idx + 1) { if (substr.charAt(idx + 1) != '\n') { if (Character.isWhitespace(substr.charAt(idx + 1))) { i++; } } } // System.err.println("i -= "+width+"-"+idx); continue; } idx = -1; // figure out where the last space is final char[] chrs = substr.toCharArray(); for (int j = width; j > 0; j--) { if (Character.isWhitespace(chrs[j - 1])) { idx = j; // System.err.println("Found whitespace: "+idx); break; } } // idx is the last whitespace on the line. // System.err.println("idx is "+idx); if (idx == -1) { for (int j = width; j > 0; j--) { if (chrs[j - 1] == '-') { idx = j; // System.err.println("Found Dash: "+idx); break; } } if (idx == -1) { buffer.append(substr); buffer.append(delim); // System.err.print(substr); // System.err.print(delim); } else { if (idx != width) { idx++; } buffer.append(substr.substring(0, idx)); buffer.append(delim); // System.err.print(substr.substring(0,idx)); // System.err.print(delim); i -= width - idx; } } else { /* * if(force) { if(idx == width-1) { buffer.append(substr); * buffer.append(delim); } else { // stick a split in. int splitsz = * split.length(); buffer.append(substr.substring(0,width-splitsz)); * buffer.append(split); buffer.append(delim); i -= splitsz; } } else { */ // insert spaces buffer.append(substr.substring(0, idx)); buffer.append(StringUtils.repeat(" ", width - idx)); // System.err.print(substr.substring(0,idx)); // System.err.print(StringUtils.repeat(" ",width-idx)); buffer.append(delim); // System.err.print(delim); // System.err.println("i -= "+width+"-"+idx); i -= width - idx; // } } } // System.err.println("\n*************"); return buffer.toString(); }