Example usage for org.apache.commons.lang StringUtils splitByCharacterTypeCamelCase

List of usage examples for org.apache.commons.lang StringUtils splitByCharacterTypeCamelCase

Introduction

In this page you can find the example usage for org.apache.commons.lang StringUtils splitByCharacterTypeCamelCase.

Prototype

public static String[] splitByCharacterTypeCamelCase(String str) 

Source Link

Document

Splits a String by Character type as returned by java.lang.Character.getType(char).

Usage

From source file:org.openmrs.module.auditlog.AuditLog.java

/**
 * Returns the simple forms of the classname property e.g 'Concept Name' will be returned for
 * ConceptName//from  www  .  jav a  2s  . c om
 * 
 * @return the classname
 */
public String getSimpleTypeName() {
    String[] sections = StringUtils.splitByCharacterTypeCamelCase(getType().getSimpleName());
    return StringUtils.join(sections, " ");
}

From source file:org.openmrs.module.webservices.rest.web.v1_0.resource.openmrs1_9.SystemSettingResource1_9.java

/**
 * Beautifies a string/*from   www.j  av a2  s  . c om*/
 * 
 * @param section
 * @return
 */
private static String beautify(String section) {
    section = section.replace("_", " ");
    section = section.replace(".", " ");

    String[] sections = StringUtils.splitByCharacterTypeCamelCase(section);
    section = StringUtils.join(sections, " ");

    sections = StringUtils.split(section);
    for (int i = 0; i < sections.length; i++) {
        sections[i] = StringUtils.capitalize(sections[i]);
    }
    section = StringUtils.join(sections, " ");

    return section;
}

From source file:org.openmrs.web.controller.maintenance.SettingsProperty.java

/**
 * Beautifies string//from w ww  .  j av  a  2 s .co  m
 *
 * @param section
 * @return
 */
private String beautify(String section) {
    section = section.replace("_", " ");
    section = section.replace(".", " ");

    String[] sections = StringUtils.splitByCharacterTypeCamelCase(section);
    section = StringUtils.join(sections, " ");

    sections = StringUtils.split(section);
    for (int i = 0; i < sections.length; i++) {
        sections[i] = StringUtils.capitalize(sections[i]);
    }
    section = StringUtils.join(sections, " ");

    return section;
}

From source file:org.opennms.features.namecutter.NameCutter.java

public String trimByCamelCase(String name, Integer maxLength) {
    String result = "";
    String[] nameParts = StringUtils.splitByCharacterTypeCamelCase(name);
    Integer charsOver = name.length() - maxLength;
    for (int i = 0; i < charsOver; i++) {
        Integer largest = 0;//from w  ww . j a v  a2  s . c o m
        Integer index = 0;
        for (int j = 0; j < nameParts.length; j++) {
            if (nameParts[j].length() > largest) {
                largest = nameParts[j].length();
                index = j;
            }
        }
        nameParts[index] = StringUtils.chop(nameParts[index]);
    }
    for (String namePart : nameParts) {
        result = result + namePart;
    }
    return result;
}

From source file:org.opennms.features.namecutter.NameCutter.java

public String trimByDictionary(String name) {
    String result = "";

    String[] nameParts = StringUtils.splitByCharacterTypeCamelCase(name);
    for (int i = 0; i < nameParts.length; i++) {
        String namePart = nameParts[i];

        for (String word : dictionary.keySet()) {
            if (namePart.equalsIgnoreCase(word)) {
                logger.debug("dictionary Hit at '{}' result '{}'", name,
                        name.replaceAll(word, dictionary.get(word)));
                nameParts[i] = dictionary.get(word);
            }/*from   w w w  .  j ava 2 s .c  o  m*/
        }
    }
    for (String namePart : nameParts) {
        result = result + namePart;
    }
    return result;
}

From source file:org.opentestsystem.delivery.testreg.domain.Sb11EntityUtils.java

