本文整理汇总了Java中org.apache.commons.lang3.StringUtils.repeat方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.repeat方法的具体用法?Java StringUtils.repeat怎么用?Java StringUtils.repeat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang3.StringUtils
的用法示例。
在下文中一共展示了StringUtils.repeat方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: removeTicketId
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Remove ticket id from the log message.
*
* @param msg the message
* @return the modified message with tgt id removed
*/
private String removeTicketId(final String msg) {
String modifiedMessage = msg;
if (StringUtils.isNotBlank(msg)) {
final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
while (matcher.find()) {
final String match = matcher.group();
final String newId = matcher.group(1) + '-'
+ StringUtils.repeat("*", match.length() - VISIBLE_ID_TAIL_LENGTH)
+ StringUtils.right(match, VISIBLE_ID_TAIL_LENGTH);
modifiedMessage = modifiedMessage.replaceAll(match, newId);
}
}
return modifiedMessage;
}
示例2: getScoresPR
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static List<String> getScoresPR(Map<Gene, GeneDR> resistanceResults) {
List<String> resistanceScoresAndLevels = new ArrayList<>();
if (resistanceResults.containsKey(Gene.PR)) {
GeneDR geneDR = resistanceResults.get(Gene.PR);
for (Drug drug : pis) {
int score = geneDR.getTotalDrugScore(drug).intValue();
int level = geneDR.getDrugLevel(drug);
resistanceScoresAndLevels.add(Integer.toString(score));
resistanceScoresAndLevels.add(Integer.toString(level));
}
} else {
String filler = StringUtils.repeat("NA", ",", pis.length * 2);
resistanceScoresAndLevels = Arrays.asList(filler.split(","));
}
return resistanceScoresAndLevels;
}
示例3: getScoresIN
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static List<String> getScoresIN(Map<Gene, GeneDR> resistanceResults) {
List<String> resistanceScoresAndLevels = new ArrayList<>();
if (resistanceResults.containsKey(Gene.IN)) {
GeneDR geneDR = resistanceResults.get(Gene.IN);
for (Drug drug : instis) {
int score = geneDR.getTotalDrugScore(drug).intValue();
int level = geneDR.getDrugLevel(drug);
resistanceScoresAndLevels.add(Integer.toString(score));
resistanceScoresAndLevels.add(Integer.toString(level));
}
} else {
String filler = StringUtils.repeat("NA", ",", instis.length * 2);
resistanceScoresAndLevels = Arrays.asList(filler.split(","));
}
return resistanceScoresAndLevels;
}
示例4: getRawJavaSnippet
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public static String getRawJavaSnippet(final Class<?> clazz, final String modulePath, final String marker, final String start, final String end) {
String javaCode = getRawJava(clazz.getName(), modulePath);
final int markerIndex = javaCode.indexOf(marker);
if (markerIndex < 0) {
throw new IllegalArgumentException("Cannot find java snippet for: " + clazz.getName() + " " + marker);
}
javaCode = javaCode.substring(markerIndex);
javaCode = javaCode.substring(javaCode.indexOf(start) + start.length());
javaCode = javaCode.substring(0, javaCode.indexOf(end));
javaCode = StringUtils.stripEnd(javaCode, " " + NEW_LINE);
// Remove indentation
final String trimmedJavaCode = javaCode.trim();
final int leadingSpaces = javaCode.indexOf(trimmedJavaCode);
if (leadingSpaces > 0) {
final String spacesRegex = NEW_LINE + StringUtils.repeat(" ", leadingSpaces);
javaCode = trimmedJavaCode.replace(spacesRegex, NEW_LINE);
}
return javaCode;
}
示例5: toString
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String toString(int indent) {
String valuesStr;
if (values != null) {
valuesStr = values.toString();
if (valuesStr.length() > 20) {
valuesStr = valuesStr.substring(0, 19) + "...}";
}
} else {
valuesStr = namespacedList.toString();
if (valuesStr.length() > 20) {
valuesStr = valuesStr.substring(0, 19) + "...}";
}
}
valuesStr = valuesStr + StringUtils.repeat(' ', indent);
return valuesStr;
}
示例6: render
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public String render(int dy, float ix, float iy) {
float charw = ClientProxy.font.getWidth("" + '\u2014');
int repeat = (int) ((1024 - x) / charw);
String s = StringUtils.repeat('\u2014', repeat);
ClientProxy.font.drawString(x, 512 - (y + dy) + 20, s, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f);
return null;
}
示例7: sanitize
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Remove ticket id from the message.
*
* @param msg the message
* @return the modified message with tgt id removed
*/
public static String sanitize(final String msg) {
String modifiedMessage = msg;
if (StringUtils.isNotBlank(msg) && !Boolean.getBoolean("CAS_TICKET_ID_SANITIZE_SKIP")) {
final Matcher matcher = TICKET_ID_PATTERN.matcher(msg);
while (matcher.find()) {
final String match = matcher.group();
final String newId = matcher.group(1) + '-'
+ StringUtils.repeat("*", match.length() - VISIBLE_TAIL_LENGTH)
+ StringUtils.right(match, VISIBLE_TAIL_LENGTH);
modifiedMessage = modifiedMessage.replaceAll(match, newId);
}
}
return modifiedMessage;
}
示例8: setUpBeforeClass
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@BeforeClass
public static void setUpBeforeClass() throws Exception {
datas = new HashMap<String, Object>();
datas.put("k1", "v1");
datas.put(nullKey, null);
datas.put("k3", new Date());
longKey = StringUtils.repeat("keys", 1024);
datas.put(longKey, StringUtils.repeat("valuevalue", 10240));
}
示例9: updateIndent
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void updateIndent(boolean up)
{
if (up)
{
this.cachedIndent = StringUtils.repeat(' ', (++ this.indent) * 2);
}
else
{
this.cachedIndent = StringUtils.repeat(' ', (-- this.indent) * 2);
}
}
示例10: newIn
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
* Return the "IN" SQL query parameters like : ?,?,?
*/
protected String newIn(final Collection<?> items) {
if (items.isEmpty()) {
return "null";
}
return StringUtils.repeat("?", ",", items.size());
}
示例11: titleTooLong
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Test
public void titleTooLong() throws Exception {
String title = StringUtils.repeat("x", 101);
Blogpost blogpost = new Blogpost(title, "", "author", "https://www.google.fi");
String blogpostJson = json(blogpost);
this.mockMvc.perform(post("/api/v01/blogposts")
.contentType(contentType)
.content(blogpostJson))
.andExpect(status().is(400))
.andExpect(content().contentType(contentType))
.andExpect((jsonPath("$", hasSize(1))))
.andExpect(jsonPath("$[0].type", is("ERROR")))
.andExpect(jsonPath("$[0].message", is("The title should be between 1 and 100 characters")))
.andExpect(jsonPath("$[0].field", is("title")));
}
示例12: authorTooLong
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Test
public void authorTooLong() throws Exception {
String author = StringUtils.repeat("x", 101);
Blogpost blogpost = new Blogpost("title", "", author, "https://www.google.fi");
String blogpostJson = json(blogpost);
this.mockMvc.perform(post("/api/v01/blogposts")
.contentType(contentType)
.content(blogpostJson))
.andExpect(status().is(400))
.andExpect(content().contentType(contentType))
.andExpect((jsonPath("$", hasSize(1))))
.andExpect(jsonPath("$[0].type", is("ERROR")))
.andExpect(jsonPath("$[0].message", is("The author should be between 1 and 100 characters")))
.andExpect(jsonPath("$[0].field", is("author")));
}
示例13: printHelp
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public void printHelp() {
HelpFormatter formatter = new HelpFormatter();
formatter.setSyntaxPrefix("Usage: ");
formatter.setOptionComparator(null);
String columns = System.getenv(ENV_COLUMNS);
if (columns != null) {
try {
formatter.setWidth(Integer.parseInt(columns));
} catch (Exception e) {
logger.warn(e.toString());
}
}
String header = "Run the " + VersionInfo.PRODUCT + " standalone command-line application.\n\n";
String leftPadding = StringUtils.repeat(' ', formatter.getLeftPadding());
//@formatter:off
String footer = new StringBuilder()
.append("\nExamples (change directory to " + VersionInfo.PRODUCT + " bin/ first):\n")
.append(leftPadding + "./" + EXECUTABLE_NAME + " -c ../examples/script/py/hello_world.xml\n")
.append(leftPadding + "./" + EXECUTABLE_NAME + " -k helloWorldKb=../examples/script/py/hello_world.py\n")
.append(leftPadding + "./" + EXECUTABLE_NAME + " -k ../examples/script/py/hello_world.py\n")
.append(leftPadding + "./" + EXECUTABLE_NAME
+ " -k filtersKb=../examples/script/py/filters.py -k heartbeatKb=../examples/script/js/rules_heartbeat.js\n")
.append(leftPadding + "./" + EXECUTABLE_NAME
+ " -k ../examples/standalone/multiple_kb_files/event_processors.py"
+ ",../examples/standalone/multiple_kb_files/example2.py\n")
.append("\nPress CTRL+C to exit the " + VersionInfo.PRODUCT + " standalone command-line application.\n")
.append("\nSee http://sponge.openksavi.org for more details.").toString();
//@formatter:on
formatter.printHelp(EXECUTABLE_NAME, header, options, footer, true);
}
示例14: formatTitle
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static String formatTitle(int tableWidth, String title) {
String tableTopBorder = StringUtils.repeat(TABLE_LINE_BORDER, tableWidth) + System.lineSeparator();
String tableTitleRow = TABLE_SIDE_BORDER + " " + title + System.lineSeparator();
String tableTitleBottomBorder = StringUtils.repeat(TABLE_TITLE_SEPARATOR, tableWidth) + System.lineSeparator();
return System.lineSeparator() +
tableTopBorder +
tableTitleRow +
tableTitleBottomBorder;
}
示例15: createRightBorder
import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private String createRightBorder(String comment, int longest, String commentRightBorder)
{
int commentLength = comment.length() + 2;
String rightBorder;
if (commentLength < longest)
{
rightBorder =
StringUtils.repeat(' ', DioriteMathUtils.ceil(((double) (longest - commentLength)) / commentRightBorder.length())) + '#';
}
else
{
rightBorder = commentRightBorder;
}
return "# " + comment + rightBorder;
}