2 * Rhynodge - DefaultOutput.java - Copyright © 2013 David Roden
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package net.pterodactylus.rhynodge.output;
22 import com.google.common.collect.Maps;
25 * {@link Output} implementation that stores texts for arbitrary MIME types.
27 * @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
29 public class DefaultOutput implements Output {
31 /** The summary of the output. */
32 private final String summary;
34 /** The texts for the different MIME types. */
35 private final Map<String, String> mimeTypeTexts = Maps.newHashMap();
38 * Creates a new default output.
41 * The summary of the output
43 public DefaultOutput(String summary) {
44 this.summary = summary;
52 * Adds the given text for the given MIME type.
55 * The MIME type to add the text for
58 * @return This default output
60 public DefaultOutput addText(String mimeType, String text) {
61 mimeTypeTexts.put(mimeType, text);
73 public String summary() {
81 public String text(String mimeType, int maxLength) {
82 return mimeTypeTexts.get(mimeType);