Esempio n. 1
0
 public Template parseTemplate(String template) throws URISyntaxException {
   this.template = template;
   builder = new Builder(template);
   builder.setHasScheme(false);
   builder.setHasAuthority(
       false); // Assume no until found otherwise.  If true, will cause // in output URL.
   builder.setIsAuthorityOnly(false);
   builder.setIsAbsolute(
       false); // Assume relative until found otherwise.  If true, will cause leading / in output
   // URL.
   builder.setIsDirectory(
       false); // Assume a file path until found otherwise.  If true, will cause trailing / in
   // output URL.
   builder.setHasQuery(
       false); // Assume no ? until found otherwise.  If true, will cause ? in output URL.
   builder.setHasFragment(
       false); // Assume no # until found otherwise.  If true, will cause # in output URL.
   Matcher match = PATTERN.matcher(template);
   if (match.matches()) {
     consumeSchemeMatch(match);
     consumeAuthorityMatch(match);
     consumePathMatch(match);
     consumeQueryMatch(match);
     consumeFragmentMatch(match);
     fixNakedAuthority();
   } else {
     throw new URISyntaxException(template, RES.parseTemplateFailureReason(template));
   }
   return builder.build();
 }