当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.repeat方法代码示例

本文整理汇总了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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:23,代码来源:CasDelegatingLogger.java

示例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;
}
 
开发者ID:hivdb,项目名称:sierra,代码行数:17,代码来源:TabularResistanceSummary.java

示例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;
}
 
开发者ID:hivdb,项目名称:sierra,代码行数:17,代码来源:TabularResistanceSummary.java

示例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;
}
 
开发者ID:gchq,项目名称:gaffer-doc,代码行数:23,代码来源:JavaSourceUtil.java

示例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;
}
 
开发者ID:Comcast,项目名称:redirector,代码行数:17,代码来源:RightSide.java

示例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;
}
 
开发者ID:McJty,项目名称:Lector,代码行数:9,代码来源:RenderElementRuler.java

示例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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:21,代码来源:TicketIdSanitizationUtils.java

示例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));

}
 
开发者ID:AlexLee-CN,项目名称:weixin_api,代码行数:11,代码来源:TestFileStorage.java

示例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);
    }
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:12,代码来源:CommentsWriter.java

示例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());
}
 
开发者ID:ligoj,项目名称:plugin-bt-jira,代码行数:10,代码来源:JiraDao.java

示例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")));
}
 
开发者ID:rovaniemi,项目名称:remember-me-back,代码行数:16,代码来源:ValidationTest.java

示例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")));
}
 
开发者ID:rovaniemi,项目名称:remember-me-back,代码行数:16,代码来源:ValidationTest.java

示例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);
}
 
开发者ID:softelnet,项目名称:sponge,代码行数:33,代码来源:StandaloneEngineBuilder.java

示例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;
}
 
开发者ID:alphagov,项目名称:verify-service-provider,代码行数:11,代码来源:StringTableFormatter.java

示例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;
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:16,代码来源:Emitter.java


注:本文中的org.apache.commons.lang3.StringUtils.repeat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。