01: // DefinitionListToken.java
02: // ---------
03: // part of YaCy
04: // (C) by Michael Peter Christen; mc@anomic.de
05: // first published on http://www.anomic.de
06: // Frankfurt, Germany, 2007
07: // Created 22.02.2007
08: //
09: // This file is contributed by Franz Brausze
10: //
11: // $LastChangedDate: $
12: // $LastChangedRevision: $
13: // $LastChangedBy: $
14: //
15: // This program is free software; you can redistribute it and/or modify
16: // it under the terms of the GNU General Public License as published by
17: // the Free Software Foundation; either version 2 of the License, or
18: // (at your option) any later version.
19: //
20: // This program is distributed in the hope that it will be useful,
21: // but WITHOUT ANY WARRANTY; without even the implied warranty of
22: // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23: // GNU General Public License for more details.
24: //
25: // You should have received a copy of the GNU General Public License
26: // along with this program; if not, write to the Free Software
27: // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28: //
29: // Using this software in any meaning (reading, learning, copying, compiling,
30: // running) means that you agree that the Author(s) is (are) not responsible
31: // for cost, loss of data or any harm that may be caused directly or indirectly
32: // by usage of this softare or this documentation. The usage of this software
33: // is on your own risk. The installation and usage (starting/running) of this
34: // software may allow other people or application to access your computer and
35: // any attached devices and is highly dependent on the configuration of the
36: // software which must be done by the user of the software; the author(s) is
37: // (are) also not responsible for proper configuration and usage of the
38: // software, even if provoked by documentation provided together with
39: // the software.
40: //
41: // Any changes to this file according to the GPL as documented in the file
42: // gpl.txt aside this file in the shipment you received can be done to the
43: // lines that follows this copyright notice here, but changes must not be
44: // done inside the copyright notive above. A re-distribution must contain
45: // the intact and unchanged copyright notice.
46: // Contributions and changes to the program code must be marked as such.
47:
48: package de.anomic.data.wiki.tokens;
49:
50: public class DefinitionListToken extends ListToken {
51:
52: private static final String[] blockElements = { "dl", "dt", "dd" };
53:
54: public DefinitionListToken() {
55: super (';', null, null);
56: }
57:
58: protected StringBuffer parse(String[] t, int depth, StringBuffer sb) {
59: sb.append("<dl>\n");
60: while (super .aktline < t.length
61: && getGrade(t[super .aktline]) >= depth) {
62: for (int j = 0; j < depth + 1; j++)
63: sb.append("\t");
64: sb.append("<dt>");
65:
66: if (getGrade(t[super .aktline]) > depth) {
67: parse(t, depth + 1, sb);
68: } else {
69: sb.append(t[super .aktline].substring(depth + 1)
70: .replaceFirst(":", "</dt><dd>"));
71: }
72:
73: sb.append("</");
74: if (t[super .aktline].indexOf(':') == -1
75: || getGrade(t[super .aktline]) > depth)
76: sb.append("dt");
77: else
78: sb.append("dd");
79: sb.append(">\n");
80: super .aktline++;
81: }
82: for (int j = 0; j < depth; j++)
83: sb.append("\t");
84: sb.append("</dl>");
85: super .aktline--;
86: return sb;
87: }
88:
89: public String[] getBlockElementNames() {
90: return blockElements;
91: }
92: }
|