Class RLSCSVsParser
java.lang.Object
fr.inria.rules.integraal.io.csv.RLSCSVsParser
- All Implemented Interfaces:
Parser<Atom>, CloseableIterator<Atom>, Closeable, AutoCloseable
Parses an RLS CSV configuration file into a stream of atoms.
- Author:
- Florent Tornil
This class parses a list of CSV file into atoms.
Retrieves CSV files from a configuration file inspired from RLS syntax <a href="https://github.com/knowsys/rulewerk/wiki/Rule-syntax-grammar#source-declarations">...</a> Each line of the configuration file defines a CSV file to be parsed as well as the predicate it defines.
The
CSVParseris used for each file. It is assumed that all the CSV file have the same separator, prefix and header size.
-
Constructor Summary
ConstructorsConstructorDescriptionRLSCSVsParser(File file, char separator, String prefix, int headerSize, boolean encode) Creates a parser from an RLS configuration file and CSV options.RLSCSVsParser(String filePath) Creates a parser from an RLS configuration file path.RLSCSVsParser(String filePath, boolean encode) Creates a parser from an RLS configuration file path and encoding mode. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the iterator and releases its resources.getRLSFileLines(String configRLSFile) Reads every line from the supplied RLS configuration file.booleanhasNext()Indicates whether another element can be read from the iterator.next()Returns the next element from the iterator.parse()Parses the whole configuration and returns the materialized parser result.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Parser
streamParsedObjects
-
Constructor Details
-
RLSCSVsParser
Creates a parser from an RLS configuration file path.- Parameters:
filePath- to RLS configuration file to parseAll with default configuration
-
RLSCSVsParser
Creates a parser from an RLS configuration file path and encoding mode.- Parameters:
filePath- to RLS configuration file to parseAll with default configurationencode- a boolean true iff the CSV has to be encoded first
-
RLSCSVsParser
Creates a parser from an RLS configuration file and CSV options.- Parameters:
file- RLS configuration file to parseAllseparator- separator character of the CSV fileprefix- prefix of the predicate nameheaderSize- size of the header of the CSV fileencode- a boolean true iff the CSV has to be encoded first
-
-
Method Details
-
hasNext
public boolean hasNext()Description copied from interface:CloseableIteratorIndicates whether another element can be read from the iterator. -
next
Description copied from interface:CloseableIteratorReturns the next element from the iterator. -
close
public void close()Description copied from interface:CloseableIteratorCloses the iterator and releases its resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceCloseableIterator<Atom>
-
parse
Parses the whole configuration and returns the materialized parser result. -
getRLSFileLines
Reads every line from the supplied RLS configuration file.- Parameters:
configRLSFile- to parseAll- Returns:
- the lines in the configRLSFile
- Throws:
FileNotFoundException- exception
-