1 /* 2 * Copyright 2007-2013 smartics, Kronseder & Reiner GmbH 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 package de.smartics.exceptions.report.renderer.html; 17 18 import org.apache.commons.lang.StringEscapeUtils; 19 20 import com.thoughtworks.qdox.model.DocletTag; 21 22 import de.smartics.exceptions.report.renderer.CodeTagRenderer; 23 24 /** 25 * Default implementation that renders the code tag as HTML. 26 */ 27 public class HtmlCodeTagRenderer implements CodeTagRenderer 28 { 29 // ********************************* Fields ********************************* 30 31 // --- constants ------------------------------------------------------------ 32 33 // --- members -------------------------------------------------------------- 34 35 // ****************************** Initializer ******************************* 36 37 // ****************************** Constructors ****************************** 38 39 // ****************************** Inner Classes ***************************** 40 41 // ********************************* Methods ******************************** 42 43 // --- init ----------------------------------------------------------------- 44 45 // --- get&set -------------------------------------------------------------- 46 47 // --- business ------------------------------------------------------------- 48 49 @Override 50 public StringBuilder render(final StringBuilder buffer, final DocletTag tag) 51 { 52 final String text = tag.getValue(); 53 final String encodedText = StringEscapeUtils.escapeHtml(text); 54 buffer.append("<code>").append(encodedText).append("</code>"); 55 return buffer; 56 } 57 58 // --- object basics -------------------------------------------------------- 59 60 }