View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2005 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.services.monitoring.jmx.display;
18  
19  /**
20   * Section of a page.
21   *
22   * @svnLink $Revision: 3883 $;$Date: 2009-08-04 15:35:01 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/jmx/src/main/java/ch/elca/el4j/services/monitoring/jmx/display/Section.java $
23   *
24   * @author David Bernhard (DBD)
25   */
26  public class Section {
27  
28  	/** Section title. */
29  	private String m_name;
30  	
31  	/** Section content. */
32  	private String m_content;
33  	
34  	/**
35  	 * @param name Creates a new section with this name.
36  	 */
37  	public Section(String name) {
38  		m_name = name;
39  		m_content = "";
40  	}
41  	
42  	/**
43  	 * @param string Adds <code>string</code> to content.
44  	 */
45  	public void add(String string) {
46  		m_content += string;
47  	}
48  	
49  	/**
50  	 * @param string Adds content between p tags and newline at end.
51  	 */
52  	public void addLine(String string) {
53  		add(HtmlDisplayManager.tag("p", string) + "\n");
54  	}
55  	
56  	/**
57  	 * @param string Adds a warning - currently in italics and red.
58  	 */
59  	public void addWarning(String string) {
60  		add(HtmlDisplayManager.tagRecursive(
61  			"<font color=#ff0000>" + string + "</font>",
62  			"p", "i") + "\n");
63  	}
64  	
65  	/**
66  	 * Adds a 1x1 table with the key in the title and the value in the table.
67  	 * @param key A property key.
68  	 * @param value A property value.
69  	 */
70  	public void addProperty(String key, String value) {
71  		HtmlTabulator tab = new HtmlTabulator(key);
72  		tab.addRow(value);
73  		m_content += HtmlDisplayManager.tag("p", tab.tabulate()) + "\n";
74  	}
75  	
76  	/**
77  	 * @return The content.
78  	 */
79  	public String getContent() {
80  		return m_content;
81  	}
82  	
83  	/**
84  	 * @return The section name (title).
85  	 */
86  	public String getName() {
87  		return m_name;
88  	}
89  	
90  	
91  }