01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2001-2006 Janne Jalkanen (Janne.Jalkanen@iki.fi)
05:
06: This program is free software; you can redistribute it and/or modify
07: it under the terms of the GNU Lesser General Public License as published by
08: the Free Software Foundation; either version 2.1 of the License, or
09: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package com.ecyrd.jspwiki.parser;
21:
22: import java.lang.ref.WeakReference;
23:
24: import org.jdom.Document;
25:
26: import com.ecyrd.jspwiki.WikiContext;
27: import com.ecyrd.jspwiki.WikiPage;
28:
29: /**
30: * Stores the DOM tree of a rendered WikiPage. This class
31: * extends the org.jdom.Document to provide some extra metadata
32: * specific to JSPWiki.
33: * <p>
34: * The document is not stored as metadata in the WikiPage because
35: * otherwise it could not be cached separately.
36: *
37: * @author Janne Jalkanen
38: * @since 2.4
39: */
40: public class WikiDocument extends Document {
41: private static final long serialVersionUID = 0L;
42:
43: private WikiPage m_page;
44: private String m_wikiText;
45:
46: private WeakReference m_context;
47:
48: /**
49: * Creates a new WikiDocument for a specific page.
50: *
51: * @param page The page to which this document refers to.
52: */
53: public WikiDocument(WikiPage page) {
54: m_page = page;
55: }
56:
57: public void setPageData(String data) {
58: m_wikiText = data;
59: }
60:
61: public String getPageData() {
62: return m_wikiText;
63: }
64:
65: public WikiPage getPage() {
66: return m_page;
67: }
68:
69: public void setContext(WikiContext ctx) {
70: m_context = new WeakReference(ctx);
71: }
72:
73: /**
74: * Returns the wiki context for this document. This method
75: * may return <code>null</code> if the associated wiki session
76: * had previously been garbage-collected.
77: * @return the wiki context
78: */
79: public WikiContext getContext() {
80: return (WikiContext) m_context.get();
81: }
82: }
|