// Path: core/main/src/com/complexible/common/openrdf/util/ModelBuildingRDFHandler.java
// public final class ModelBuildingRDFHandler extends AbstractRDFHandler {
// 
// 	/**
// 	 * The graph to collect statements in
// 	 */
// 	private final Model mGraph;
// 
// 	/**
// 	 * Create a new GraphBuildingRDFHandler
// 	 */
// 	public ModelBuildingRDFHandler() {
// 		this(Models2.newModel());
// 	}
// 
// 	/**
// 	 * Create a new GraphBuildingRDFHandler that will insert statements into the supplied Graph
// 	 * @param theGraph the graph to insert into
// 	 */
// 	public ModelBuildingRDFHandler(final Model theGraph) {
// 		mGraph = theGraph;
// 	}
// 
// 	/**
// 	 * {@inheritDoc}
// 	 */
// 	@Override
// 	public void handleStatement(final Statement theStatement) throws RDFHandlerException {
// 		mGraph.add(theStatement);
// 	}
// 
// 	/**
// 	 * Return the graph built from events fired to this handler
// 	 * @return the graph
// 	 */
// 	public Model getModel() {
// 		return mGraph;
// 	}
// 
// 	/**
// 	 * Clear the underlying graph of all collected statements
// 	 */
// 	public void clear() {
// 		mGraph.clear();
// 	}
// }
// 
// Path: core/main/src/com/complexible/common/openrdf/util/RDFByteSource.java
// public abstract class RDFByteSource extends ByteSource {
// 
// 	/**
// 	 * Return the RDF format used by the source
// 	 * @return  the format
// 	 */
// 	public abstract RDFFormat getFormat();
// 
// 	/**
// 	 * Return the base uri that should be used when parsing this source
// 	 * @return the base
// 	 */
// 	public String getBaseURI() {
// 		return "http://openrdf.clarkparsia.com";
// 	}
// 
// 	public static RDFByteSource create(final ByteSource theSource, final RDFFormat theFormat) {
// 		return new RDFByteSource() {
// 			@Override
// 			public RDFFormat getFormat() {
// 				return theFormat;
// 			}
// 
// 			@Override
// 			public InputStream openStream() throws IOException {
// 				return theSource.openStream();
// 			}
// 		};
// 	}
// }


import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
import com.complexible.common.openrdf.util.ModelBuildingRDFHandler;
import com.complexible.common.openrdf.util.RDFByteSource;
import com.google.common.base.Charsets;
import org.openrdf.model.Model;
import org.openrdf.model.Statement;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFHandler;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.RDFParser;
import org.openrdf.rio.RDFWriter;
import org.openrdf.rio.Rio;
import org.openrdf.rio.helpers.BasicParserSettings;
	 * @param theFormat the format the data is in
	 * @param theBase the base url used for parsing
	 * @return the graph represented by the data from the stream
	 * @throws IOException if there is an error while reading
	 * @throws RDFParseException if there is an error while trying to parse the data as the specified format
	 */
	public static Model read(InputStream theInput, RDFFormat theFormat, final String theBase) throws IOException, RDFParseException {
		return read(new InputStreamReader(theInput, getCharset(theFormat).orElse(Charsets.UTF_8)), theFormat, theBase);
	}

	/**
	 * Read an RDF graph from the Reader using the specified format.  The reader is closed after parsing.
	 *
	 * @param theInput  the reader to read from
	 * @param theFormat the format the data is in
	 * @param theBase   the base url for parsing
	 *
	 * @return the graph represented by the data from the stream
	 *
	 * @throws IOException if there is an error while reading
	 * @throws RDFParseException if there is an error while trying to parse the data as the specified format
	 */
	public static Model read(final Reader theInput, final RDFFormat theFormat, final String theBase) throws IOException, RDFParseException {
		RDFParser aParser = Rio.createParser(theFormat);

		aParser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
		aParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false);
		aParser.getParserConfig().set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, false);
		aParser.getParserConfig().set(BasicParserSettings.PRESERVE_BNODE_IDS, true);

