Package: libjpf-java / 1.5.1+dfsg-2

jxp_161.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
Author: tony mancill <tmancill@debian.org>
Description: make jpf work with newer jxp

--- a/source-tools/org/java/plugin/tools/docgen/ClassPathPageSource.java
+++ /dev/null
@@ -1,85 +0,0 @@
-package org.java.plugin.tools.docgen;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-
-import org.onemind.commons.java.util.FileUtils;
-import org.onemind.jxp.CachedJxpPage;
-import org.onemind.jxp.CachingPageSource;
-import org.onemind.jxp.JxpPage;
-import org.onemind.jxp.JxpPageNotFoundException;
-import org.onemind.jxp.JxpPageParseException;
-import org.onemind.jxp.parser.AstJxpDocument;
-import org.onemind.jxp.parser.JxpParser;
-import org.onemind.jxp.parser.ParseException;
-
-/**
- * JXP page source configured to load templates from the classpath.
- * @version $Id$
- */
-final class ClassPathPageSource extends CachingPageSource {
-    private final String base;
-    private final ClassLoader cl;
-    private final String encoding;
-
-    ClassPathPageSource(final String aBase, final String anEncoding) {
-        super();
-        base = aBase;
-        encoding = anEncoding;
-        cl = getClass().getClassLoader();
-    }
-
-    /**
-     * @see org.onemind.jxp.CachingPageSource#loadJxpPage(java.lang.String)
-     */
-    @Override
-    protected CachedJxpPage loadJxpPage(final String id)
-            throws JxpPageNotFoundException {
-        if (!hasJxpPage(id)) {
-            throw new JxpPageNotFoundException("page " + id + " not found"); //$NON-NLS-1$ //$NON-NLS-2$
-        }
-        return new CachedJxpPage(this, id);
-    }
-
-    /**
-     * @see org.onemind.jxp.CachingPageSource#parseJxpDocument(
-     *      org.onemind.jxp.JxpPage)
-     */
-    @Override
-    protected AstJxpDocument parseJxpDocument(final JxpPage page)
-            throws JxpPageParseException {
-        try {
-            JxpParser parser;
-            if (encoding == null) {
-                parser = new JxpParser(cl.getResourceAsStream(
-                        getStreamName(page.getName())));
-            } else {
-                parser = new JxpParser(new InputStreamReader(
-                        cl.getResourceAsStream(getStreamName(page.getName())),
-                        encoding));
-            }
-            return parser.JxpDocument();
-        } catch (IOException ioe) {
-            throw new JxpPageParseException("problem parsing page " //$NON-NLS-1$
-                    + page.getName() + ": " + ioe.getMessage(), ioe); //$NON-NLS-1$
-        } catch (ParseException pe) {
-            throw new JxpPageParseException("problem parsing page " //$NON-NLS-1$
-                    + page.getName() + ": " + pe.getMessage(), pe); //$NON-NLS-1$
-        }
-    }
-
-    /**
-     * @see org.onemind.jxp.JxpPageSource#hasJxpPage(java.lang.String)
-     */
-    @Override
-    public boolean hasJxpPage(final String id) {
-        if (isJxpPageCached(id)) {
-            return true;
-        }
-        return cl.getResource(getStreamName(id)) != null;
-    }
-    
-    private String getStreamName(final String pageName) {
-        return FileUtils.concatFilePath(base, pageName);
-    }
-}
--- a/source-tools/org/java/plugin/tools/docgen/DocGenerator.java
+++ b/source-tools/org/java/plugin/tools/docgen/DocGenerator.java
@@ -45,8 +45,11 @@
 import org.java.plugin.registry.PluginRegistry;
 import org.java.plugin.util.IoUtil;
 import org.onemind.jxp.FilePageSource;
-import org.onemind.jxp.JxpProcessingContext;
+import org.onemind.jxp.CachingPageSource;
+import org.onemind.jxp.JxpPageSource;
 import org.onemind.jxp.JxpProcessor;
+import org.onemind.jxp.JxpContext;
+import org.onemind.jxp.ResourceStreamPageSource;
 
 /**
  * Tool class to generate documentation for plug-ins using <a
@@ -128,7 +131,7 @@
             final PathResolver aPathResolver, final String templatesPath,
             final String templatesEncoding) throws Exception {
         this(aRegistry, aPathResolver, new JxpProcessor(
-                new ClassPathPageSource(templatesPath, templatesEncoding)));
+        		new JxpContext(new FilePageSource(templatesPath, templatesEncoding))));
     }
 
     /**
@@ -152,8 +155,8 @@
             final String templatesEncoding) throws Exception {
         // TODO: use character encoding when that will be possible in JXP
         // library
-        this(aRegistry, aPathResolver, new JxpProcessor(new FilePageSource(
-                templatesFolder.getCanonicalPath())));
+        this(aRegistry, aPathResolver, new JxpProcessor(
+        		new JxpContext(new FilePageSource(templatesFolder.getCanonicalPath()))));
     }
 
     private DocGenerator(final PluginRegistry aRegistry,
@@ -217,7 +220,7 @@
         Writer out = new OutputStreamWriter(new BufferedOutputStream(
                 new FileOutputStream(outFile, false)), outputEncoding);
         try {
-            processor.process(template, new JxpProcessingContext(out, ctx));
+            processor.process(template, out);
         } finally {
             out.close();
         }
@@ -237,11 +240,11 @@
         Writer out = new OutputStreamWriter(new BufferedOutputStream(
                 new FileOutputStream(outFile, false)), outputEncoding);
         try {
-            JxpProcessor proc = new JxpProcessor(new FilePageSource(tmpFile
-                    .getParentFile().getCanonicalPath()));
+            JxpProcessor proc = new JxpProcessor(
+            		new JxpContext(new FilePageSource(tmpFile.getParentFile().getCanonicalPath())));
             // TODO: use character encoding when that will be possible in JXP
             // library (UTF-8 in this case)
-            proc.process(tmpFile.getName(), new JxpProcessingContext(out, ctx));
+            proc.process(tmpFile.getName(), out);
         } finally {
             tmpFile.delete();
             out.close();