private void processGroups ( MutableTemplateInfo template ) throws TemplateException { List < TemplateTokenGroupInfo > groupInfos = template . groupInfo ; List < String > allGroupTokens = new ArrayList < String > ( ) ; for ( TemplateTokenGroupInfo groupInfo : groupInfos ) { for ( String newToken : groupInfo . getContainsString ( ) ) { if ( allGroupTokens . contains ( newToken ) ) { throw new TemplateException ( "Token " + newToken + " in template group : '" + groupInfo . getName ( ) + "' already exists in another group" ) ; } else { allGroupTokens . add ( newToken ) ; } } } List < String > containsList = new ArrayList < String > ( ) ; for ( TemplateTokenInfo tokenInfo : template . tokenInfos ) { if ( ! allGroupTokens . contains ( tokenInfo . getName ( ) ) ) { //if its not already in another group, add containsList . add ( tokenInfo . getName ( ) ) ; } } if ( containsList . size ( ) != 0 ) { TemplateTokenGroupInfo allOthersGroup = new TemplateTokenGroupInfo ( null , containsList , "" , true ) ; //this will have a group order of '0' by default and will appear at the top when sorted template . groupInfo . add ( allOthersGroup ) ; } for ( TemplateTokenGroupInfo groupInfo : template . groupInfo ) { groupInfo . setParentGroups ( template . tokenInfos ) ; } }
creates a group containing all tokens not contained in any other sections - an all others group