public int parseStartLoop( String content, DirectivesStack directives, int startOfStartListDirectiveIndex ) { // contentWichStartsWithList='[#list developers as d]yyy' String contentWhichStartsWithList = content.substring( startOfStartListDirectiveIndex, content.length() ); int endOfStartListDirectiveIndex = contentWhichStartsWithList.indexOf( ']' ); if ( endOfStartListDirectiveIndex == -1 ) { // [#list not closed with ']' return 0; } // startLoopDirective='[#list developers as d]' String startLoopDirective = contentWhichStartsWithList.substring( 0, endOfStartListDirectiveIndex + 1 ); // insideLoop='developers as d]' String insideLoop = startLoopDirective.substring( START_LIST_DIRECTIVE.length(), startLoopDirective.length() ); int indexBeforeAs = insideLoop.indexOf( " " ); if ( indexBeforeAs == -1 ) { return 0; } // afterSequence=' as d]' String afterSequence = insideLoop.substring( indexBeforeAs, insideLoop.length() ); int indexAfterAs = afterSequence.indexOf( AS_DIRECTIVE ); if ( indexAfterAs == -1 ) { return 0; } // sequence='developpers' String sequence = insideLoop.substring( 0, indexBeforeAs ).trim(); if ( StringUtils.isEmpty( sequence ) ) { return 0; } // afterAs='d]' String afterAs = afterSequence.substring( AS_DIRECTIVE.length(), afterSequence.length() ); int endListIndex = afterAs.indexOf( ']' ); if ( endListIndex == -1 ) { return 0; } // item='d' String item = afterAs.substring( 0, endListIndex ).trim(); if ( StringUtils.isEmpty( item ) ) { return 0; } int nbLoop = 1; directives.push( new LoopDirective( directives.peekOrNull(), startLoopDirective, getEndLoopDirective( null ), sequence, item ) ); // afterList = 'yyy' String afterList = content.substring( startOfStartListDirectiveIndex + startLoopDirective.length(), content.length() ); nbLoop += extractListDirectiveInfo( afterList, directives ); return nbLoop; }
public boolean containsInterpolation(String content) { if (StringUtils.isEmpty(content)) { return false; } int dollarIndex = content.indexOf(DOLLAR_TOTKEN); if (dollarIndex == -1) { // Not included to FM directive return false; } return true; }
protected boolean isModelField(String content, String fieldName) { if (StringUtils.isEmpty(content)) { return false; } int dollarIndex = content.indexOf(DOLLAR_TOTKEN); if (dollarIndex == -1) { // Not included to FM directive return false; } int fieldNameIndex = content.indexOf(fieldName); if (fieldNameIndex < dollarIndex) { // Not included to FM directive return false; } return true; }