
com.atlassian.clover.util.format.HtmlFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of clover Show documentation
Show all versions of clover Show documentation
Clover is an award winning code coverage and testing tool for Java and Groovy.
It integrates easily with Maven, Ant, Grails, Eclipse and IntelliJ IDEA
as well as with continuous integration servers such as Bamboo, Jenkins or Hudson.
Note: before Clover 4.0 this artifact was named com.cenqua.clover:clover.
The newest version!
package com.atlassian.clover.util.format;
public class HtmlFormatter {
public static String format(String message) {
try {
StringBuilder buffer = new StringBuilder();
MessageTokenizer tokenizer = new MessageTokenizer(message);
while (tokenizer.hasNext()) {
int token = tokenizer.nextToken();
if (token == MessageTokenizer.ANCHOR_START) {
buffer.append(readAnchor(tokenizer));
} else if (token == MessageTokenizer.HORIZONTAL_LINE) {
buffer.append("
");
} else {
buffer.append(tokenizer.getContent());
}
}
String formatted = buffer.toString();
// replace all of the new line characters.
return StringFormatting.replaceAll(formatted, "\n", "
");
} catch (MessageFormatException e) {
return message;
}
}
private static String readAnchor(MessageTokenizer tokenizer) throws MessageFormatException {
StringBuilder buffer = new StringBuilder();
int token = 0;
while (tokenizer.hasNext()) {
token = tokenizer.nextToken();
if (token == MessageTokenizer.ANCHOR_END) {
break;
}
buffer.append(tokenizer.getContent());
}
String anchor = buffer.toString();
return "" + anchor + "";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy