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.ms.commons.log.LoggerHelper.java
private static String leftpad(int level, String msg) { String prefix = StringUtils.repeat("\t", level); String[] lines = StringUtils.split(msg, newline); for (int i = 0; i < lines.length; i++) { lines[i] = prefix + lines[i];/*from w ww. j av a 2 s . c om*/ } return StringUtils.join(lines, newline); }
From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.CompressionUtilsTest.java
private static void testCompression(CompressionMethod compressionMethod) throws IOException { String text = StringUtils.repeat("This is a test. ", 100000); File file = new File("compressed" + compressionMethod.getExtension()); OutputStream os = CompressionUtils.getOutputStream(file); os.write(text.getBytes());//from w ww.j a v a2s. c o m os.close(); InputStream is = CompressionUtils.getInputStream(file.getPath(), new FileInputStream(file)); assertEquals(text, IOUtils.toString(is)); is.close(); file.delete(); }
From source file:net.cazzar.bukkit.perplayerchatfilter.util.CensorUtil.java
public static String censorString(Player player, String message) { for (String word : PerPlayerChatFilter.getInstance().getPlayerData(player).getCensoredWords()) { String replacement = StringUtils.repeat("*", word.length()); message = message.replaceAll("(?i)" + word, replacement); }//from w w w . j a v a2s. c om return message; }
From source file:com.nec.harvest.util.StringUtil.java
/** * Change a number to string and format it with style by user define * /*ww w. jav a 2 s . com*/ * @param fill * Character to fill up * @param total * Length of string return * @param number * Number to convert * @return String return */ public static <T> String numberToStringWithUserFillUp(String fill, int total, T number) { if (StringUtils.isEmpty(fill)) { throw new IllegalArgumentException("Number to string fill character must not be null or empty"); } // nts mean that number to string String nts = String.valueOf(number); int fillUp = total - nts.length(); if (fillUp > 0) { nts = StringUtils.repeat(fill, fillUp) + nts; } return nts; }
From source file:com.livinglogic.ul4.MulAST.java
public static String call(int arg1, String arg2) { return StringUtils.repeat(arg2, arg1); }
From source file:cc.vidr.datum.tools.Console.java
private static void printFact(Literal fact, int depth) { Literal[] proof = Server.getProof(fact); String response = StringUtils.capitalize(QA.respond(fact)); System.out.print(StringUtils.repeat(" ", depth)); System.out.print("- "); System.out.print(response != null ? response : fact); System.out.println(proof.length > 0 ? ", because:" : "."); for (Literal literal : proof) printFact(literal, depth + 1);//from w w w . j a v a2 s. c o m }
From source file:com.firewallid.util.FISQL.java
public static String getFirstFieldInsertIfNotExist(Connection conn, String tableName, String field, Map<String, String> fields) throws SQLException { /* Query *//*from w w w . j a va 2 s . c o m*/ String query = "SELECT " + field + " FROM " + tableName + " WHERE " + Joiner.on(" = ? AND ").join(fields.keySet()) + " = ?"; /* Execute */ PreparedStatement pst = conn.prepareStatement(query); int i = 1; for (String value : fields.values()) { pst.setString(i, value); i++; } ResultSet executeQuery = pst.executeQuery(); if (executeQuery.next()) { return executeQuery.getString(field); } /* Row is not exists. Insert */ query = "INSERT INTO " + tableName + " (" + Joiner.on(", ").join(fields.keySet()) + ") VALUES (" + StringUtils.repeat("?, ", fields.size() - 1) + "?)"; pst = conn.prepareStatement(query); i = 1; for (String value : fields.values()) { pst.setString(i, value); i++; } if (pst.execute()) { return null; } return getFirstFieldInsertIfNotExist(conn, tableName, field, fields); }
From source file:com.gnadenheimer.mg.utils.CuentaContableCellRenderer.java
@Override public void setValue(Object value) { setText((value == null) ? "" : StringUtils.repeat(" ", getSpaces(value.toString())) + value.toString()); //setHorizontalAlignment(SwingConstants.RIGHT); }
From source file:com.livinglogic.ul4.MulAST.java
public static String call(long arg1, String arg2) { if (((int) arg1) != arg1) throw new ArgumentTypeMismatchException("{} * {}", arg1, arg2); return StringUtils.repeat(arg2, (int) arg1); }
From source file:de.cismet.lagis.cidsmigtest.StandartTypToStringTester.java
/** * DOCUMENT ME! * * @return DOCUMENT ME! */ protected static String t() { return StringUtils.repeat("\t", TAB_LVL); }