01: // AbstractToken.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: import de.anomic.data.wiki.wikiParserException;
51:
52: public abstract class AbstractToken implements Token {
53:
54: protected String text = null;
55: protected String markup = null;
56: protected boolean parsed = false;
57:
58: protected abstract void parse() throws wikiParserException;
59:
60: public String getMarkup() throws wikiParserException {
61: if (this .text == null)
62: throw new IllegalArgumentException();
63: if (!this .parsed)
64: parse();
65: return this .markup;
66: }
67:
68: public String getText() {
69: return this .text;
70: }
71:
72: public String toString() {
73: try {
74: return getMarkup();
75: } catch (wikiParserException e) {
76: return null;
77: }
78: }
79: }
|