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 shouldCallAndFailTextFieldMaxLenValidators() throws Exception { // given//from w w w . j av a2s . co m String textValue = StringUtils.repeat("a", 4097); // when & then performFieldValidationTestOnPart("longDescription", textValue, false); }
From source file:com.egt.ejb.toolkit.JasperQuery.java
private String field(SystemColumn c, String alias, String suffix, int depth) { boolean pkey = c.getPkcid() != null; // boolean fkey = c.getFkcid() != null; // boolean col1 = prefixed(c, "id"); boolean col2 = prefixed(c, "version"); // boolean col3 = prefixed(c, "codigo"); // boolean col4 = prefixed(c, "nombre"); // boolean col5 = prefixed(c, "descripcion"); boolean join = depth > 0; boolean skip = depth > fieldDepth || fieldCount >= fieldLimit || pkey || col2; if (join) {//from w ww . j a v a 2s. c o m if (skip) { return ""; } fieldCount++; } return NL + StringUtils.repeat(TAB, depth + 1) + alias + "." + DQ + c.getColname() + DQ + " AS " + shortAlias(c, suffix) + ","; }
From source file:adalid.core.ReportField.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) { string += fee + tab + "pixels" + faa + _pixels + foo; string += fee + tab + "resizeable" + faa + _resizeable + foo; }/*from ww w . j a va2 s. c o m*/ } return string; }
From source file:com.zimbra.qa.unittest.TestImap.java
@Test public void testTooDeepNestedAndSearch() throws IOException, ServiceException { int nesting = LC.imap_max_nesting_in_search_request.intValue(); connection = connect();/*from www.j av a 2 s .c o m*/ connection.select("INBOX"); try { connection.search((Object[]) new String[] { StringUtils.repeat("(", nesting) + "ANSWERED UNDELETED" + StringUtils.repeat(")", nesting) }); Assert.fail("Expected search to fail due to complexity"); } catch (CommandFailedException cfe) { String es = "parse error: Search query too complex"; Assert.assertTrue(String.format("Exception '%s' should contain string '%s'", cfe.getMessage(), es), cfe.getMessage().contains(es)); } }
From source file:com.projity.dialog.FieldDialog.java
protected JComponent createFieldsPanel(FieldComponentMap map, Collection fields) { if (fields == null || fields.size() == 0) return null; FormLayout layout = new FormLayout("p, 3dlu, fill:160dlu:grow", //$NON-NLS-1$ StringUtils.chomp(StringUtils.repeat("p,3dlu,", fields.size()))); // repeats and gets rid of last comma //$NON-NLS-1$ DefaultFormBuilder builder = new DefaultFormBuilder(layout); map.append(builder, fields);/*w w w.j av a 2 s . c o m*/ return builder.getPanel(); }
From source file:export.notes.view.to.excel.ExcelWriter.java
private void createCellStyle(int position, ViewColumn column, ViewEntry entry) throws NotesException { CellStyle cellStyle = workbook.createCellStyle(); Font font = workbook.createFont(); if (column.isFontBold()) { font.setBoldweight(Font.BOLDWEIGHT_BOLD); }/* w w w. j a va 2 s .c o m*/ font.setItalic(column.isFontItalic()); switch (column.getFontColor()) { case RichTextStyle.COLOR_BLACK: font.setColor(HSSFColor.BLACK.index); break; case RichTextStyle.COLOR_BLUE: font.setColor(HSSFColor.BLUE.index); break; case RichTextStyle.COLOR_CYAN: font.setColor(HSSFColor.CORAL.index); break; case RichTextStyle.COLOR_DARK_BLUE: font.setColor(HSSFColor.DARK_BLUE.index); break; case RichTextStyle.COLOR_DARK_CYAN: font.setColor(HSSFColor.DARK_GREEN.index); break; case RichTextStyle.COLOR_DARK_GREEN: font.setColor(HSSFColor.DARK_GREEN.index); break; case RichTextStyle.COLOR_DARK_MAGENTA: font.setColor(HSSFColor.VIOLET.index); break; case RichTextStyle.COLOR_DARK_RED: font.setColor(HSSFColor.DARK_RED.index); break; case RichTextStyle.COLOR_DARK_YELLOW: font.setColor(HSSFColor.DARK_YELLOW.index); break; case RichTextStyle.COLOR_GRAY: font.setColor(HSSFColor.GREY_80_PERCENT.index); break; case RichTextStyle.COLOR_GREEN: font.setColor(HSSFColor.GREEN.index); break; case RichTextStyle.COLOR_LIGHT_GRAY: font.setColor(HSSFColor.GREY_50_PERCENT.index); break; case RichTextStyle.COLOR_MAGENTA: font.setColor(HSSFColor.VIOLET.index); break; case RichTextStyle.COLOR_RED: font.setColor(HSSFColor.RED.index); break; case RichTextStyle.COLOR_WHITE: font.setColor(HSSFColor.BLACK.index); break; case RichTextStyle.COLOR_YELLOW: font.setColor(HSSFColor.YELLOW.index); break; default: break; } cellStyle.setFont(font); switch (column.getAlignment()) { case ViewColumn.ALIGN_CENTER: cellStyle.setAlignment(CellStyle.ALIGN_CENTER); break; case ViewColumn.ALIGN_LEFT: cellStyle.setAlignment(CellStyle.ALIGN_LEFT); break; case ViewColumn.ALIGN_RIGHT: cellStyle.setAlignment(CellStyle.ALIGN_RIGHT); break; default: break; } @SuppressWarnings("unchecked") Vector<Object> values = entry.getColumnValues(); Object value = values.get(position); String name = value.getClass().getSimpleName(); short format = 0; if (name.contains("Double")) { //$NON-NLS-1$ XSSFDataFormat fmt = (XSSFDataFormat) workbook.createDataFormat(); switch (column.getNumberFormat()) { case ViewColumn.FMT_CURRENCY: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(6)); break; case ViewColumn.FMT_FIXED: String zero = "0"; //$NON-NLS-1$ String fixedFormat = "#0"; //$NON-NLS-1$ int digits = column.getNumberDigits(); if (digits > 0) { String n = StringUtils.repeat(zero, digits); fixedFormat = fixedFormat + "." + n; } format = fmt.getFormat(fixedFormat); break; default: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(1)); break; } } else if (name.contains("DateTime")) { //$NON-NLS-1$ XSSFDataFormat fmt = (XSSFDataFormat) workbook.createDataFormat(); switch (column.getTimeDateFmt()) { case ViewColumn.FMT_DATE: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0xe)); break; case ViewColumn.FMT_DATETIME: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0x16)); break; case ViewColumn.FMT_TIME: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0x15)); break; default: format = fmt.getFormat(BuiltinFormats.getBuiltinFormat(0xe)); break; } } cellStyle.setDataFormat(format); styles.add(cellStyle); }
From source file:com.github.cereda.arara.rulechecker.RuleUtils.java
public static void updateRules(List<File> files) { // check if the provided list is empty if (files.isEmpty()) { // print error message System.err.println(WordUtils.wrap("Fatal exception: I could not find any rules in " + "the provided directory. I am afraid I won't be " + "be able to continue. Please make sure the " + "provided directory contains at least one rule to " + "be analyzed. The application will halt now.", 60)); }//from w w w. j a va 2 s . c om // print header System.out.println(StringUtils.center(" Update report ", 60, "-").concat("\n")); // read each file of the list and extract // each task found for (File file : files) { try { // read each file into a list // of strings List<String> lines = FileUtils.readLines(file, "UTF-8"); // create the potential // output for the updated file List<String> output = new ArrayList<>(); // iterate through each line for (String line : lines) { // only add lines not matching // the task pattern if (!match(line)) { output.add(line); } } // result string String result; // if the sizes are the same, // nothing happened if (lines.size() == output.size()) { // update status result = " Unchanged"; } else { // update the file reference FileUtils.writeLines(file, "UTF-8", output); // update status result = " Updated"; } // build the beginning of the line String line = String.format("- %s ", file.getName()); // generate the full entry line = line.concat(StringUtils.repeat(".", 60 - line.length() - result.length())).concat(result); // print entry System.out.println(line); } catch (IOException exception) { // print error message System.err.println(WordUtils.wrap("Fatal exception: an error was raised while " + "trying to read one of the rules. Please make " + "sure all rules in the provided directory have " + "read permission. I won't be able to continue. " + "The application will halt now.", 60)); System.exit(1); } } }
From source file:com.enonic.cms.itest.content.ContentServiceImpl_updateContentTest.java
@Test public void testUpdateContentNameTooLong() { UserEntity testUser = fixture.findUserByName("testuser"); CreateContentCommand createCommand = createCreateContentCommand(ContentStatus.DRAFT.getKey(), testUser); ContentKey contentKey = contentService.createContent(createCommand); fixture.flushAndClearHibernateSesssion(); ContentEntity persistedContent = contentDao.findByKey(contentKey); UpdateContentCommand command = createUpdateContentCommand(contentKey, persistedContent.getDraftVersion().getKey(), ContentStatus.DRAFT.getKey(), false, false); String newName = StringUtils.repeat("x", ContentNameValidator.CONTENT_NAME_MAX_LENGTH + 1); command.setContentName(newName);//w w w.j a v a2 s .c o m try { contentService.updateContent(command); fail("Expected exception"); } catch (AssertionError e) { throw e; } catch (Throwable e) { assertTrue(e instanceof UpdateContentException); assertTrue(e.getMessage().toLowerCase().contains("too long")); } }
From source file:com.qcadoo.model.integration.FieldModuleIntegrationTest.java
License:asdf
@Test public void shouldCallAndPassDefaultPasswordFieldValidators() throws Exception { // given/*from w ww.ja v a2s .c o m*/ String textValue = StringUtils.repeat("a", 255); // when & then performFieldValidationTestOnPart("discountCode", textValue, true); }
From source file:de.csdev.ebus.utils.EBusConsoleUtils.java
private static String createTelegramResoverRow(int pos, int length, int textStart, String text) { StringBuilder sb = new StringBuilder(); String repeat = StringUtils.repeat("^^ ", length); if (repeat.length() > 0) { repeat = repeat.substring(0, repeat.length() - 1); }//from ww w.j a v a 2 s . c o m sb.append(StringUtils.repeat(" ", pos * 3)); sb.append(repeat); sb.append(StringUtils.repeat("-", textStart - sb.length())); sb.append(" "); sb.append(text); sb.append("\n"); return sb.toString(); }