code: private void fillMapWithTemplateData(String textForTemplateExtraction,
  			TemplateFilter filterToApply, int id,
  			Map<String, Set<Integer>> mapToFill)
  	{
  		Set<String> names = getTemplateNames(textForTemplateExtraction);
  		// Update the map with template values for current page
  		for (String name : names) {
  
  			// filter templates - only use templates from a provided
  			// whitelist
  			if (filterToApply.acceptTemplate(name)) {
  				// Create records for TEMPLATE->PAGES/REVISION map
  				if (mapToFill.containsKey(name)) {
  					// add the page id to the set for the current template
  					Set<Integer> pIdList = mapToFill.remove(name);
  					pIdList.add(id);
  					mapToFill.put(name, pIdList);
  				}
  				else {
  					// add new list with page id of current page
  					Set<Integer> newIdList = new HashSet<Integer>();
  					newIdList.add(id);
  					mapToFill.put(name, newIdList);
  				}
  			}
  		}
  	}
docs: Fill map(mapToFill) with template data
  
  @param textForTemplateExtraction
  text for template extraction
  @param filterToApply
  filter to apply for templates
  @param id
  id of a page/revision
  @param mapToFill
  map to fill with data