Author: reto
Date: Tue Feb 2 10:04:28 2010
New Revision: 905562
URL: http://svn.apache.org/viewvc?rev=905562&view=rev
Log:
splitting method in smaller ones
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.maven-pladoc-plugin/org.apache.clerezza.maven-pladoc-plugin.service/src/main/java/org/apache/clerezza/pladocplugin/service/GeneratorServiceImpl.java
Modified:
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.maven-pladoc-plugin/org.apache.clerezza.maven-pladoc-plugin.service/src/main/java/org/apache/clerezza/pladocplugin/service/GeneratorServiceImpl.java
URL:
http://svn.apache.org/viewvc/incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.maven-pladoc-plugin/org.apache.clerezza.maven-pladoc-plugin.service/src/main/java/org/apache/clerezza/pladocplugin/service/GeneratorServiceImpl.java?rev=905562&r1=905561&r2=905562&view=diff
==============================================================================
---
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.maven-pladoc-plugin/org.apache.clerezza.maven-pladoc-plugin.service/src/main/java/org/apache/clerezza/pladocplugin/service/GeneratorServiceImpl.java
(original)
+++
incubator/clerezza/trunk/org.apache.clerezza.parent/org.apache.clerezza.maven-pladoc-plugin/org.apache.clerezza.maven-pladoc-plugin.service/src/main/java/org/apache/clerezza/pladocplugin/service/GeneratorServiceImpl.java
Tue Feb 2 10:04:28 2010
@@ -20,7 +20,9 @@
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.FileOutputStream;
+import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.HashSet;
@@ -57,7 +59,6 @@
Parser parser;
@Reference
RendererFactory rendererFactory;
-
/** this is just to activate Triaxrs in order for MediaType to work
*
*/
@@ -86,30 +87,8 @@
} finally {
in.close();
}
- Set<NonLiteral> docRoots = new HashSet<NonLiteral>();
- Iterator<Triple> titledContentTypeTriples =
- documentationGraph.filter(null,
RDF.type, DISCOBITS.TitledContent);
- while (titledContentTypeTriples.hasNext()) {
- NonLiteral titleContent =
titledContentTypeTriples.next().getSubject();
- if (!documentationGraph.filter(null,
DISCOBITS.holds, titleContent).hasNext()) {
- docRoots.add(titleContent);
- System.out.println("doc root: " +
titleContent);
- }
- }
- for (NonLiteral docRoot : docRoots) {
- GraphNode docRootNode = new GraphNode(docRoot,
documentationGraph);
- Renderer renderer =
rendererFactory.createRenderer(docRootNode, null,
-
Collections.singletonList(MediaType.APPLICATION_XHTML_XML_TYPE));
- String fileName =
generateFileNameFromUri((UriRef)docRoot)+".html";
- File outFile = new File(outputDir, fileName);
- FileOutputStream out = new
FileOutputStream(outFile);
- try {
- System.out.println("writing "+outFile);
- renderer.render(docRootNode,
docRootNode, out);
- } finally {
- out.close();
- }
- }
+ process(documentationGraph, outputDir);
+
} catch (Exception ex) {
@@ -128,4 +107,36 @@
String lastSection =
uriString.substring(uriString.lastIndexOf('/'));
return lastSection;
}
+
+ private void process(Graph documentationGraph, File outputDir) throws
IOException {
+ Set<NonLiteral> docRoots = new HashSet<NonLiteral>();
+ Iterator<Triple> titledContentTypeTriples =
+ documentationGraph.filter(null, RDF.type,
DISCOBITS.TitledContent);
+ while (titledContentTypeTriples.hasNext()) {
+ NonLiteral titleContent =
titledContentTypeTriples.next().getSubject();
+ if (!documentationGraph.filter(null, DISCOBITS.holds,
titleContent).hasNext()) {
+ docRoots.add(titleContent);
+ System.out.println("doc root: " + titleContent);
+ }
+ }
+ for (NonLiteral docRoot : docRoots) {
+ String fileName = generateFileNameFromUri((UriRef)
docRoot) + ".html";
+ File outFile = new File(outputDir, fileName);
+ createFile(docRoot, documentationGraph, outFile);
+ }
+ }
+
+ private void createFile(NonLiteral docRoot, Graph documentationGraph,
+ File outFile) throws IOException {
+ GraphNode docRootNode = new GraphNode(docRoot,
documentationGraph);
+ Renderer renderer =
rendererFactory.createRenderer(docRootNode, null,
+
Collections.singletonList(MediaType.APPLICATION_XHTML_XML_TYPE));
+ FileOutputStream out = new FileOutputStream(outFile);
+ try {
+ System.out.println("writing " + outFile);
+ renderer.render(docRootNode, docRootNode, out);
+ } finally {
+ out.close();
+ }
+ }
}