Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package com.yammer.metrics.jdbi.strategies;
 
 
 
 public class StatementName {
    
Characters safe to be used in JMX names.
    private static final Pattern JMX_SAFE_CHARS = Pattern.compile("[^a-zA-Z0-9_\\.-]");
    public static MetricName getJmxSafeName(String groupNameString typeNameString statementName) {
        return new MetricName(getJmxSafeName(groupName),
                              getJmxSafeName(typeName),
                              getJmxSafeName(statementName));
    }

    
Turns an arbitrary string into a JMX safe name.

Parameters:
name an arbitrary string
Returns:
a JMX-safe name
    private static String getJmxSafeName(String name) {
        final String result = .matcher(name).replaceAll("_");
        if (result == null || result.length() == 0) {
            return "";
        }
        return (Character.isDigit(result.charAt(0))) ? "_" + result : result;
    }
New to GrepCode? Check out our FAQ X