return;
}
List pieces = new ArrayList();
List combined = new LinkedList();
String rawTemplate = getTemplate();
PatternMatcher matcher = (Perl5Matcher) localMatcher.get();
Pattern templatePattern =
patternCache.getPattern(
"\\$(\\d+)\\$",
Perl5Compiler.READ_ONLY_MASK & Perl5Compiler.SINGLELINE_MASK);
log.debug("Pattern = " + templatePattern);
log.debug("template = " + rawTemplate);
Util.split(pieces, matcher, templatePattern, rawTemplate);
PatternMatcherInput input = new PatternMatcherInput(rawTemplate);
Iterator iter = pieces.iterator();
boolean startsWith = isFirstElementGroup(rawTemplate);
log.debug(
"template split into "
+ pieces.size()
+ " pieces, starts with = "
+ startsWith);
while (iter.hasNext())
{
boolean matchExists = matcher.contains(input, templatePattern);
if (startsWith)
{
if (matchExists)
{
combined.add(new Integer(matcher.getMatch().group(1)));
}
combined.add(iter.next());
}
else
{
combined.add(iter.next());
if (matchExists)
{
combined.add(new Integer(matcher.getMatch().group(1)));
}
}
}
if (matcher.contains(input, templatePattern))
{
log.debug("Template does end with template pattern");
combined.add(new Integer(matcher.getMatch().group(1)));
}
template = combined.toArray();
}