Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add BugUrlReplacer to clean up bare URLs
This transformation was suggested by Brian Campbell.
- Loading branch information
Showing
3 changed files
with
72 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package buglinky; | ||
|
||
import java.util.regex.Matcher; | ||
import java.util.regex.Pattern; | ||
|
||
import com.google.wave.api.Range; | ||
import com.google.wave.api.TextView; | ||
|
||
/** | ||
* Convert raw bug tracker URLs into text of the form "issue #NNN". | ||
*/ | ||
class BugUrlReplacer extends BlipProcessor { | ||
/** The URL to a bug, minus the actual bug number. */ | ||
private String bugUrl; | ||
|
||
/** Create a BugUrlReplacer for the specified URL. */ | ||
public BugUrlReplacer(String bugUrl) { | ||
super(); | ||
this.bugUrl = bugUrl; | ||
} | ||
|
||
@Override | ||
protected String getPattern() { | ||
return Pattern.quote(bugUrl) + "(\\d+)"; | ||
} | ||
|
||
@Override | ||
protected void processMatch(TextView doc, Range range, Matcher match) { | ||
replace(doc, range, "issue #" + match.group(1)); | ||
} | ||
|
||
} |