Example usage for org.apache.commons.lang WordUtils initials

List of usage examples for org.apache.commons.lang WordUtils initials

Introduction

In this page you can find the example usage for org.apache.commons.lang WordUtils initials.

Prototype

public static String initials(String str, char[] delimiters) 

Source Link

Document

Extracts the initial letters from each word in the String.

The first letter of the string and all first letters after the defined delimiters are returned as a new string.

Usage

From source file:com.notio.example.karaf.provision.s2.ExampleServiceImpl.java

public String sayHello(String name) {
    if (LOG.isInfoEnabled()) {
        LOG.info("sayHello('{}')", name);
    }//from   w  ww. j ava 2  s . c o  m
    final String caps = WordUtils.capitalize(name);
    final String initials = WordUtils.initials(caps, INITIAL_DELIMS);
    return String.format(FMT, caps, ExampleServiceImpl.class.getName(), initials);
}

From source file:com.googlecode.jmxtrans.model.output.RRDToolWriter.java

/**
 * rrd datasources must be less than 21 characters in length, so work to
 * make it shorter. Not ideal at all, but works fairly well it seems.
 *//* w w w  .j  a  v a 2s.co  m*/
public String getDataSourceName(String typeName, String attributeName, String entry) {
    String result;
    if (typeName != null) {
        result = typeName + attributeName + entry;
    } else {
        result = attributeName + entry;
    }

    if (attributeName.length() > 15) {
        String[] split = StringUtils.splitByCharacterTypeCamelCase(attributeName);
        String join = StringUtils.join(split, '.');
        attributeName = WordUtils.initials(join, INITIALS);
    }
    result = attributeName + DigestUtils.md5Hex(result);

    result = StringUtils.left(result, 19);

    return result;
}