01: /*
02: * Copyright 2001-2006 C:1 Financial Services GmbH
03: *
04: * This software is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License Version 2.1, as published by the Free Software Foundation.
07: *
08: * This software is distributed in the hope that it will be useful,
09: * but WITHOUT ANY WARRANTY; without even the implied warranty of
10: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11: * Lesser General Public License for more details.
12: *
13: * You should have received a copy of the GNU Lesser General Public
14: * License along with this library; if not, write to the Free Software
15: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA
16: */
17:
18: package de.finix.contelligent.client.base;
19:
20: import java.io.IOException;
21: import java.io.Serializable;
22: import java.io.StringWriter;
23: import java.util.logging.Level;
24: import java.util.logging.Logger;
25:
26: import de.zeigermann.xml.XMLWriter;
27:
28: public final class Description implements Serializable {
29: private static Logger logger = Logger.getLogger(Description.class
30: .getName());
31:
32: private String language, title, text, helpURL;
33:
34: public Description(String language, String title, String text,
35: String helpURL) {
36: this .language = language;
37: this .title = title;
38: this .text = text;
39: this .helpURL = helpURL;
40: }
41:
42: public String getTitle() {
43: return title;
44: }
45:
46: public String getText() {
47: return text;
48: }
49:
50: public String getHelpURL() {
51: return helpURL;
52: }
53:
54: public void writeToXML(XMLWriter xmlWriter) throws IOException {
55: XMLWriter
56: .generateAndWriteElementWithCData(
57: xmlWriter,
58: "description",
59: new String[][] { { "lang", language },
60: { "title", title }, { "help", helpURL } },
61: text);
62: }
63:
64: public String toXML() {
65: StringWriter sw = new StringWriter();
66: try {
67: XMLWriter xmlWriter = new XMLWriter(sw);
68: writeToXML(xmlWriter);
69: xmlWriter.flush();
70: return sw.toString();
71: } catch (IOException ioe) {
72: logger.log(Level.SEVERE,
73: "Could not convert description to XML", ioe);
74: return null;
75: }
76: }
77: }
|