Normally it's bad to mix your data and display markup within your Java code. However, if there is no other workaround, then you could do the following:
public static String wrapText(String text, String cssClass) {
if (text == null) {
throw new IllegalArgumentException("Text to wrap is null");
}
if (cssClass == null) {
cssClass = "";
}
return "<span class=\"" + cssClass + "\">" + text + "</span>";
}
public String getShortDescription() {
if (isOption1()) {
return "Option " + wrapText("1 heading","heading");
}
...
}