Source:
<code>public final String highlight(final String attribute, final Query parsedQuery) { <START> UseCase uc = MonitorFactory.startUseCase("Highlight.PhraseBolder.highlight()"); <END> StringBuilder result = new StringBuilder(); if (attribute != null && parsedQuery != null) { Highlighter highlighter = new Highlighter(this, new QueryScorer(parsedQuery)); highlighter.setTextFragmenter(getFragmenter()); try { TokenStream tokenStream = analyzer.tokenStream(this.getHighlightAttribute(), new StringReader(attribute)); UseCase ucFragments = MonitorFactory.startUseCase("Highlight.PhraseBolder.highlight()#getFragments"); TextFragment[] frags = highlighter.getBestTextFragments(tokenStream, attribute, mergeAdjacentFragments(), getMaxFragments()); ucFragments.stop(); boolean first = true; int startPosition = -1; int endPosition = -1; for (TextFragment frag : frags) { String fragment = frag.toString(); fragment = fragment.replaceAll(REMOVE_TEXT_FROM_FRAGMENT_REGEX, ""); startPosition = attribute.indexOf(fragment); endPosition = startPosition + fragment.length(); if (!first || (addSeperatorArroundAllFragments() && startPosition != 0)) { result.append(getFragmentSeperator()); } result.append(fragment); } if (addSeperatorArroundAllFragments() && endPosition != attribute.length() && result.length() != 0) { result.append(getFragmentSeperator()); } } catch (IOException e) { LOGGER.error("Error getting fragments from highlighter.", e); } catch (InvalidTokenOffsetsException e) { LOGGER.error("Error getting fragments from highlighter.", e); } } uc.stop(); return result.toString(); }</code><technical_language>This break code refactored</technical_language>

Target:
public final String highlight(final String attribute, final Query parsedQuery) { UseCase uc = MonitorFactory.startUseCase("Highlight.PhraseBolder.highlight()"); StringBuilder result = new StringBuilder(); if (attribute != null && parsedQuery != null) { Highlighter highlighter = new Highlighter(this, new QueryScorer(parsedQuery)); highlighter.setTextFragmenter(getFragmenter()); try { TokenStream tokenStream = analyzer.tokenStream(this.getHighlightAttribute(), new StringReader(attribute)); UseCase ucFragments = MonitorFactory.startUseCase("Highlight.PhraseBolder.highlight()#getFragments"); TextFragment[] frags = highlighter.getBestTextFragments(tokenStream, attribute, isMergeAdjacentFragments(), getMaxFragments()); ucFragments.stop(); boolean first = true; int startPosition = -1; int endPosition = -1; for (TextFragment frag : frags) { String fragment = frag.toString(); fragment = fragment.replaceAll(REMOVE_TEXT_FROM_FRAGMENT_REGEX, ""); startPosition = attribute.indexOf(fragment); endPosition = startPosition + fragment.length(); if (!first || (addSeperatorArroundAllFragments() && startPosition != 0)) { result.append(getFragmentSeperator()); } result.append(fragment); } if (addSeperatorArroundAllFragments() && endPosition != attribute.length() && result.length() != 0) { result.append(getFragmentSeperator()); } } catch (IOException e) { LOGGER.error("Error getting fragments from highlighter.", e); } catch (InvalidTokenOffsetsException e) { LOGGER.error("Error getting fragments from highlighter.", e); } } uc.stop(); return result.toString(); }