/** * Construct a new URI template. * <p> * The template will be parsed to extract template variables. * <p> * A specific regular expression will be generated from the template * to match URIs according to the template and map template variables to * template values. * <p> * @param templateParser the parser to parse the template. * @throws PatternSyntaxException if the specified * regular expression could not be generated * @throws IllegalArgumentException if the template is null or * an empty string. */ protected UriTemplate(UriTemplateParser templateParser) throws PatternSyntaxException, IllegalArgumentException { this.template = templateParser.getTemplate(); this.normalizedTemplate = templateParser.getNormalizedTemplate(); this.pattern = createUriPattern(templateParser); this.numOfExplicitRegexes = templateParser.getNumberOfExplicitRegexes(); this.numOfCharacters = templateParser.getNumberOfLiteralCharacters(); this.endsWithSlash = template.charAt(template.length() - 1) == '/'; this.templateVariables = Collections.unmodifiableList(templateParser.getNames()); }
/** * Construct a new URI template. * <p> * The template will be parsed to extract template variables. * <p> * A specific regular expression will be generated from the template * to match URIs according to the template and map template variables to * template values. * <p> * @param templateParser the parser to parse the template. * @throws PatternSyntaxException if the specified * regular expression could not be generated * @throws IllegalArgumentException if the template is null or * an empty string. */ protected UriTemplate(UriTemplateParser templateParser) throws PatternSyntaxException, IllegalArgumentException { this.template = templateParser.getTemplate(); this.normalizedTemplate = templateParser.getNormalizedTemplate(); this.pattern = createUriPattern(templateParser); this.numOfExplicitRegexes = templateParser.getNumberOfExplicitRegexes(); this.numOfCharacters = templateParser.getNumberOfLiteralCharacters(); this.endsWithSlash = template.charAt(template.length() - 1) == '/'; this.templateVariables = Collections.unmodifiableList(templateParser.getNames()); }