}
private URI doBuild(boolean fromEncoded, Object... values) {
try {
String thePath = buildPath(fromEncoded);
URITemplate pathTempl = new URITemplate(thePath);
thePath = substituteVarargs(pathTempl, values, 0);
String theQuery = buildQuery(fromEncoded);
if (theQuery != null) {
URITemplate queryTempl = new URITemplate(theQuery);
int lengthDiff = values.length - pathTempl.getVariables().size();
if (lengthDiff > 0) {
theQuery = substituteVarargs(queryTempl, values, values.length - lengthDiff);
}
}