private void check() throws IOException, UnsupportedEncodingException {
		PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
		for (Resource resource : resolver.getResources(rootPath)) {
			String current = stripExtension(resource.getFilename());
			BufferedReader reader = new BufferedReader(new InputStreamReader(resource.getInputStream(), "UTF-8"));
			String line = null;
			int lineNumber = 0;
			while ((line = reader.readLine()) != null) {
				lineNumber++;

				Matcher matcher = ANCHOR_PATTERN.matcher(line);
				if (matcher.matches()) {
					String anchor = matcher.group(1);
					String previous = anchors.put(anchor, current);
					if (previous != null) {
						error("Anchor '%s' exists in both %s and %s.%n", anchor,
								previous, current);
					}
				}

				matcher = LINK_PATTERN.matcher(line);
				while (matcher.find()) {
					links.add(new Link(current, lineNumber, matcher.group(1), matcher.group(2)));
				}
			}
			reader.close();
		}

		for (Link link : links) {
			String target = anchors.get(link.targetAnchor);
			if (target == null) {
				error("The link at %s@%d pointing to %s#%s references an undefined anchor.%n",
						link.owningFile, link.line, link.targetFile, link.targetAnchor);
			}
			else if (!target.equals(link.targetFile)) {
				error(
						"The link at %s@%d pointing to %s#%s references an anchor that is actually defined in '%s'.%n",
						link.owningFile, link.line, link.targetFile, link.targetAnchor, target);
			}
		}


	}
A tool that checks that for files that will form the whole "concatenated" documentation, any link of the form
<pre>
{@code
link:<file>:<anchor>[<label>]
}
</pre>
indeed points to an <em>explicit</em> and <em>unique across all included files</em> anchor in the given file.

@author Eric Bottard
documentation-toolchain/src/main/java/org/springframework/xd/documentation/AsciidocLinkChecker.java