public List < TextPair > getInlineTextPairs ( boolean markTemplates ) { List < TextPair > pairList = new ArrayList < TextPair > ( ) ; try { //extract sections List < ExtractedSection > beforeSections = null ; List < ExtractedSection > afterSections = null ; if ( markTemplates ) { //add inline marker for the template beforeSections = ParseUtils . getSections ( before . getRevisionText ( ) , before . getRevisionID ( ) + "" , before . getRevisionID ( ) , Arrays . asList ( new String [ ] { template } ) ) ; afterSections = ParseUtils . getSections ( after . getRevisionText ( ) , after . getRevisionID ( ) + "" , after . getRevisionID ( ) , Arrays . asList ( new String [ ] { template } ) ) ; } else { //no inline markers beforeSections = ParseUtils . getSections ( before . getRevisionText ( ) , before . getRevisionID ( ) + "" , before . getRevisionID ( ) ) ; afterSections = ParseUtils . getSections ( after . getRevisionText ( ) , after . getRevisionID ( ) + "" , after . getRevisionID ( ) ) ; } for ( ExtractedSection tplSect : revPairType == RevisionPairType . deleteTemplate ? beforeSections : afterSections ) { // in DELETE-mode, the "before" revision contain the templates // in ADD-mode, the "after" revision contains the templates if ( containsIgnoreCase ( tplSect . getTemplates ( ) , template ) ) { // the current sect contains the template we're looking for // now find the corresponding tpl in the other revisions for ( ExtractedSection nonTplSect : revPairType == RevisionPairType . deleteTemplate ? afterSections : beforeSections ) { // TODO how do we match the sections? // currently only by title - we could do fuzzy matching // of the section body if ( tplSect . getTitle ( ) != null && nonTplSect . getTitle ( ) != null && tplSect . getTitle ( ) . equalsIgnoreCase ( nonTplSect . getTitle ( ) ) ) { if ( revPairType == RevisionPairType . deleteTemplate ) { pairList . add ( new TextPair ( tplSect . getBody ( ) , nonTplSect . getBody ( ) ) ) ; } else { pairList . add ( new TextPair ( nonTplSect . getBody ( ) , tplSect . getBody ( ) ) ) ; } } } } } } catch ( Exception ex ) { //This happends if a (SWEBLE-)compiler exception occurs.S //Sometimes, malformed xml items seem to cause class cast exceptions //in the parser, which is not wrapped in a Compiler exception. //Therefore, we should catch all exceptions here and return the //TextPairs identified so far (if any) System . err . println ( ex . getMessage ( ) ) ; //TODO use logger!! } return pairList ; }
Returns the text around the given template and returns the corresponding text in the other pair part of the RevisionPair .