private SQLPPMapping load(Reader reader, SpecificationFactory specificationFactory,
                                     SQLPPMappingFactory ppMappingFactory, String fileName)
            throws MappingIOException, InvalidMappingExceptionWithIndicator, DuplicateMappingException {

        final Map<String, String> prefixes = new HashMap<>();
        final List<SQLPPTriplesMap> mappings = new ArrayList<>();
        final List<Indicator> invalidMappingIndicators = new ArrayList<>();

        List<TargetQueryParser> parsers = null;
		
		String line;

        try (LineNumberReader lineNumberReader = new LineNumberReader(reader)) {

            while ((line = lineNumberReader.readLine()) != null) {
                try {
                    if (isCommentLine(line) || line.isEmpty()) {
                        continue; // skip comment lines and blank lines
                    }
                    if (line.contains(PREFIX_DECLARATION_TAG)) {
                        prefixes.putAll(readPrefixDeclaration(lineNumberReader));

                    /*
                     * In case of late prefix declaration
                     */
                        if (parsers != null) {
                            parsers = createParsers(ImmutableMap.copyOf(prefixes));
                        }

                    } else if (line.contains(CLASS_DECLARATION_TAG)) {
                        // deprecated tag
                        throw new UnsupportedTagException(CLASS_DECLARATION_TAG);
                    } else if (line.contains(OBJECT_PROPERTY_DECLARATION_TAG)) {
                        // deprecated tag
                        throw new UnsupportedTagException(OBJECT_PROPERTY_DECLARATION_TAG);
                    } else if (line.contains(DATA_PROPERTY_DECLARATION_TAG)) {
                        // deprecated tag
                        throw new UnsupportedTagException(DATA_PROPERTY_DECLARATION_TAG);
                    } else if (line.contains(SOURCE_DECLARATION_TAG)) {
                        // This exception wil be rethrown
                        throw new RuntimeException("Source declaration is not supported anymore (since 3.0). " +
                                "Please give this information with the Ontop configuration.");
                    } else if (line.contains(MAPPING_DECLARATION_TAG)) {
                        if (parsers == null) {
                            parsers = createParsers(ImmutableMap.copyOf(prefixes));
                        }
                        mappings.addAll(readMappingDeclaration(lineNumberReader, parsers, invalidMappingIndicators));
                    } else {
                        throw new IOException("Unknown syntax: " + line);
                    }
                } catch (Exception e) {
                    throw new IOException(String.format("ERROR reading %s at line: %s", fileName,
                            lineNumberReader.getLineNumber()
                                    + " \nMESSAGE: " + e.getMessage()), e);
                }
            }
        } catch (IOException e) {
            throw new MappingIOException(e);
        }

        // Throw some validation exceptions
        if (!invalidMappingIndicators.isEmpty()) {
            throw new InvalidMappingExceptionWithIndicator(invalidMappingIndicators);
        }

        PrefixManager prefixManager = specificationFactory.createPrefixManager(ImmutableMap.copyOf(prefixes));
        ImmutableList<SQLPPTriplesMap> mappingAxioms = ImmutableList.copyOf(mappings);

        UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher.create(
                mappingAxioms.stream()
                        .flatMap(ax -> ax.getTargetAtoms().stream())
                        .flatMap(atom -> atom.getSubstitution().getImmutableMap().values().stream())
                        .filter(t -> t instanceof ImmutableFunctionalTerm)
                        .map(t -> (ImmutableFunctionalTerm) t),
                termFactory);

        MappingMetadata metadata = specificationFactory.createMetadata(prefixManager, uriTemplateMatcher);
        return ppMappingFactory.createSQLPreProcessedMapping(mappingAxioms, metadata);
	}
private SQLPPMapping load ( Reader reader , SpecificationFactory specificationFactory , SQLPPMappingFactory ppMappingFactory , String fileName ) throws MappingIOException , InvalidMappingExceptionWithIndicator , DuplicateMappingException { final Map < String , String > prefixes = new HashMap < > ( ) ; final List < SQLPPTriplesMap > mappings = new ArrayList < > ( ) ; final List < Indicator > invalidMappingIndicators = new ArrayList < > ( ) ; List < TargetQueryParser > parsers = null ; String line ; try ( LineNumberReader lineNumberReader = new LineNumberReader ( reader ) ) { while ( ( line = lineNumberReader . readLine ( ) ) != null ) { try { if ( isCommentLine ( line ) || line . isEmpty ( ) ) { continue ; } if ( line . contains ( PREFIX_DECLARATION_TAG ) ) { prefixes . putAll ( readPrefixDeclaration ( lineNumberReader ) ) ; if ( parsers != null ) { parsers = createParsers ( ImmutableMap . copyOf ( prefixes ) ) ; } } else if ( line . contains ( CLASS_DECLARATION_TAG ) ) { throw new UnsupportedTagException ( CLASS_DECLARATION_TAG ) ; } else if ( line . contains ( OBJECT_PROPERTY_DECLARATION_TAG ) ) { throw new UnsupportedTagException ( OBJECT_PROPERTY_DECLARATION_TAG ) ; } else if ( line . contains ( DATA_PROPERTY_DECLARATION_TAG ) ) { throw new UnsupportedTagException ( DATA_PROPERTY_DECLARATION_TAG ) ; } else if ( line . contains ( SOURCE_DECLARATION_TAG ) ) { throw new RuntimeException ( "Source declaration is not supported anymore (since 3.0). " + "Please give this information with the Ontop configuration." ) ; } else if ( line . contains ( MAPPING_DECLARATION_TAG ) ) { if ( parsers == null ) { parsers = createParsers ( ImmutableMap . copyOf ( prefixes ) ) ; } mappings . addAll ( readMappingDeclaration ( lineNumberReader , parsers , invalidMappingIndicators ) ) ; } else { throw new IOException ( "Unknown syntax: " + line ) ; } } catch ( Exception e ) { throw new IOException ( String . format ( "ERROR reading %s at line: %s" , fileName , lineNumberReader . getLineNumber ( ) + " \nMESSAGE: " + e . getMessage ( ) ) , e ) ; } } } catch ( IOException e ) { throw new MappingIOException ( e ) ; } if ( ! invalidMappingIndicators . isEmpty ( ) ) { throw new InvalidMappingExceptionWithIndicator ( invalidMappingIndicators ) ; } PrefixManager prefixManager = specificationFactory . createPrefixManager ( ImmutableMap . copyOf ( prefixes ) ) ; ImmutableList < SQLPPTriplesMap > mappingAxioms = ImmutableList . copyOf ( mappings ) ; UriTemplateMatcher uriTemplateMatcher = UriTemplateMatcher . create ( mappingAxioms . stream ( ) . flatMap ( ax -> ax . getTargetAtoms ( ) . stream ( ) ) . flatMap ( atom -> atom . getSubstitution ( ) . getImmutableMap ( ) . values ( ) . stream ( ) ) . filter ( t -> t instanceof ImmutableFunctionalTerm ) . map ( t -> ( ImmutableFunctionalTerm ) t ) , termFactory ) ; MappingMetadata metadata = specificationFactory . createMetadata ( prefixManager , uriTemplateMatcher ) ; return ppMappingFactory . createSQLPreProcessedMapping ( mappingAxioms , metadata ) ; }
File may be null.

TODO: refactor it. Way too complex.