private String interpolateExpression(TokenIterator tokenIterator, Context context, Locale locale) throws MessageDescriptorFormatException { while (tokenIterator.hasMoreInterpolationTerms()) { String term = tokenIterator.nextInterpolationTerm(); String resolvedExpression = interpolate(context, locale, term); tokenIterator.replaceCurrentInterpolationTerm(resolvedExpression); } return tokenIterator.getInterpolatedMessage(); }
private String interpolateBundleMessage( String message, ResourceBundle bundle, Locale locale, boolean recursive) throws MessageDescriptorFormatException { TokenCollector tokenCollector = new TokenCollector(message, InterpolationTermType.PARAMETER); TokenIterator tokenIterator = new TokenIterator(tokenCollector.getTokenList()); while (tokenIterator.hasMoreInterpolationTerms()) { String term = tokenIterator.nextInterpolationTerm(); String resolvedParameterValue = resolveParameter(term, bundle, locale, recursive); tokenIterator.replaceCurrentInterpolationTerm(resolvedParameterValue); } return tokenIterator.getInterpolatedMessage(); }