/** * Construct * * @param method http method * @param template uri template * @param includeExtension include uri extension in index * @param script associated web script */ IndexEntry(String method, UriTemplate template, boolean includeExtension, WebScript script) { this.method = method.toUpperCase(); this.template = template; this.includeExtension = includeExtension; this.script = script; this.key = template.getRegex() + ":" + this.method; int firstTokenIdx = template.getTemplate().indexOf('{'); this.staticTemplate = (firstTokenIdx == -1) ? template.getTemplate() : template.getTemplate().substring(0, firstTokenIdx); }
/** * Construct * * @param method http method * @param template uri template * @param includeExtension include uri extension in index * @param script associated web script */ IndexEntry(String method, UriTemplate template, boolean includeExtension, WebScript script) { this.method = method.toUpperCase(); this.template = template; this.includeExtension = includeExtension; this.script = script; this.key = template.getRegex() + ":" + this.method; int firstTokenIdx = template.getTemplate().indexOf('{'); this.staticTemplate = (firstTokenIdx == -1) ? template.getTemplate() : template.getTemplate().substring(0, firstTokenIdx); }
/** * Construct * * @param method http method * @param template uri template * @param includeExtension include uri extension in index * @param script associated web script */ IndexEntry(String method, UriTemplate template, boolean includeExtension, WebScript script) { this.method = method.toUpperCase(); this.template = template; this.includeExtension = includeExtension; this.script = script; this.key = template.getRegex() + ":" + this.method; int firstTokenIdx = template.getTemplate().indexOf('{'); this.staticTemplate = (firstTokenIdx == -1) ? template.getTemplate() : template.getTemplate().substring(0, firstTokenIdx); }
if (entry.getMethod().equals(method)) scriptMatch = new Match(entry.getTemplate().getTemplate(), vars, entry.getStaticTemplate(), entry.getScript()); break; scriptMatch = new Match(pathMatch.getTemplate().getTemplate(), varsMatch, pathMatch.getStaticTemplate());
if (entry.getMethod().equals(method)) scriptMatch = new Match(entry.getTemplate().getTemplate(), vars, entry.getStaticTemplate(), entry.getScript()); break; scriptMatch = new Match(pathMatch.getTemplate().getTemplate(), varsMatch, pathMatch.getStaticTemplate());
if (entry.getMethod().equals(method)) scriptMatch = new Match(entry.getTemplate().getTemplate(), vars, entry.getStaticTemplate(), entry.getScript()); break; scriptMatch = new Match(pathMatch.getTemplate().getTemplate(), varsMatch, pathMatch.getStaticTemplate());
public void testParseTemplate() { UriTemplate i1 = new UriTemplate("/"); assertEquals("/", i1.getTemplate()); assertEquals("/", i1.getRegex().pattern()); assertEquals(1, i1.getStaticCharCount()); assertEquals(0, i1.getVariableNames().length); UriTemplate i2 = new UriTemplate("/a/{a1}/b{b1}b/{c_c}"); assertEquals("/a/{a1}/b{b1}b/{c_c}", i2.getTemplate()); assertEquals("/a/(.*?)/b(.*?)b/(.*?)", i2.getRegex().pattern()); assertEquals(7, i2.getStaticCharCount()); assertEquals(3, i2.getVariableNames().length); assertEquals("a1", i2.getVariableNames()[0]); assertEquals("b1", i2.getVariableNames()[1]); assertEquals("c_c", i2.getVariableNames()[2]); }