package com.obidea.semantika.mapping.parser.r2rml;

import java.io.IOException;
import java.io.Reader;

import org.openrdf.rio.turtle.TurtleParser;

import io.github.johardi.r2rmlparser.R2RmlHandler;

import com.obidea.semantika.io.IDocumentSource;
import com.obidea.semantika.knowledgebase.DefaultPrefixManager;
import com.obidea.semantika.knowledgebase.IPrefixManager;
import com.obidea.semantika.mapping.IMappingFactory.IMetaModel;
import com.obidea.semantika.mapping.IMappingSet;
import com.obidea.semantika.mapping.exception.MappingParserException;
import com.obidea.semantika.mapping.parser.AbstractMappingParser;
import com.obidea.semantika.mapping.parser.MappingParserConfiguration;

public class R2RmlParser extends AbstractMappingParser
{
   public R2RmlParser(IMetaModel metaModel)
   {
      super(metaModel);
   }

   @Override
   public IPrefixManager parse(IDocumentSource inputDocument, IMappingSet mappingSet,
         MappingParserConfiguration configuration) throws MappingParserException, IOException
   {
      R2RmlTriplesMapHandler triplesMapHandler = new R2RmlTriplesMapHandler(mappingSet, getMetaModel(), configuration);
      Reader reader = inputDocument.getReader();
      try {
         DefaultPrefixManager prefixManager = new DefaultPrefixManager();
         TurtleParser parser = new TurtleParser();
         R2RmlHandler parserHandler = new R2RmlHandler();
         parser.setRDFHandler(parserHandler);
         triplesMapHandler.handle(parserHandler.getTriplesMaps());
         prefixManager.setAll(parserHandler.getPrefixMapper());
         return prefixManager;
      }
      catch (Exception e) {
         throw new MappingParserException(e.getMessage());
      }
      finally {
         if (reader != null) {
            reader.close();
         }
      }
   }

   @Override
   public String getSyntax()
   {
      return "R2RML/Turtle"; //$NON-NLS-1$
   }
}

@@ -88,22 +88,27 @@
 java.io.
-Reader
+InputStream
 ;%0A%0Aimpor
@@ -1154,21 +1154,22 @@
     
-Reader reader
+InputStream is
  = i
@@ -1188,14 +1188,19 @@
 .get
-Reader
+InputStream
 ();%0A
@@ -1440,16 +1440,71 @@
 ndler);%0A
+         parser.parse(is, configuration.getBaseIri());%0A
         
@@ -1789,22 +1789,18 @@
     if (
-reader
+is
  != null
@@ -1819,14 +1819,10 @@
     
-reader
+is
 .clo

Change the input for the parser to be InputStream instead of Reader.