/** * Handle velocity comments and directive. * * @param contentBuffer the final result buffer * @param array the source * @param currentIndex the current index in the source * @param context the velocity parser context * @param filterContext the filter context * @return the index after the comment or directive * @throws InvalidVelocityException not velocity */ private int cleanKeyWord(StringBuffer contentBuffer, char[] array, int currentIndex, VelocityParserContext context, FilterContext filterContext) throws InvalidVelocityException { int i = this.velocityParser.getKeyWord(array, currentIndex, null, context); if (context.getType() != VelocityType.COMMENT) { if (context.getType() == VelocityType.DIRECTIVE) { if (filterContext.wsGroup.length() == 0) { flushWhiteSpaces(filterContext.wsGroup, filterContext, false); } filterContext.wsGroup.append(array, currentIndex, i - currentIndex); filterContext.removeWhiteSpaces = true; } else { flushWhiteSpaces(contentBuffer, filterContext, false); contentBuffer.append(array, currentIndex, i - currentIndex); } } return i; }