Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docgen/parameters.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"title" : "Venus (Fugerit Document Generation Framework)",
"name": "Venus",
"version" : "0.8.3",
"date" : "24/01/2023",
"version" : "0.8.4",
"date" : "27/01/2023",
"organization" : {
"name" : "Fugerit Org",
"url" : "https://www.fugerit.org"
Expand Down
8 changes: 6 additions & 2 deletions docgen/release-notes.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
0.8.3 (2023-01-24)
0.8.4 (2023-01-27)
------------------
+ [fj-doc-mod-fop - need to create FopConfigClassLoaderWrapper with default ResourceResolver]([0.5.2](https://github.com/fugerit-org/fj-doc/issues/15))
+ [fj-doc-base - Enable charset selection for DocTypeHandlerXML](https://github.com/fugerit-org/fj-doc/issues/17)

0.8.3 (2023-01-24)
------------------
+ [fj-doc-mod-fop - need to create FopConfigClassLoaderWrapper with default ResourceResolver](https://github.com/fugerit-org/fj-doc/issues/15)

0.8.2 (2023-01-22)
------------------
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
</parent>

<name>fj-doc-base-json</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base-yaml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
</parent>

<name>fj-doc-base-yaml</name>
Expand Down
2 changes: 1 addition & 1 deletion fj-doc-base/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.fugerit.java</groupId>
<artifactId>fj-doc</artifactId>
<version>0.8.3</version>
<version>0.8.4</version>
</parent>

<name>fj-doc-base</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package org.fugerit.java.doc.base.config;

import java.nio.charset.Charset;

import org.fugerit.java.core.util.ObjectUtils;

public abstract class DocCharsetProvider {

public abstract Charset resolveCharset( Charset charset );

public static final DocCharsetProvider DEFAULT = new DocCharsetProvider() {
@Override
public Charset resolveCharset(Charset charset) {
return ObjectUtils.objectWithDefault( charset , Charset.defaultCharset() );
}
};

private static DocCharsetProvider defaultProvider = DEFAULT;

public static DocCharsetProvider getDefaultProvider() {
return defaultProvider;
}

public static void setDefaultProvider(DocCharsetProvider defaultProvider) {
DocCharsetProvider.defaultProvider = defaultProvider;
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.fugerit.java.doc.base.config;

import java.nio.charset.Charset;

import org.fugerit.java.core.util.collection.KeyString;

public interface DocTypeHandler extends KeyString {
Expand All @@ -10,6 +12,8 @@ public interface DocTypeHandler extends KeyString {

String getMime();

Charset getCharset();

void handle( DocInput docInput, DocOutput docOutput ) throws Exception;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.fugerit.java.doc.base.config;

import org.fugerit.java.core.cfg.ConfigException;
import org.w3c.dom.Element;

public class DocTypeHandlerDecorator extends DocTypeHandlerDefault {

private static final long serialVersionUID = 5531355008187717238L;

private DocTypeHandler handler;

public DocTypeHandlerDecorator( DocTypeHandler handler ) {
super( handler.getType(), handler.getModule(), handler.getMime(), handler.getCharset() );
this.handler = handler;
}

public DocTypeHandler unwrap() {
return handler;
}

@Override
public void handle(DocInput docInput, DocOutput docOutput) throws Exception {
this.handler.handle(docInput, docOutput);
}

@Override
public void configure(Element tag) throws ConfigException {
if ( this.handler instanceof DocTypeHandlerDefault ) {
((DocTypeHandlerDefault)this.handler).configure(tag);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.fugerit.java.doc.base.config;

import java.io.Serializable;
import java.nio.charset.Charset;

import org.fugerit.java.core.cfg.ConfigException;
import org.fugerit.java.core.cfg.helpers.XMLConfigurableObject;
import org.fugerit.java.core.lang.helpers.StringUtils;
import org.fugerit.java.doc.base.helper.DefaultMimeHelper;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;

public class DocTypeHandlerDefault extends XMLConfigurableObject implements DocTypeHandler, Serializable {

Expand All @@ -14,12 +17,18 @@ public class DocTypeHandlerDefault extends XMLConfigurableObject implements DocT
*/
private static final long serialVersionUID = -5024985828785381015L;

public static final String TAG_NAME_CONFIG = "config";

public static final String ATT_NAME_CHARSET = "charset";

private String type;

private String module;

private String mime;

private Charset charset;

@Override
public String getMime() {
String res = this.mime;
Expand All @@ -44,16 +53,26 @@ public String getModule() {
return module;
}

@Override
public Charset getCharset() {
return charset;
}

@Override
public void handle(DocInput docInput, DocOutput docOutput) throws Exception {

}

public DocTypeHandlerDefault(String type, String module, String mime) {
public DocTypeHandlerDefault(String type, String module, String mime, Charset charset) {
super();
this.type = type;
this.module = module;
this.mime = mime;
this.charset = DocCharsetProvider.getDefaultProvider().resolveCharset(charset);
}

public DocTypeHandlerDefault(String type, String module, String mime) {
this( type, module, mime, null );
}

public DocTypeHandlerDefault(String type, String module ) {
Expand All @@ -64,8 +83,21 @@ public static final String createKey( String type, String mod ) {
return type+"-"+mod;
}

protected void handleConfigTag( Element config ) throws ConfigException {

}

@Override
public void configure(Element tag) throws ConfigException {
NodeList nl = tag.getElementsByTagName( TAG_NAME_CONFIG );
if ( nl.getLength() > 0 ) {
Element config = (Element)nl.item( 0 );
String charsetAtt = config.getAttribute( ATT_NAME_CHARSET );
if ( StringUtils.isNotEmpty( charsetAtt ) ) {
this.charset = Charset.forName( charsetAtt );
}
this.handleConfigTag(config);
}
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package org.fugerit.java.doc.base.config;

import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.fugerit.java.core.io.StreamIO;

Expand All @@ -13,17 +15,23 @@ public class DocTypeHandlerXML extends DocTypeHandlerDefault {

public static final DocTypeHandler HANDLER = new DocTypeHandlerXML();

public static final DocTypeHandler HANDLER_UTF8 = new DocTypeHandlerXML( StandardCharsets.UTF_8 );

public static final String TYPE = DocConfig.TYPE_XML;

public static final String MODULE = "doc";

public DocTypeHandlerXML( Charset charset ) {
super( TYPE, MODULE, null, charset );
}

public DocTypeHandlerXML() {
super( TYPE, MODULE );
}

@Override
public void handle(DocInput docInput, DocOutput docOutput) throws Exception {
StreamIO.pipeCharCloseBoth( docInput.getReader() , new OutputStreamWriter( docOutput.getOs() ) );
StreamIO.pipeCharCloseBoth( docInput.getReader() , new OutputStreamWriter( docOutput.getOs(), this.getCharset() ) );
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.fugerit.java.doc.base.config;

public class DocTypeHandlerXMLUTF8 extends DocTypeHandlerDecorator {

private static final long serialVersionUID = -8512962187951518109L;

public static final DocTypeHandler HANDLER = new DocTypeHandlerXMLUTF8();

public DocTypeHandlerXMLUTF8() {
super( DocTypeHandlerXML.HANDLER_UTF8 );
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.fugerit.java.doc.base.typehandler.markdown;

import java.nio.charset.Charset;

import org.fugerit.java.doc.base.config.DocConfig;
import org.fugerit.java.doc.base.config.DocTypeHandlerDefault;

Expand All @@ -11,11 +13,19 @@ public abstract class AbstractCustomMarkdownTypeHandler extends DocTypeHandlerDe

public static final String MIME = "text/x-markdown";

public AbstractCustomMarkdownTypeHandler( boolean printComments ) {
super(TYPE, MODULE, MIME);
public AbstractCustomMarkdownTypeHandler( Charset charset, boolean printComments ) {
super(TYPE, MODULE, MIME, charset);
this.printComments = printComments;
}

public AbstractCustomMarkdownTypeHandler( Charset charset ) {
this( charset, MarkdownBasicDocFacade.DEFAULT_PRINT_COMMENTS );
}

public AbstractCustomMarkdownTypeHandler( boolean printComments ) {
this( null, printComments );
}

public AbstractCustomMarkdownTypeHandler() {
this( MarkdownBasicDocFacade.DEFAULT_PRINT_COMMENTS );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.fugerit.java.doc.base.config.DocInput;
import org.fugerit.java.doc.base.config.DocOutput;
Expand All @@ -24,6 +26,10 @@ public class SimpleMarkdownBasicTypeHandler extends AbstractCustomMarkdownTypeHa

public static final DocTypeHandler HANDLER_NOCOMMENTS = new SimpleMarkdownBasicTypeHandler( false );

public static final DocTypeHandler HANDLER_UTF8 = new SimpleMarkdownBasicTypeHandler( StandardCharsets.UTF_8 );

public static final DocTypeHandler HANDLER_NOCOMMENTS_UTF8 = new SimpleMarkdownBasicTypeHandler( StandardCharsets.UTF_8, false );

/**
*
*/
Expand All @@ -35,15 +41,21 @@ public SimpleMarkdownBasicTypeHandler() {
super();
}



public SimpleMarkdownBasicTypeHandler(boolean printComments) {
super(printComments);
}

public SimpleMarkdownBasicTypeHandler(Charset charset, boolean printComments) {
super(charset, printComments);
}

public SimpleMarkdownBasicTypeHandler(Charset charset) {
super(charset);
}

@Override
public void handle(DocInput docInput, DocOutput docOutput) throws Exception {
PrintWriter writer = new PrintWriter( new OutputStreamWriter( docOutput.getOs() ) );
PrintWriter writer = new PrintWriter( new OutputStreamWriter( docOutput.getOs(), this.getCharset() ) );
DocBase docBase = docInput.getDoc();
/*
* The key for building a DocTypeHandler is to correctly renders
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.fugerit.java.doc.base.typehandler.markdown;

import org.fugerit.java.doc.base.config.DocTypeHandler;
import org.fugerit.java.doc.base.config.DocTypeHandlerDecorator;

public class SimpleMarkdownBasicTypeHandlerUTF8 extends DocTypeHandlerDecorator {

private static final long serialVersionUID = 2821034278291920037L;

public static final DocTypeHandler HANDLER = new SimpleMarkdownBasicTypeHandlerUTF8();

public SimpleMarkdownBasicTypeHandlerUTF8() {
super( SimpleMarkdownBasicTypeHandler.HANDLER_UTF8 );
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;

import org.fugerit.java.doc.base.config.DocInput;
import org.fugerit.java.doc.base.config.DocOutput;
Expand All @@ -24,6 +26,10 @@ public class SimpleMarkdownExtTypeHandler extends AbstractCustomMarkdownTypeHand

public static final DocTypeHandler HANDLER_NOCOMMENTS = new SimpleMarkdownExtTypeHandler( false );

public static final DocTypeHandler HANDLER_UTF8 = new SimpleMarkdownExtTypeHandler( StandardCharsets.UTF_8 );

public static final DocTypeHandler HANDLER_NOCOMMENTS_UTF8 = new SimpleMarkdownExtTypeHandler( StandardCharsets.UTF_8, false );

/**
*
*/
Expand All @@ -35,12 +41,19 @@ public SimpleMarkdownExtTypeHandler() {

public SimpleMarkdownExtTypeHandler(boolean printComments) {
super(printComments);
// TODO Auto-generated constructor stub
}

public SimpleMarkdownExtTypeHandler(Charset charset, boolean printComments) {
super(charset, printComments);
}

public SimpleMarkdownExtTypeHandler(Charset charset) {
super(charset);
}

@Override
public void handle(DocInput docInput, DocOutput docOutput) throws Exception {
PrintWriter writer = new PrintWriter( new OutputStreamWriter( docOutput.getOs() ) );
PrintWriter writer = new PrintWriter( new OutputStreamWriter( docOutput.getOs(), this.getCharset() ) );
DocBase docBase = docInput.getDoc();
/*
* The key for building a DocTypeHandler is to correctly renders
Expand Down
Loading