@Test public void testResolveDefinition() { Definition def = new Definition(); def.setName("testDef(.*)\\.message(.*)"); def.setTemplateAttribute(Attribute.createTemplateAttribute("/test{1}.jsp")); def.putAttribute("body", new Attribute("message{2}")); DefinitionPatternMatcher patternMatcher = new RegexpDefinitionPatternMatcher("testDef(.*)\\.message(.*)", def); Definition result = patternMatcher.createDefinition("testDefOne.messageTwo"); assertNotNull(result); assertEquals("testDefOne.messageTwo", result.getName()); assertEquals("/testOne.jsp", result.getTemplateAttribute().getValue()); assertEquals("messageTwo", result.getAttribute("body").getValue()); }
public Definition createDefinition(String definitionName) { Definition retValue = null; Matcher matcher = pattern.matcher(definitionName); if (matcher.matches()) { int groupCount = matcher.groupCount() + 1; Object[] vars = new Object[groupCount]; for (int i = 0; i < groupCount; i++) { vars[i] = matcher.group(i); } retValue = PatternUtil.replacePlaceholders(definition, definitionName, vars); } return retValue; }
RegexpDefinitionPatternMatcher implements DefinitionPatternMatcher { public Definition createDefinition(String definitionName) { Definition retValue = null; Matcher matcher = pattern.matcher(definitionName); if (matcher.matches()) { int groupCount = matcher.groupCount() + 1; Object[] vars = new Object[groupCount]; for (int i = 0; i < groupCount; i++) { vars[i] = matcher.group(i); } retValue = PatternUtil.replacePlaceholders(definition, definitionName, vars); } return retValue; } }
RegexpDefinitionPatternMatcher implements DefinitionPatternMatcher { public Definition createDefinition(String definitionName) { Definition retValue = null; Matcher matcher = pattern.matcher(definitionName); if (matcher.matches()) { int groupCount = matcher.groupCount() + 1; Object[] vars = new Object[groupCount]; for (int i = 0; i < groupCount; i++) { vars[i] = matcher.group(i); } retValue = PatternUtil.replacePlaceholders(definition, definitionName, vars); } return retValue; } RegexpDefinitionPatternMatcher(String pattern, Definition definition); }
RegexpDefinitionPatternMatcher implements DefinitionPatternMatcher { public Definition createDefinition(String definitionName) { Definition retValue = null; Matcher matcher = pattern.matcher(definitionName); if (matcher.matches()) { int groupCount = matcher.groupCount() + 1; Object[] vars = new Object[groupCount]; for (int i = 0; i < groupCount; i++) { vars[i] = matcher.group(i); } retValue = PatternUtil.replacePlaceholders(definition, definitionName, vars); } return retValue; } RegexpDefinitionPatternMatcher(String pattern, Definition definition); Definition createDefinition(String definitionName); }
RegexpDefinitionPatternMatcher implements DefinitionPatternMatcher { public Definition createDefinition(String definitionName) { Definition retValue = null; Matcher matcher = pattern.matcher(definitionName); if (matcher.matches()) { int groupCount = matcher.groupCount() + 1; Object[] vars = new Object[groupCount]; for (int i = 0; i < groupCount; i++) { vars[i] = matcher.group(i); } retValue = PatternUtil.replacePlaceholders(definition, definitionName, vars); } return retValue; } RegexpDefinitionPatternMatcher(String pattern, Definition definition); Definition createDefinition(String definitionName);  }