public int getDirective ( char [ ] array , int currentIndex , StringBuffer velocityBlock , VelocityParserContext context ) throws InvalidVelocityException { int i = currentIndex + 1 ; // Get macro name StringBuffer directiveNameBuffer = new StringBuffer ( ) ; i = getDirectiveName ( array , i , directiveNameBuffer , null , context ) ; String directiveName = directiveNameBuffer . toString ( ) ; if ( ! VELOCITYDIRECTIVE_NOPARAM . contains ( directiveName ) ) { // Skip spaces while ( i < array . length && array [ i ] == ' ' ) { ++ i ; } if ( i < array . length && array [ i ] == ' ' ) { // Skip condition i = getMethodParameters ( array , i , null , context ) ; } else { throw new InvalidVelocityException ( ) ; } } if ( VELOCITYDIRECTIVE_ALL . contains ( directiveName ) ) { if ( VELOCITYDIRECTIVE_BEGIN . contains ( directiveName ) ) { context . pushVelocityElement ( new VelocityBlock ( directiveName , VelocityBlock . VelocityType . DIRECTIVE ) ) ; } else if ( VELOCITYDIRECTIVE_END . contains ( directiveName ) ) { context . popVelocityElement ( ) ; } // consume the end of the line i = getDirectiveEndOfLine ( array , i , null , context ) ; context . setType ( VelocityBlock . VelocityType . DIRECTIVE ) ; } else { context . setType ( VelocityBlock . VelocityType . MACRO ) ; } if ( velocityBlock != null ) { velocityBlock . append ( array , currentIndex , i - currentIndex ) ; } return i ; }
Get any valid Velocity block starting with a sharp character except comments .