KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > help > internal > xhtml > XHTMLSupport


1 /***************************************************************************************************
2  * Copyright (c) 2004, 2006 IBM Corporation and others. All rights reserved. This program and the
3  * accompanying materials are made available under the terms of the Eclipse Public License v1.0
4  * which accompanies this distribution, and is available at
5  * http://www.eclipse.org/legal/epl-v10.html
6  *
7  * Contributors: IBM Corporation - initial API and implementation
8  **************************************************************************************************/

9
10 package org.eclipse.help.internal.xhtml;
11
12 import org.eclipse.help.HelpSystem;
13 import org.w3c.dom.Document JavaDoc;
14
15
16 /**
17  * Central class for XHTML support in help.
18  */

19 public class XHTMLSupport {
20
21     // singleton for performance.
22
private static UAContentFilterProcessor filterProcessor = new UAContentFilterProcessor();
23
24
25
26
27     private Document JavaDoc document = null;
28
29     private UAContentMergeProcessor mergeProcessor = null;
30
31
32     public XHTMLSupport(String JavaDoc pluginID, String JavaDoc file, Document JavaDoc document, String JavaDoc locale) {
33         this.document = document;
34         mergeProcessor = new UAContentMergeProcessor(pluginID, file, document, locale);
35
36     }
37
38     /**
39      * Processes the DOM, with filtering turned on.
40      *
41      * @return the resulting DOM
42      */

43     public Document JavaDoc processDOM() {
44         return processDOM(true);
45     }
46
47     /**
48      * Processes the DOM. Filtering will only be done if requested. Filtering
49      * may be skipped, for example, for indexing.
50      *
51      * @param filter whether or not to filter
52      * @return the resulting DOM
53      */

54     public Document JavaDoc processDOM(boolean filter) {
55
56         // filters do not apply to shared help systems
57
if (filter && !HelpSystem.isShared()) {
58             // resolve filters.
59
filterProcessor.applyFilters(document);
60         }
61
62         // resolve includes.
63
mergeProcessor.resolveIncludes();
64
65         // resolve anchors.
66
mergeProcessor.resolveContentExtensions();
67
68         return document;
69     }
70
71     public static UAContentFilterProcessor getFilterProcessor() {
72         return filterProcessor;
73     }
74
75     /**
76      * Used by the UI plugin to override base functionality and add more filtering capabilities.
77      */

78     public static void setFilterProcessor(UAContentFilterProcessor filterProcessor) {
79         XHTMLSupport.filterProcessor = filterProcessor;
80     }
81
82 }
83
Popular Tags