Skip to content

Commit

Permalink
[Fix #286] Add CharacterHandler and ModeHandler and register them in …
Browse files Browse the repository at this point in the history
…HandlerRegistry
  • Loading branch information
kostobog committed Dec 15, 2024
1 parent d53c74c commit 313ec43
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package cz.cvut.spipes.modules.handlers;

import cz.cvut.spipes.engine.ExecutionContext;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;

public class CharacterHandler extends BaseRDFNodeHandler<Character> {

public CharacterHandler(Resource resource, ExecutionContext executionContext, Setter<? super Character> setter) {
super(resource, executionContext, setter);
}

@Override
Character getRDFNodeValue(RDFNode node) throws Exception {
return node.asLiteral().getChar();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ private void initHandlers() {
registerHandler(boolean.class, BooleanHandler.class);
registerHandler(Integer.class, IntegerHandler.class);
registerHandler(int.class, IntegerHandler.class);
registerHandler(char.class, CharacterHandler.class);
registerHandler(Character.class, CharacterHandler.class);
registerHandler(String.class, StringHandler.class);
registerHandler(RDFNode.class, RDFNodeHandler.class);
registerHandler(Select.class, SelectHandler.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package cz.cvut.spipes.modules;

import cz.cvut.spipes.modules.handlers.HandlerRegistry;
import cz.cvut.spipes.modules.handlers.ModeHandler;

public class ModuleRegistration {

public static void register(){
HandlerRegistry.getInstance().registerHandler(Mode.class, ModeHandler.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"The table is constructed from column and row resources defined in TableSchema and saves it as a new CSV file.\n" +
"</p>")
public class RDF2CSVModule extends AnnotatedAbstractModule {

static {ModuleRegistration.register();}
public static final String TYPE_URI = KBSS_MODULE.uri + "RDF2CSV";
public static final String TYPE_PREFIX = TYPE_URI + "/";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
*/
@SPipesModule(label = "Tabular module", comment = "Module for converting tabular data (e.g. CSV or TSV) to RDF")
public class TabularModule extends AnnotatedAbstractModule {

static {ModuleRegistration.register();}
public static final String TYPE_URI = KBSS_MODULE.uri + "tabular";
public static final String PARAM_URL_PREFIX = TYPE_URI + "/";
private static final Logger LOG = LoggerFactory.getLogger(TabularModule.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package cz.cvut.spipes.modules.handlers;
import cz.cvut.spipes.engine.ExecutionContext;
import cz.cvut.spipes.modules.Mode;
import org.apache.jena.rdf.model.RDFNode;
import org.apache.jena.rdf.model.Resource;

public class ModeHandler extends BaseRDFNodeHandler<Mode> {

public ModeHandler(Resource resource, ExecutionContext executionContext, Setter<? super Mode> setter) {
super(resource, executionContext, setter);

}

@Override
Mode getRDFNodeValue(RDFNode node) throws Exception {
return Mode.fromResource(node.asResource());
}
}

0 comments on commit 313ec43

Please sign in to comment.