Java Code Examples for org.apache.commons.lang.StringUtils.lastOrdinalIndexOf()

The following are Jave code examples for showing how to use lastOrdinalIndexOf() of the org.apache.commons.lang.StringUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: oneops   File: HPOMTransformer.java   Source Code and License Vote up 5 votes
public String getComponentName(String ciName) {

        int index = StringUtils.lastOrdinalIndexOf(ciName, "-", 2);
        if (!(index > 0)) {
            return null;
        }
        return ciName.substring(0, index);
    }
 
Example 2
Project: athena   File: DefaultInfluxDbMetricsRetriever.java   Source Code and License Vote up 5 votes
/**
 * Returns metric name from full name.
 * The elements in full name is split by using '.';
 * We assume that the metric name always comes after the last three '.'
 *
 * @param fullName full name
 * @return metric name
 */
private String getMetricName(String fullName) {
    int index = StringUtils.lastOrdinalIndexOf(fullName,
            METRIC_DELIMITER, NUB_OF_DELIMITER);
    if (index != -1) {
        return StringUtils.substring(fullName, index + 1);
    } else {
        log.warn("Database {} contains malformed metric name.", database);
        return null;
    }
}
 
Example 3
Project: athena   File: DefaultInfluxDbMetricsRetriever.java   Source Code and License Vote up 5 votes
/**
 * Returns node id from full name.
 * The elements in full name is split by using '.';
 * We assume that the node id always comes before the last three '.'
 *
 * @param fullName full name
 * @return node id
 */
private String getNodeId(String fullName) {
    int index = StringUtils.lastOrdinalIndexOf(fullName,
            METRIC_DELIMITER, NUB_OF_DELIMITER);
    if (index != -1) {
        return StringUtils.substring(fullName, 0, index);
    } else {
        log.warn("Database {} contains malformed node id.", database);
        return null;
    }
}