// Path: core/main/src/com/complexible/common/openrdf/util/ModelBuildingRDFHandler.java
// public final class ModelBuildingRDFHandler extends AbstractRDFHandler {
// 
// 	/**
// 	 * The graph to collect statements in
// 	 */
// 	private final Model mGraph;
// 
// 	/**
// 	 * Create a new GraphBuildingRDFHandler
// 	 */
// 	public ModelBuildingRDFHandler() {
// 		this(Models2.newModel());
// 	}
// 
// 	/**
// 	 * Create a new GraphBuildingRDFHandler that will insert statements into the supplied Graph
// 	 * @param theGraph the graph to insert into
// 	 */
// 	public ModelBuildingRDFHandler(final Model theGraph) {
// 		mGraph = theGraph;
// 	}
// 
// 	/**
// 	 * {@inheritDoc}
// 	 */
// 	@Override
// 	public void handleStatement(final Statement theStatement) throws RDFHandlerException {
// 		mGraph.add(theStatement);
// 	}
// 
// 	/**
// 	 * Return the graph built from events fired to this handler
// 	 * @return the graph
// 	 */
// 	public Model getModel() {
// 		return mGraph;
// 	}
// 
// 	/**
// 	 * Clear the underlying graph of all collected statements
// 	 */
// 	public void clear() {
// 		mGraph.clear();
// 	}
// }
// 
// Path: core/main/src/com/complexible/common/openrdf/util/RDFByteSource.java
// public abstract class RDFByteSource extends ByteSource {
// 
// 	/**
// 	 * Return the RDF format used by the source
// 	 * @return  the format
// 	 */
// 	public abstract RDFFormat getFormat();
// 
// 	/**
// 	 * Return the base uri that should be used when parsing this source
// 	 * @return the base
// 	 */
// 	public String getBaseURI() {
// 		return "http://openrdf.clarkparsia.com";
// 	}
// 
// 	public static RDFByteSource create(final ByteSource theSource, final RDFFormat theFormat) {
// 		return new RDFByteSource() {
// 			@Override
// 			public RDFFormat getFormat() {
// 				return theFormat;
// 			}
// 
// 			@Override
// 			public InputStream openStream() throws IOException {
// 				return theSource.openStream();
// 			}
// 		};
// 	}
// }


// Path: core/main/src/com/complexible/common/openrdf/model/ModelIO.java
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.StringWriter;
import java.io.Writer;
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Optional;
import com.complexible.common.openrdf.util.ModelBuildingRDFHandler;
import com.complexible.common.openrdf.util.RDFByteSource;
import com.google.common.base.Charsets;
import org.openrdf.model.Model;
import org.openrdf.model.Statement;
import org.openrdf.rio.RDFFormat;
import org.openrdf.rio.RDFHandler;
import org.openrdf.rio.RDFHandlerException;
import org.openrdf.rio.RDFParseException;
import org.openrdf.rio.RDFParser;
import org.openrdf.rio.RDFWriter;
import org.openrdf.rio.Rio;
import org.openrdf.rio.helpers.BasicParserSettings;

	 * @param theFormat the format the data is in
	 * @param theBase the base url used for parsing
	 * @return the graph represented by the data from the stream
	 * @throws IOException if there is an error while reading
	 * @throws RDFParseException if there is an error while trying to parse the data as the specified format
	 */
	public static Model read(InputStream theInput, RDFFormat theFormat, final String theBase) throws IOException, RDFParseException {
		return read(new InputStreamReader(theInput, getCharset(theFormat).orElse(Charsets.UTF_8)), theFormat, theBase);
	}

	/**
	 * Read an RDF graph from the Reader using the specified format.  The reader is closed after parsing.
	 *
	 * @param theInput  the reader to read from
	 * @param theFormat the format the data is in
	 * @param theBase   the base url for parsing
	 *
	 * @return the graph represented by the data from the stream
	 *
	 * @throws IOException if there is an error while reading
	 * @throws RDFParseException if there is an error while trying to parse the data as the specified format
	 */
	public static Model read(final Reader theInput, final RDFFormat theFormat, final String theBase) throws IOException, RDFParseException {
		RDFParser aParser = Rio.createParser(theFormat);

		aParser.getParserConfig().set(BasicParserSettings.VERIFY_DATATYPE_VALUES, false);
		aParser.getParserConfig().set(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES, false);
		aParser.getParserConfig().set(BasicParserSettings.NORMALIZE_DATATYPE_VALUES, false);
		aParser.getParserConfig().set(BasicParserSettings.PRESERVE_BNODE_IDS, true);

		ModelBuildingRDFHandler aHandler = new ModelBuildingRDFHandler();