001/* 002 * (C) Copyright 2012 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Thierry Delprat 018 */ 019package org.nuxeo.apidoc.documentation; 020 021import org.apache.commons.lang.StringEscapeUtils; 022 023public class ContributionItem { 024 025 protected String tagName; 026 027 protected String nameOrId; 028 029 protected String documentation; 030 031 protected String xml; 032 033 public void write(StringBuffer sb) { 034 sb.append("\n\n<div>"); 035 sb.append("\n<div>"); 036 sb.append(tagName); 037 if (nameOrId != null) { 038 sb.append(" "); 039 sb.append(nameOrId); 040 } 041 sb.append("</div>"); 042 043 sb.append("\n<p>"); 044 sb.append(DocumentationHelper.getHtml(documentation)); 045 sb.append("</p>"); 046 047 sb.append("\n<code>"); 048 sb.append(StringEscapeUtils.escapeHtml(xml)); 049 sb.append("</code>"); 050 051 sb.append("</div>"); 052 } 053 054 public String getLabel() { 055 StringBuffer sb = new StringBuffer(); 056 sb.append(tagName); 057 if (nameOrId != null) { 058 sb.append(" "); 059 sb.append(nameOrId); 060 } 061 return sb.toString(); 062 } 063 064 public String getId() { 065 return nameOrId; 066 } 067 068 public String getDocumentation() { 069 return DocumentationHelper.getHtml(documentation); 070 } 071 072 public String getXml() { 073 return StringEscapeUtils.escapeHtml(xml); 074 } 075 076 public String getRawXml() { 077 return xml; 078 } 079 080}