src/main/java/org/jmxtrans/agent/util/PropertyPlaceholderResolver.java
public String resolveString(String string) throws IllegalStateException {

        StringBuilder result = new StringBuilder(string.length());

        int position = 0;
        while (position < string.length()) {
            char c = string.charAt(position);
            if (c == '$' && (position < string.length() - 1) && string.charAt(position + 1) == '{') {
                int beginningBracketPosition = position + 1;
                int endingBracketPosition = string.indexOf('}', beginningBracketPosition);
                int colonPosition = string.indexOf(':', beginningBracketPosition);
                if (colonPosition > endingBracketPosition) {
                    colonPosition = -1;
                }

                String placeholder;
                String defaultValue;
                if (colonPosition == -1) {
                    placeholder = string.substring(beginningBracketPosition + 1, endingBracketPosition);
                    defaultValue = null;
                } else {
                    placeholder = string.substring(beginningBracketPosition + 1, colonPosition);
                    defaultValue = string.substring(colonPosition + 1, endingBracketPosition);
                }

                String resolvedPlaceHolder = resolvePlaceholder(placeholder, defaultValue);
                result.append(resolvedPlaceHolder);
                position = endingBracketPosition + 1;
            } else {
                result.append(c);
                position++;
            }
        }

        return result.toString();
    }
public String resolveString(String string) throws IllegalStateException {

        StringBuilder result = new StringBuilder(string.length());

        int position = 0;
        while (position < string.length()) {
            char c = string.charAt(position);
            if (c == '$' && (position < string.length() - 1) && string.charAt(position + 1) == '{') {
                int beginningBracketPosition = position + 1;
                int endingBracketPosition = string.indexOf('}', beginningBracketPosition);
                int colonPosition = string.indexOf(':', beginningBracketPosition);
                if (colonPosition > endingBracketPosition) {
                    colonPosition = -1;
                }

                String placeholder;
                String defaultValue;
                if (colonPosition == -1) {
                    placeholder = string.substring(beginningBracketPosition + 1, endingBracketPosition);
                    defaultValue = null;
                } else {
                    placeholder = string.substring(beginningBracketPosition + 1, colonPosition);
                    defaultValue = string.substring(colonPosition + 1, endingBracketPosition);
                }

                String resolvedPlaceHolder = resolvePlaceholder(placeholder, defaultValue);
                result.append(resolvedPlaceHolder);
                position = endingBracketPosition + 1;
            } else {
                result.append(c);
                position++;
            }
        }

        return result.toString();
    }
public String resolveString ( String string ) throws IllegalStateException { StringBuilder result = new StringBuilder ( string . length ( ) ) ; int position = 0 ; while ( position < string . length ( ) ) { char c = string . charAt ( position ) ; if ( c == ' ' && ( position < string . length ( ) - 1 ) && string . charAt ( position + 1 ) == ' ' ) { int beginningBracketPosition = position + 1 ; int endingBracketPosition = string . indexOf ( ' ' , beginningBracketPosition ) ; int colonPosition = string . indexOf ( ' ' , beginningBracketPosition ) ; if ( colonPosition > endingBracketPosition ) { colonPosition = - 1 ; } String placeholder ; String defaultValue ; if ( colonPosition == - 1 ) { placeholder = string . substring ( beginningBracketPosition + 1 , endingBracketPosition ) ; defaultValue = null ; } else { placeholder = string . substring ( beginningBracketPosition + 1 , colonPosition ) ; defaultValue = string . substring ( colonPosition + 1 , endingBracketPosition ) ; } String resolvedPlaceHolder = resolvePlaceholder ( placeholder , defaultValue ) ; result . append ( resolvedPlaceHolder ) ; position = endingBracketPosition + 1 ; } else { result . append ( c ) ; position ++ ; } } return result . toString ( ) ; }
Parse the given <code>string</code> resolving property placeholders (<code>${my-property[:default-value]}</code>)

@param string the string to parse.
@return the parsed string. Non <code>null</code>.
@throws IllegalStateException a property placeholder could not be resolved and no default value has been defined.
Parse the given <code > string< / code > resolving property placeholders ( <code > $ { my - property [ : default - value ] } < / code > )