/**
 * // w w w  .  jav  a  2s .co  m
 * Returns Camel cased string to human readable text.Take a look at the examples below <br>
 * <code>
 * <br>
"lowercase"         => lowercase<br>
"Class"             => Class<br>
"MyClass",          => My Class<br>
"HTML",             => HTML<br>
"PDFLoader",        => PDF Loader<br>
"AString",          => A String<br>
"SimpleXMLParser", =>  Simple XML Parser<br>
"GL11Version",     =>  GL 11 Version<br>
"99Bottles",       =>  99 Bottles<br>
"May5",            =>  May 5<br>
"BFG9000",         =>  BFG 9000<br>
<br>
 * </code>
 * 
 * 
 * @param label
 *            CamelCased label
 * @return Normal Human readable text.
 */
public static String getHumanReadableName(final String label) {
    return StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(label), ' ');
}

From source file:org.sonar.plugins.gosu.codenarc.Rule.java

private static String cleanName(String internalKey) {
    String result = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(internalKey), ' ');
    return result.replace("J Unit", "JUnit");
}

From source file:org.sonar.plugins.groovy.codenarc.Converter.java

private void rule(Class<? extends AbstractRule> ruleClass, String since) throws Exception {
    if (duplications.contains(ruleClass)) {
        System.out.println("Duplicated rule " + ruleClass.getName());
    } else {//from  ww w . ja v  a2s  .  c o  m
        duplications.add(ruleClass);
    }
    AbstractRule rule = ruleClass.newInstance();
    String key = ruleClass.getCanonicalName();
    String configKey = StringUtils.removeEnd(ruleClass.getSimpleName(), "Rule");
    String name = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(configKey), ' ');
    String priorityStr = priority(rule.getPriority());
    String description = props.getProperty(configKey + ".description.html");

    SortedSet<String> params = new TreeSet<String>();

    // extract params
    String[] params1 = StringUtils.substringsBetween(description, "${", "}");
    if (params1 != null) {
        for (String param : params1) {
            description = StringUtils.remove(description, " (${" + param + "})");
            param = StringUtils.removeStart(param, "rule.");
            params.add(param);
        }
    }

    String[] params2 = StringUtils.substringsBetween(description, "<em>", "</em> property");
    if (params2 != null) {
        params.addAll(Arrays.asList(params2));
    }

    String[] params3 = StringUtils.substringsBetween(description, "configured in <em>", "</em>");
    if (params3 != null) {
        params.addAll(Arrays.asList(params3));
    }

    if (StringUtils.contains(description, "length property")) {
        params.add("length");
    }
    if (StringUtils.contains(description, "sameLine property")) {
        params.add("sameLine");
    }

    // output
    if (since != null) {
        out.println("  <!-- since " + since + " -->");
    }
    out.println("  <rule key=\"" + key + "\"" + " priority=\"" + priorityStr + "\">");
    out.println("    <name><![CDATA[" + name + "]]></name>");
    out.println("    <configKey><![CDATA[" + configKey + "]]></configKey>");
    out.println("    <description><![CDATA[" + description + "]]></description>");

    if (params != null) {
        for (String param : params) {
            out.println("    <param key=\"" + param + "\"/>");
        }
    }

    out.println("  </rule>");
    out.println();
    count++;
}

From source file:org.trzcinka.intellitrac.utils.StringConversionUtils.java

public static String toUnderscore(String mixedCaseExpression) {
    String[] values = StringUtils.splitByCharacterTypeCamelCase(mixedCaseExpression);
    String[] result = new String[values.length * 2];
    for (int i = 0; i < values.length; i++) {
        String value = values[i];
        result[i * 2] = value.toLowerCase();
        if (i < values.length - 1) {
            result[i * 2 + 1] = "_";
        }/*w  ww. j a va2s  . c  om*/
    }
    return StringUtils.join(result);
}

From source file:org.vbossica.springbox.cliapp.AbstractSpringModule.java

/**
 * Returns the name of the Spring application context to load. By default, the name is the lowercased name of the
 * module class, with the words separated by an underscore.<p>
 *
 * <b>Example</b>/*from   w  w  w .j  av  a2 s.  c  o  m*/
 *
 * <ul>
 *   <li>{@code SampleModule.class} =&gt; {@code META-INF/sample_module.xml}</li>
 * </ul>
 * @return filename of the application context
 */
protected String getApplicationContextFilename() {
    String filename = StringUtils
            .join(StringUtils.splitByCharacterTypeCamelCase(ClassUtils.getShortClassName(getClass())), '_')
            .toLowerCase();
    return "META-INF/" + filename + ".xml";
}