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