Package io.ultreia.java4all.util.sql
Class SqlScriptReader
- java.lang.Object
-
- io.ultreia.java4all.util.sql.SqlScriptReader
-
- All Implemented Interfaces:
Closeable,AutoCloseable,Iterable<String>
public class SqlScriptReader extends Object implements Iterable<String>, Closeable
Create an iterable on a SQL text content. The content is iterated on each SQL statement. For information the class handles semi-colon in quote.File example: INSERT INTO client (surname, age) VALUES ('John', 11); INSERT INTO client (surname, age) VALUES ('Jack', 12);
Then: SqlScriptReader source = new SqlScriptReader(stream); for (String sql : source) { // process sql variable } Created by tchemit on 10/05/2018.
- Since:
- 1.1.0
- Author:
- Tony Chemit - dev@tchemit.fr, jruchaud
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSqlScriptReader.Builderstatic classSqlScriptReader.ConcatenatedInputStreamstatic classSqlScriptReader.SqlFileReaderIteratorUse to create an iterator on the iterable.static classSqlScriptReader.SqlFileReaderIteratorWithoutCommentstatic classSqlScriptReader.StringStreamReader
-
Method Summary
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
of
public static SqlScriptReader of(String source)
-
of
public static SqlScriptReader of(String[] source)
-
of
public static SqlScriptReader of(Collection<String> source)
-
of
public static SqlScriptReader of(Stream<String> source)
-
of
public static SqlScriptReader of(byte[] source)
-
of
public static SqlScriptReader of(Path source)
-
of
public static SqlScriptReader of(URL source)
-
of
public static SqlScriptReader of(InputStream source)
-
builder
public static SqlScriptReader.Builder builder(String source)
-
builder
public static SqlScriptReader.Builder builder(String[] source)
-
builder
public static SqlScriptReader.Builder builder(Collection<String> source)
-
builder
public static SqlScriptReader.Builder builder(Stream<String> source)
-
builder
public static SqlScriptReader.Builder builder(InputStream content)
-
builder
public static SqlScriptReader.Builder builder(byte[] source)
-
builder
public static SqlScriptReader.Builder builder(Path source)
-
builder
public static SqlScriptReader.Builder builder(URL source)
-
builder
public static SqlScriptReader.Builder builder(SqlScriptReader location)
-
getStatementCount
public long getStatementCount()
-
isGzip
public boolean isGzip()
-
getSource
public SingletonSupplier<Reader> getSource()
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-