/** * An implementation of var substitution as defined by the * <a href="http://bitworking.org/projects/URI-Templates/spec/draft-gregorio-uritemplate-03.html#var">URI template specification</a>. * <p/> * If for a given variable, the variable is in the name/value map but the associated value is null. The variable will be replaced with an empty string or with the default value if any. * * @param expansionPattern an expansion pattern (not a uri template) e.g. "{foo}" * @param expansionInfo the result of {@link #parseExpansion(String)} for the given expansion pattern * @param nameValuePairs the Map<String, String> of names and associated values. May containt null values. * @return the expanded string, properly escaped. * @throws URIException if an encoding exception occured * @see org.apache.commons.httpclient.util.URIUtil#encodeWithinQuery(String) * @see java.net.URI */ public static String varSubstitution(String expansionPattern, Object[] expansionInfo, Map<String, String> nameValuePairs) throws URIException { return varSubstitution(expansionPattern, expansionInfo, nameValuePairs, false); }
} else { sb.append(varSubstitution(expansionPattern, expansionInfo, nameValuePairs, preserveUndefinedVar));