List of usage examples for org.apache.commons.lang3 StringUtils swapCase
public static String swapCase(final String str)
Swaps the case of a String changing upper and title case to lower case, and lower case to upper case.
For a word based algorithm, see org.apache.commons.lang3.text.WordUtils#swapCase(String) .
From source file:cn.sixlab.sixutil.StrUtil.java
/** * ???????/*from w w w . ja va 2 s. c o m*/ * * @param ulStr ?? * @param isFirstLower ??? * @return ??@{code isFirstLower}true???? * @since 1.0.0 */ public static String getCamel(String ulStr, boolean isFirstLower) { StringBuffer result = new StringBuffer(); String[] ulArray = ulStr.split("_"); boolean isFirst = true; for (String s : ulArray) { if (StringUtils.isNotEmpty(s)) { s = StringUtils.lowerCase(s); if (isFirst && isFirstLower) { isFirst = false; result.append(s); } else { result.append(StringUtils.swapCase(s.substring(0, 1))).append(s.substring(1, s.length())); } } } return result.toString(); }
From source file:org.graylog.plugins.pipelineprocessor.functions.strings.Swapcase.java
@Override protected String apply(String value, Locale unused) { return StringUtils.swapCase(value); }
From source file:org.moeaframework.problem.StandardProblemsTest.java
/** * Ensures the names are not case sensitive. *//* w w w.java 2 s . com*/ @Test public void testCaseInsensitivity() { for (String name : problems) { String swapCaseName = StringUtils.swapCase(name); Assert.assertNotNull("no problem for " + swapCaseName, ProblemFactory.getInstance().getProblem(swapCaseName)); Assert.assertNotNull("no reference set for " + swapCaseName, ProblemFactory.getInstance().getReferenceSet(swapCaseName)); } }
From source file:org.openlmis.core.domain.StockAdjustmentReasonTest.java
@Test public void shouldParseDirtyCategoryString() { for (StockAdjustmentReason.Category c : StockAdjustmentReason.Category.values()) { String cStr = " " + StringUtils.swapCase(c.toString()) + " "; // swap case and throw in some spaces StockAdjustmentReason.Category cParsed = StockAdjustmentReason.Category.parse(cStr); assertThat(cParsed, is(c));/*from w w w .j a va 2 s . co m*/ } }