KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > protomatter > syslog > xml > HTMLSyslogTextFormatter_Helper


1 package com.protomatter.syslog.xml;
2
3 /**
4  * {{{ The Protomatter Software License, Version 1.0
5  * derived from The Apache Software License, Version 1.1
6  *
7  * Copyright (c) 1998-2002 Nate Sammons. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  *
13  * 1. Redistributions of source code must retain the above copyright
14  * notice, this list of conditions and the following disclaimer.
15  *
16  * 2. Redistributions in binary form must reproduce the above copyright
17  * notice, this list of conditions and the following disclaimer in
18  * the documentation and/or other materials provided with the
19  * distribution.
20  *
21  * 3. The end-user documentation included with the redistribution,
22  * if any, must include the following acknowledgment:
23  * "This product includes software developed for the
24  * Protomatter Software Project
25  * (http://protomatter.sourceforge.net/)."
26  * Alternately, this acknowledgment may appear in the software itself,
27  * if and wherever such third-party acknowledgments normally appear.
28  *
29  * 4. The names "Protomatter" and "Protomatter Software Project" must
30  * not be used to endorse or promote products derived from this
31  * software without prior written permission. For written
32  * permission, please contact support@protomatter.com.
33  *
34  * 5. Products derived from this software may not be called "Protomatter",
35  * nor may "Protomatter" appear in their name, without prior written
36  * permission of the Protomatter Software Project
37  * (support@protomatter.com).
38  *
39  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
40  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
41  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
42  * DISCLAIMED. IN NO EVENT SHALL THE PROTOMATTER SOFTWARE PROJECT OR
43  * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
45  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
46  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
47  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
48  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
49  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
50  * SUCH DAMAGE. }}}
51  */

52
53 import java.io.PrintWriter JavaDoc;
54 import java.util.*;
55 import java.text.*;
56 import java.net.*;
57 import java.io.*;
58 import java.lang.reflect.*;
59
60 import org.jdom.*;
61
62 import com.protomatter.xml.*;
63 import com.protomatter.syslog.*;
64
65 /**
66  * XML configuration helper for <tt>HTMLSyslogTextFormatter</tt>.
67  */

68 public class HTMLSyslogTextFormatter_Helper
69 extends SimpleSyslogTextFormatter_Helper
70 {
71   /**
72    * Configure this text formatter given the XML element.
73    * The <tt>&lt;Format&gt;</tt> element should look like this:<P>
74    *
75    * <TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0 WIDTH="90%">
76    * <TR><TD>
77    * <PRE><B>
78    *
79    * &lt;Format class="com.protomatter.syslog.HTMLSyslogTextFormatter" &gt;
80    *
81    * <font color="#888888">&lt;!--
82    * Config params from {@link SimpleSyslogTextFormatter_Helper#configure(Object,Element) SimpleSyslogTextFormatter_Helper}
83    * can get inserted here.
84    * --&gt;</font>
85    *
86    * &lt;stylesheet&gt;<i>StyleSheetName</i>&lt;/stylesheet&gt;
87    *
88    * &lt;/Format&gt;
89    * </B></PRE>
90    * </TD></TR></TABLE><P>
91    *
92    * <TABLE BORDER=1 CELLPADDING=2 CELLSPACING=0 WIDTH="90%">
93    * <TR CLASS="TableHeadingColor">
94    * <TD COLSPAN=3><B>Element</B></TD>
95    * </TR>
96    * <TR CLASS="TableHeadingColor">
97    * <TD><B>name</B></TD>
98    * <TD><B>value</B></TD>
99    * <TD><B>required</B></TD>
100    * </TR>
101    *
102    * <TR CLASS="TableRowColor">
103    * <TD VALIGN=TOP><TT>stylesheet</TT></TD>
104    * <TD VALIGN=TOP>The name of the stylesheet to use.
105    * </TD>
106    * <TD VALIGN=TOP>no (default is "<tt>syslog-stylesheet.css</tt>")</TD>
107    * </TR>
108    *
109    * </TABLE><P>
110    */

111   public void configure(Object JavaDoc o, Element e)
112   throws SyslogInitException
113   {
114     super.configure(o, e);
115     HTMLSyslogTextFormatter format = (HTMLSyslogTextFormatter)o;
116
117     String JavaDoc tmp = e.getChildTextTrim("stylesheet", e.getNamespace());
118     if (tmp != null)
119       format.setStyleSheet(tmp);
120   }
121
122   public Element getConfiguration(Object JavaDoc o, Element element)
123   {
124     Element e = super.getConfiguration(o, element);
125     HTMLSyslogTextFormatter format = (HTMLSyslogTextFormatter)o;
126
127     Element ss = new Element("stylesheet");
128     ss.setText(format.getStyleSheet());
129     e.getChildren().add(ss);
130
131     return element;
132   }
133 }
134
Popular Tags