Merge "Move method to create a highlighting html string into Util class"
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/HighlightingInlineHyperlink.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/HighlightingInlineHyperlink.java
index 255f823..00825a3 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/HighlightingInlineHyperlink.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/HighlightingInlineHyperlink.java
@@ -14,7 +14,6 @@
 
 package com.google.gerrit.client.ui;
 
-import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
 
 public class HighlightingInlineHyperlink extends InlineHyperlink {
 
@@ -34,27 +33,6 @@
   }
 
   private void highlight(final String text, final String toHighlight) {
-    if (toHighlight == null || "".equals(toHighlight)) {
-      return;
-    }
-
-    final SafeHtmlBuilder b = new SafeHtmlBuilder();
-    int pos = 0;
-    int endPos = 0;
-    while ((pos = text.toLowerCase().indexOf(
-        toHighlight.toLowerCase(), pos)) > -1) {
-      if (pos > endPos) {
-        b.append(text.substring(endPos, pos));
-      }
-      endPos = pos + toHighlight.length();
-      b.openElement("b");
-      b.append(text.substring(pos, endPos));
-      b.closeElement("b");
-      pos = endPos;
-    }
-    if (endPos < text.length()) {
-      b.append(text.substring(endPos));
-    }
-    setHTML(b.toSafeHtml().asString());
+    setHTML(Util.highlight(text, toHighlight));
   }
 }
diff --git a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Util.java b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Util.java
index 13d0bd9..804eee1 100644
--- a/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Util.java
+++ b/gerrit-gwtui/src/main/java/com/google/gerrit/client/ui/Util.java
@@ -15,8 +15,35 @@
 package com.google.gerrit.client.ui;
 
 import com.google.gwt.core.client.GWT;
+import com.google.gwtexpui.safehtml.client.SafeHtmlBuilder;
 
 public class Util {
   public static final UIConstants C = GWT.create(UIConstants.class);
   public static final UIMessages M = GWT.create(UIMessages.class);
+
+  public static String highlight(final String text, final String toHighlight) {
+    final SafeHtmlBuilder b = new SafeHtmlBuilder();
+    if (toHighlight == null || "".equals(toHighlight)) {
+      b.append(text);
+      return b.toSafeHtml().asString();
+    }
+
+    int pos = 0;
+    int endPos = 0;
+    while ((pos = text.toLowerCase().indexOf(
+        toHighlight.toLowerCase(), pos)) > -1) {
+      if (pos > endPos) {
+        b.append(text.substring(endPos, pos));
+      }
+      endPos = pos + toHighlight.length();
+      b.openElement("b");
+      b.append(text.substring(pos, endPos));
+      b.closeElement("b");
+      pos = endPos;
+    }
+    if (endPos < text.length()) {
+      b.append(text.substring(endPos));
+    }
+    return b.toSafeHtml().asString();
+  }
 }