├── .classpath
├── .github
├── dependabot.yml
└── workflows
│ └── maven-package.yml
├── LICENSE.txt
├── docs
├── CsvJdbcLogo.png
├── README.md
├── develop.md
├── doc.md
└── release.md
├── lib
└── dans-dbf-lib-1.0.0-beta-10.jar
├── pom.xml
└── src
├── doc
├── .cvsignore
├── CsvJdbcLogo.jpg
├── Non_Scrollable_Driver_Class_Diagram.gif
├── Scrollable_Driver_Class_Diagram.gif
├── readme.html
└── releasenotes.html
├── main
├── java
│ └── org
│ │ └── relique
│ │ ├── io
│ │ ├── CryptoFilter.java
│ │ ├── DataReader.java
│ │ ├── EncryptedFileInputStream.java
│ │ ├── EncryptedFileOutputStream.java
│ │ ├── FileSetInputStream.java
│ │ ├── ListDataReader.java
│ │ ├── TableReader.java
│ │ └── XORCipher.java
│ │ └── jdbc
│ │ ├── csv
│ │ ├── AggregateFunction.java
│ │ ├── AndExpression.java
│ │ ├── AsteriskExpression.java
│ │ ├── BetweenExpression.java
│ │ ├── BinaryOperation.java
│ │ ├── ClasspathTableReader.java
│ │ ├── ColumnName.java
│ │ ├── CsvConnection.java
│ │ ├── CsvDatabaseMetaData.java
│ │ ├── CsvDriver.java
│ │ ├── CsvMain.java
│ │ ├── CsvPreparedStatement.java
│ │ ├── CsvRawReader.java
│ │ ├── CsvReader.java
│ │ ├── CsvResources.java
│ │ ├── CsvResultSet.java
│ │ ├── CsvResultSetMetaData.java
│ │ ├── CsvSavepoint.java
│ │ ├── CsvStatement.java
│ │ ├── CurrentDateConstant.java
│ │ ├── CurrentTimeConstant.java
│ │ ├── ExistsExpression.java
│ │ ├── ExistsExpressionSubQueryRowMatcher.java
│ │ ├── Expression.java
│ │ ├── InExpression.java
│ │ ├── InExpressionSubQueryRowMatcher.java
│ │ ├── IsNullExpression.java
│ │ ├── JoinType.java
│ │ ├── LikeExpression.java
│ │ ├── LikePattern.java
│ │ ├── LogicalExpression.java
│ │ ├── MinimumMemoryMap.java
│ │ ├── MultipleSqlParser.java
│ │ ├── NotExpression.java
│ │ ├── NullConstant.java
│ │ ├── NumericConstant.java
│ │ ├── OrExpression.java
│ │ ├── OrderByEntry.java
│ │ ├── ParsedExpression.java
│ │ ├── ParsedStatement.java
│ │ ├── ParsedTable.java
│ │ ├── Placeholder.java
│ │ ├── PlaceholderFactory.java
│ │ ├── QueryEnvEntry.java
│ │ ├── RelopExpression.java
│ │ ├── SQLAbsFunction.java
│ │ ├── SQLArrayAggFunction.java
│ │ ├── SQLAvgFunction.java
│ │ ├── SQLCalendarFunction.java
│ │ ├── SQLCoalesceFunction.java
│ │ ├── SQLCountFunction.java
│ │ ├── SQLDayOfMonthFunction.java
│ │ ├── SQLHourOfDayFunction.java
│ │ ├── SQLLengthFunction.java
│ │ ├── SQLLineNumberFunction.java
│ │ ├── SQLLowerFunction.java
│ │ ├── SQLMaxFunction.java
│ │ ├── SQLMinFunction.java
│ │ ├── SQLMinuteFunction.java
│ │ ├── SQLMonthFunction.java
│ │ ├── SQLNullIfFunction.java
│ │ ├── SQLRandomFunction.java
│ │ ├── SQLReplaceFunction.java
│ │ ├── SQLRoundFunction.java
│ │ ├── SQLSecondFunction.java
│ │ ├── SQLStringAggFunction.java
│ │ ├── SQLSubstringFunction.java
│ │ ├── SQLSumFunction.java
│ │ ├── SQLToArrayFunction.java
│ │ ├── SQLToNumberFunction.java
│ │ ├── SQLTrimFunction.java
│ │ ├── SQLUpperFunction.java
│ │ ├── SQLUserFunction.java
│ │ ├── SQLVersionFunction.java
│ │ ├── SQLYearFunction.java
│ │ ├── SearchedCaseExpression.java
│ │ ├── SimpleCaseExpression.java
│ │ ├── SqlArray.java
│ │ ├── SqlParser.java
│ │ ├── StringConstant.java
│ │ ├── StringConverter.java
│ │ ├── SubQueryEqualsRowMatcher.java
│ │ ├── SubQueryExpression.java
│ │ ├── SubQueryRowMatcher.java
│ │ └── ZipFileTableReader.java
│ │ └── dbf
│ │ ├── DbfClassNotFoundException.java
│ │ └── DbfReader.java
├── javacc
│ └── org
│ │ └── relique
│ │ └── jdbc
│ │ └── csv
│ │ └── where.jj
└── resources
│ ├── META-INF
│ └── services
│ │ └── java.sql.Driver
│ └── org
│ └── relique
│ └── jdbc
│ └── csv
│ └── messages.properties
├── test
├── java
│ └── org
│ │ └── relique
│ │ └── jdbc
│ │ └── csv
│ │ ├── RunSuite.java
│ │ ├── TableReaderTester.java
│ │ ├── TestAggregateFunctions.java
│ │ ├── TestArrayFunctions.java
│ │ ├── TestClasspathResources.java
│ │ ├── TestCryptoFilter.java
│ │ ├── TestCsvDriver.java
│ │ ├── TestDbfDriver.java
│ │ ├── TestDoubleQuoting.java
│ │ ├── TestFileSetInputStream.java
│ │ ├── TestFixedWidthFiles.java
│ │ ├── TestGroupBy.java
│ │ ├── TestJoinedTables.java
│ │ ├── TestLimitOffset.java
│ │ ├── TestLineNumber.java
│ │ ├── TestOrderBy.java
│ │ ├── TestPrepareStatement.java
│ │ ├── TestRandomFunction.java
│ │ ├── TestScrollableDriver.java
│ │ ├── TestSqlParser.java
│ │ ├── TestStringConverter.java
│ │ ├── TestSubQuery.java
│ │ ├── TestTime.java
│ │ ├── TestToNumberFunction.java
│ │ ├── TestVersionFunction.java
│ │ └── TestZipFiles.java
└── resources
│ └── testdata
│ ├── encodings
│ ├── iso8859-1.txt
│ ├── utf-16.txt
│ └── utf-8.txt
│ └── olympic-medals
│ ├── medals2004.csv
│ └── medals2008.csv
└── testdata
├── C D.csv
├── Hutchenson_011020182.txt
├── Purchase.csv
├── arrays_sample.csv
├── bad_values.csv
├── badquoted.csv
├── banks.txt
├── bool.csv
├── calendar.csv
├── currency-exchange-rates-fixed.txt
├── d.dbf
├── defectiveheader.csv
├── doublequoted.csv
├── duplicate_headers.csv
├── embassies.txt
├── empty-1.txt
├── empty-2.txt
├── empty-3.txt
├── empty-glued.txt
├── encodings.zip
├── escape.csv
├── events.csv
├── evonix.csv
├── flights.txt
├── foodstuffs.csv
├── fox_samp.dbf
├── headerless-001-20081112.txt
├── headerless-002-20081112.txt
├── headerless-003-20081112.txt
├── headerless-004-20081112.txt
├── headerless-glued-leading.txt
├── hotel.dbf
├── jo.txt
├── nikesh.csv
├── nodata.txt
├── numbers_de.csv
├── numeric.csv
├── olympic-medals.zip
├── only_comments.txt
├── petr-333-444.csv
├── petr-555-666.csv
├── recording-2015-06-28.log
├── sample
├── sample.csv
├── sample.dbf
├── sample.txt
├── sample2.csv
├── sample3.csv
├── sample4.csv
├── sample5.csv
├── sample8.csv
├── scores.csv
├── scrambled.txt
├── scrambled_trailing.txt
├── single-char-cols-fixed.txt
├── singlerecord.csv
├── speedtest_decypher.csv
├── speedtest_decypher.txt
├── sunil_date_time.csv
├── test-001-20081112.txt
├── test-001-20081113.txt
├── test-001-20081114.txt
├── test-002-20081112.txt
├── test-002-20081113.txt
├── test-002-20081114.txt
├── test-003-20081112.txt
├── test-003-20081113.txt
├── test-003-20081114.txt
├── test-004-20081112.txt
├── test-004-20081113.txt
├── test-004-20081114.txt
├── test-glued-leading.txt
├── test-glued-trailing.txt
├── transactions.txt
├── twoheaders.txt
├── twojoinedtables01.txt
├── twojoinedtables01joined.txt
├── twojoinedtables02.txt
├── twojoinedtables02joined.txt
├── twojoinedtablesindex_1.txt
├── twojoinedtablesindex_2.txt
├── twojoinedtablesindex_3.txt
├── uses_quotes.txt
├── utf16le_01102018.txt
├── utf16le_04112020.txt
├── utf8_bom.csv
├── varlen1-20081112.txt
├── varlen1-20081113.txt
├── varlen2-20081112.txt
├── varlen2-20081114.txt
├── with_comments.txt
├── with_leading_trash.txt
├── witheol.txt
├── wrong_column_count.csv
├── xbase.dbf
├── xbase.dbt
├── yogesh.csv
└── yogesh_de.csv
/.classpath:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: maven
4 | directory: "/"
5 | schedule:
6 | interval: weekly
7 | - package-ecosystem: github-actions
8 | directory: "/"
9 | schedule:
10 | interval: weekly
11 |
12 |
--------------------------------------------------------------------------------
/.github/workflows/maven-package.yml:
--------------------------------------------------------------------------------
1 | name: Java CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | pull_request:
8 | branches:
9 | - master
10 | workflow_dispatch:
11 |
12 | jobs:
13 | build:
14 | runs-on: ubuntu-latest
15 |
16 | steps:
17 | - uses: actions/checkout@v4
18 | - name: Set up JDK 11
19 | uses: actions/setup-java@v4
20 | with:
21 | distribution: 'temurin'
22 | java-version: 11
23 | - name: Build with Maven
24 | run: mvn -B clean package
25 |
--------------------------------------------------------------------------------
/docs/CsvJdbcLogo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/docs/CsvJdbcLogo.png
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # 
2 |
3 | 
4 |
5 | A Java database driver for reading comma-separated-value files.
6 |
7 | ## Introduction
8 |
9 | CsvJdbc is a read-only JDBC driver that uses Comma Separated Value (CSV) files
10 | or DBF files as database tables. It is ideal for writing data import programs
11 | or analyzing log files.
12 |
13 | The driver enables a directory or a ZIP file containing CSV or DBF files to be
14 | accessed as though it were a database containing tables. However, as there is
15 | no real database management system behind the scenes, not all JDBC
16 | functionality is available.
17 |
18 | ## Usage
19 |
20 | The CsvJdbc driver is used just like any other JDBC driver,
21 | either in a database tool such as
22 | [DBeaver](https://dbeaver.io/) or
23 | [SQuirrel SQL Client](http://squirrel-sql.sourceforge.net/),
24 | or programmatically in your own Java program using the steps below:
25 |
26 | 1. download `csvjdbc.jar` and add it to the Java CLASSPATH.
27 | 1. use `DriverManager` to connect to the database (the directory or ZIP file)
28 | 1. create a statement object
29 | 1. use the statement object to execute an SQL SELECT query
30 | 1. the result of the query is a `ResultSet`
31 |
32 | The following example puts the above steps into practice.
33 |
34 | ```java
35 | import java.sql.*;
36 | import org.relique.jdbc.csv.CsvDriver;
37 |
38 | public class DemoDriver
39 | {
40 | public static void main(String[] args) throws Exception
41 | {
42 | // Create a connection to directory given as first command line
43 | // parameter. Driver properties are passed in URL format
44 | // (or alternatively in a java.utils.Properties object).
45 | //
46 | // A single connection is thread-safe for use by several threads.
47 | String url = "jdbc:relique:csv:" + args[0] + "?" +
48 | "separator=;" + "&" + "fileExtension=.txt";
49 | try (Connection conn = DriverManager.getConnection(url);
50 |
51 | // Create a Statement object to execute the query with.
52 | // A Statement is not thread-safe.
53 | Statement stmt = conn.createStatement();
54 |
55 | // Select the ID and NAME columns from sample.csv
56 | ResultSet results = stmt.executeQuery("SELECT ID,NAME FROM sample"))
57 | {
58 | // Dump out the results to a CSV file with the same format
59 | // using CsvJdbc helper function
60 | boolean append = true;
61 | CsvDriver.writeToCsv(results, System.out, append);
62 | }
63 | }
64 | }
65 | ```
66 |
67 | ## Documentation
68 |
69 | Full documentation for CsvJdbc is found [here](doc.md).
70 |
71 | ## Developing
72 |
73 | Read the instructions for [compiling](develop.md) CsvJdbc
74 | and for [releasing](release.md) CsvJdbc.
75 |
--------------------------------------------------------------------------------
/docs/develop.md:
--------------------------------------------------------------------------------
1 | ## Building From Source
2 |
3 | To checkout and build the latest source code from the
4 | [CsvJdbc git repository](https://github.com/simoc/csvjdbc.git),
5 | use the following commands ([git](http://git-scm.com/), [gpg](https://www.gnupg.org/download/) and
6 | [Maven](http://maven.apache.org/) must first be installed).
7 |
8 | Before building the project, ensure that you have [generated a GPG key](https://docs.github.com/en/authentication/managing-commit-signature-verification/generating-a-new-gpg-key#generating-a-gpg-key).
9 |
10 | cd $HOME
11 | mkdir workspace1
12 | cd workspace1
13 | git clone https://github.com/simoc/csvjdbc.git csvjdbc
14 | cd csvjdbc
15 | mvn install
16 | cd target
17 | dir csvjdbc*.jar
18 |
19 | ## Working With Eclipse
20 |
21 | 1. Start Eclipse with workspace `workspace1`
22 | 2. Install the JavaCC Eclipse Plug-in from the Help ->
23 | Eclipse Marketplace... menu option
24 | 3. Create a new project named `csvjdbc` using menu option
25 | File -> Import -> Maven Project -> Existing Maven Projects,
26 | select directory `workspace1` as the Root Directory, then
27 | `csvjdbc/pom.xml` as the Project and select the Add project
28 | to working set checkbox.
29 | 4. Open `src/main/javacc/org/relique/jdbc/csv/where.jj` in the Eclipse
30 | Editor and then select menu option JavaCC -> Compile with javacc
31 |
32 | ## Maven Project Usage
33 |
34 | CsvJdbc is available at [Maven Central](http://search.maven.org/).
35 | To include CsvJdbc in a [Maven](http://maven.apache.org/) project,
36 | add the following lines to the `pom.xml` file.
37 |
38 |
39 | ...
40 |
41 |
42 |
43 | net.sourceforge.csvjdbc
44 | csvjdbc
45 | 1.0.41
46 |
47 |
48 |
49 | ## Contributing
50 |
51 | A change to CsvJdbc must first be entered as a
52 | [Issue](https://github.com/simoc/csvjdbc/issues)
53 | before starting development.
54 | A [Pull Request](https://github.com/simoc/csvjdbc/pulls)
55 | for an issue will then be accepted or not
56 | accepted by a CsvJdbc administrator.
57 |
58 | Completed changes must be provided as a [git](http://www.git-scm.com)
59 | pull request and include
60 | a unit test to test the changed functionality.
61 |
62 | Label *good first issue* is used to identify existing
63 | issues that are suitable for new developers.
64 |
--------------------------------------------------------------------------------
/docs/release.md:
--------------------------------------------------------------------------------
1 | ## Releasing CsvJdbc
2 |
3 | Use the following steps to create a CsvJdbc release.
4 |
5 | * Check environment
6 |
7 | ```
8 | java -version
9 | ```
10 |
11 | must be 11.
12 |
13 | * Checkout from GitHub
14 |
15 | Push all changes from GitHub git repository to SourceForge repository
16 | (replace `simoc` with your GitHub and SourceForge usernames).
17 |
18 | ```
19 | git clone https://github.com/simoc/csvjdbc.git csvjdbc-github
20 | cd csvjdbc-github
21 | git push ssh://simoc@git.code.sf.net/p/csvjdbc/code master
22 | ```
23 |
24 | * Checkout from SourceForge
25 |
26 | ```
27 | git clone ssh://simoc@git.code.sf.net/p/csvjdbc/code csvjdbc-code
28 | git clone ssh://simoc@git.code.sf.net/p/csvjdbc/website csvjdbc-website
29 | ```
30 |
31 | * Check that XML `` tag in file `pom.xml` is the version
32 | number we are creating plus "-SNAPSHOT" suffix. If not, update it and
33 | commit.
34 |
35 | * Check that you have a `$HOME/.m2/settings.xml` file containing
36 | the following XML tags, as described
37 | [here](http://central.sonatype.org/pages/apache-maven.html)
38 | and that the GPG profile contains a GPG key created using
39 | [these steps](http://central.sonatype.org/pages/working-with-pgp-signatures.html)
40 |
41 | ```
42 | git.code.sf.net ...
43 | ossrh ...
44 | ossrh ... contains GPG profile
45 | ```
46 |
47 | * Maven deploy to Maven Central
48 |
49 | ```
50 | mvn release:clean release:prepare
51 | ```
52 |
53 | (accept defaults at prompts for CsvJdbc version, git tag, next CsvJdbc
54 | version number. You are also prompted for Sourceforge password several
55 | times).
56 |
57 | * Check that the Maven step above does not report failing unit tests
58 |
59 | ```
60 | mvn release:perform
61 | ```
62 |
63 | * Login to [Nexus Repository Manager](https://oss.sonatype.org/)
64 | (username and password same as in `` XML tag in
65 | `$HOME/.m2/settings.xml`), click on Staging Repositories in left panel,
66 | then on row netsourceforgecsvjdbc- ..., then Close in toolbar and
67 | Confirm in dialog box. This may take 20 minutes to process. Then click
68 | Release in toolbar and Confirm in dialog
69 | box, as described
70 | [here](http://central.sonatype.org/pages/releasing-the-deployment.html).
71 |
72 | * Upload to Sourceforge web site (replace `simoc`, `1.0-29` and `1.0.29` with values
73 | for this release).
74 |
75 | ```
76 | sftp simoc,csvjdbc@frs.sourceforge.net
77 | cd /home/frs/project/c/cs/csvjdbc/CsvJdbc
78 | mkdir 1.0-29
79 | cd 1.0-29
80 | put target/csvjdbc-1.0.29.jar
81 | ```
82 |
83 | * Create a `README.md` file listing the changed SourceForge
84 | Tracker tickets and GitHub issues and
85 | upload to 1.0-29 directory, as in previous step.
86 |
87 | * Update Tracker tickets from 'Pending' to 'Closed' with a comment
88 | that they are included in release 1.0-29.
89 |
90 | * Upload new `index.html` if it has changed since last release.
91 |
92 | ```
93 | cd csvjdbc-website/www
94 | sftp simoc@web.sourceforge.net
95 | cd /home/project-web/c/cs/csvjdbc/htdocs
96 | put index.html
97 | ```
98 |
99 | * Push the commits and tag created by Maven to the GitHub repository
100 |
101 | ```
102 | git push https://github.com/simoc/csvjdbc.git master
103 | git push https://github.com/simoc/csvjdbc.git csvjdbc-1.0.29
104 | ```
105 |
--------------------------------------------------------------------------------
/lib/dans-dbf-lib-1.0.0-beta-10.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/lib/dans-dbf-lib-1.0.0-beta-10.jar
--------------------------------------------------------------------------------
/src/doc/.cvsignore:
--------------------------------------------------------------------------------
1 | org
--------------------------------------------------------------------------------
/src/doc/CsvJdbcLogo.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/doc/CsvJdbcLogo.jpg
--------------------------------------------------------------------------------
/src/doc/Non_Scrollable_Driver_Class_Diagram.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/doc/Non_Scrollable_Driver_Class_Diagram.gif
--------------------------------------------------------------------------------
/src/doc/Scrollable_Driver_Class_Diagram.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/doc/Scrollable_Driver_Class_Diagram.gif
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/CryptoFilter.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.OutputStream;
21 |
22 | /**
23 | * minimalistic approach to decrypting a file.
24 | *
25 | * a class implementing this interface is required to return one character at a
26 | * time from the given InputStream. the InputStream is encrypted, the client
27 | * receives it clear-text.
28 | *
29 | * the encryption used may require you to read more than one character from the
30 | * InputStream, but this is your business, as is all initialization required by
31 | * your cipher, the client will be offered one deciphered character at a time.
32 | *
33 | * @author mfrasca@zonnet.nl
34 | *
35 | */
36 | public interface CryptoFilter
37 | {
38 | int read(InputStream in) throws IOException;
39 | void write(OutputStream out, int ch) throws IOException;
40 | int read(InputStream in, byte[] b, int off, int len) throws IOException;
41 | int read(InputStream in, byte[] b) throws IOException;
42 | void reset();
43 |
44 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/DataReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.sql.SQLException;
19 | import java.util.Map;
20 |
21 | public abstract class DataReader
22 | {
23 | public static final int DEFAULT_COLUMN_SIZE = 20;
24 |
25 | public DataReader()
26 | {
27 | super();
28 | }
29 |
30 | abstract public boolean next() throws SQLException;
31 |
32 | abstract public String[] getColumnNames() throws SQLException;
33 |
34 | abstract public void close() throws SQLException;
35 |
36 | abstract public Map getEnvironment() throws SQLException;
37 |
38 | abstract public String[] getColumnTypes() throws SQLException;
39 |
40 | abstract public int[] getColumnSizes() throws SQLException;
41 |
42 | abstract public String getTableAlias();
43 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/EncryptedFileInputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.io.BufferedInputStream;
19 | import java.io.FileInputStream;
20 | import java.io.FileNotFoundException;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 |
24 | public class EncryptedFileInputStream extends InputStream
25 | {
26 | private InputStream in;
27 | private CryptoFilter filter;
28 |
29 | public EncryptedFileInputStream(String fileName, CryptoFilter filter)
30 | throws FileNotFoundException
31 | {
32 | this.filter = filter;
33 | in = new BufferedInputStream(new FileInputStream(fileName));
34 | }
35 |
36 | @Override
37 | public int read() throws IOException
38 | {
39 | if (filter != null)
40 | return filter.read(in);
41 | else
42 | return in.read();
43 | }
44 |
45 | @Override
46 | public int read(byte[] b, int off, int len) throws IOException
47 | {
48 | if (filter != null)
49 | return filter.read(in, b, off, len);
50 | else
51 | return in.read(b, off, len);
52 | }
53 |
54 | @Override
55 | public int read(byte[] b) throws IOException
56 | {
57 | if (filter != null)
58 | return filter.read(in, b);
59 | else
60 | return in.read(b);
61 | }
62 |
63 | @Override
64 | public void close() throws IOException
65 | {
66 | if (in != null)
67 | {
68 | in.close();
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/EncryptedFileOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.io.FileNotFoundException;
19 | import java.io.FileOutputStream;
20 | import java.io.IOException;
21 | import java.io.OutputStream;
22 |
23 | public class EncryptedFileOutputStream extends OutputStream
24 | {
25 | private OutputStream out;
26 | private CryptoFilter filter;
27 |
28 | public EncryptedFileOutputStream(String fileName, CryptoFilter filter)
29 | throws FileNotFoundException
30 | {
31 | this.filter = filter;
32 | this.filter.reset();
33 | out = new FileOutputStream(fileName);
34 | }
35 |
36 | @Override
37 | public void write(int b) throws IOException
38 | {
39 | if (filter == null)
40 | out.write(b);
41 | else
42 | filter.write(out, b);
43 | }
44 |
45 | @Override
46 | public void close() throws IOException
47 | {
48 | if (out != null)
49 | out.close();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/ListDataReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.sql.SQLException;
19 | import java.util.Arrays;
20 | import java.util.HashMap;
21 | import java.util.List;
22 | import java.util.Map;
23 |
24 | /**
25 | * A reader from a list, enabling database metadata functions to return JDBC ResultSet objects
26 | * containing lists of tables, schemas and other metadata.
27 | */
28 | public class ListDataReader extends DataReader
29 | {
30 | private String []columnNames;
31 | private String []columnTypes;
32 | private List columnValues;
33 | private int rowIndex;
34 |
35 | public ListDataReader(String []columnNames, String []columnTypes, List columnValues)
36 | {
37 | this.columnNames = columnNames;
38 | this.columnTypes = columnTypes;
39 | this.columnValues = columnValues;
40 | rowIndex = -1;
41 | }
42 |
43 | @Override
44 | public boolean next() throws SQLException
45 | {
46 | rowIndex++;
47 | return rowIndex < columnValues.size();
48 | }
49 |
50 | @Override
51 | public String[] getColumnNames() throws SQLException
52 | {
53 | return columnNames;
54 | }
55 |
56 | @Override
57 | public void close() throws SQLException
58 | {
59 | }
60 |
61 | @Override
62 | public Map getEnvironment() throws SQLException
63 | {
64 | HashMap retval = new HashMap<>();
65 | Object []o = columnValues.get(rowIndex);
66 | for (int i = 0; i < columnNames.length; i++)
67 | {
68 | retval.put(columnNames[i], o[i]);
69 | }
70 | return retval;
71 | }
72 |
73 | @Override
74 | public String[] getColumnTypes() throws SQLException
75 | {
76 | return columnTypes;
77 | }
78 |
79 | @Override
80 | public int[] getColumnSizes() throws SQLException
81 | {
82 | int []columnSizes = new int[columnTypes.length];
83 | Arrays.fill(columnSizes, DEFAULT_COLUMN_SIZE);
84 | return columnSizes;
85 | }
86 |
87 | @Override
88 | public String getTableAlias()
89 | {
90 | return null;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/TableReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.io.Reader;
19 | import java.sql.Connection;
20 | import java.sql.SQLException;
21 | import java.sql.Statement;
22 | import java.util.List;
23 |
24 | /**
25 | * Interface for reading database tables.
26 | */
27 | public interface TableReader
28 | {
29 | /**
30 | * Get reader for a database table.
31 | * @param statement JDBC statement being executed.
32 | * @param tableName name of database table to read.
33 | * @return reader for the table, csvjdbc will close the reader itself at the end.
34 | * @throws SQLException if table does not exist or cannot be read.
35 | */
36 | Reader getReader(Statement statement, String tableName) throws SQLException;
37 |
38 | /**
39 | * Returns a list of the names of all tables in the database.
40 | * @param connection JDBC connection.
41 | * @return list of String values containing table names.
42 | * @throws SQLException if there is a problem creating table name list.
43 | */
44 | List getTableNames(Connection connection) throws SQLException;
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/io/XORCipher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.io;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStream;
20 | import java.io.OutputStream;
21 | import java.util.Arrays;
22 |
23 | /**
24 | * Example encryption filter that XOR's the all data with a secret seed value.
25 | */
26 | public class XORCipher implements CryptoFilter
27 | {
28 | private int keyCounter;
29 | private int[] scrambleKey;
30 |
31 | public XORCipher(String seed)
32 | {
33 | scrambleKey = new int[seed.length()];
34 | for (int i = 0; i < seed.length(); i++)
35 | scrambleKey[i] = seed.charAt(i);
36 | keyCounter = 0;
37 | }
38 |
39 | @Override
40 | public int read(InputStream in) throws IOException
41 | {
42 | if (in.available() > 0)
43 | {
44 | return (byte) scrambleInt(in.read());
45 | }
46 | else
47 | return -1;
48 | }
49 |
50 | @Override
51 | public int read(InputStream in, byte[] b) throws IOException
52 | {
53 | int len;
54 | len = in.read(b, 0, b.length);
55 | scrambleArray(b);
56 | return len;
57 | }
58 |
59 | @Override
60 | public int read(InputStream in, byte[] b, int off, int len)
61 | throws IOException
62 | {
63 | len = in.read(b, off, len);
64 | scrambleArray(b);
65 | return len;
66 | }
67 |
68 | @Override
69 | public String toString()
70 | {
71 | StringBuilder sb = new StringBuilder("XORCipher(");
72 | sb.append(scrambleKey.length);
73 | sb.append("):");
74 | sb.append(Arrays.toString(scrambleKey));
75 | return sb.toString();
76 | }
77 |
78 | /**
79 | * Perform the scrambling algorithm (named bitwise XOR encryption) using
80 | * bitwise exclusive OR (byte) encrypted character = (byte) original
81 | * character ^ (byte) key character.
82 | *
83 | * Note that ^ is the symbol for XOR (and not the mathematical power)
84 | *
85 | * @param org original value.
86 | * @return scrambled value.
87 | */
88 | private int scrambleInt(int org)
89 | {
90 | int encrDataChar = org;
91 | if (scrambleKey.length > 0)
92 | {
93 | encrDataChar = org ^ scrambleKey[keyCounter];
94 | keyCounter++;
95 | keyCounter %= scrambleKey.length;
96 | }
97 | return encrDataChar;
98 | }
99 |
100 | /**
101 | * Perform the scrambling algorithm (named bitwise XOR encryption) using
102 | * bitwise exclusive OR (byte) encrypted character = (byte) original
103 | * character ^ (byte) key character.
104 | *
105 | * Note that ^ is the symbol for XOR (and not the mathematical power)
106 | *
107 | * @param org original byte array.
108 | * @return scrambled byte array.
109 | */
110 | private void scrambleArray(byte[] org)
111 | {
112 | if (scrambleKey.length > 0)
113 | {
114 | for (int i = 0; i < org.length; i++)
115 | {
116 | org[i] ^= scrambleKey[keyCounter];
117 | keyCounter++;
118 | keyCounter %= scrambleKey.length;
119 | }
120 | }
121 | }
122 |
123 | @Override
124 | public void write(OutputStream out, int ch) throws IOException
125 | {
126 | out.write(scrambleInt(ch));
127 | }
128 |
129 | @Override
130 | public void reset()
131 | {
132 | keyCounter = 0;
133 | }
134 | }
135 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/AggregateFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | abstract class AggregateFunction extends Expression
27 | {
28 | /*
29 | * Key for column name in database rows that is accumulating
30 | * the aggregate function value.
31 | */
32 | public static final String GROUPING_COLUMN_NAME = "@GROUPROWS";
33 |
34 | public abstract List aggregateColumns(Set availableColumns);
35 | public abstract void processRow(Map env) throws SQLException;
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/AndExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class AndExpression extends LogicalExpression
28 | {
29 | LogicalExpression left, right;
30 | boolean isValid;
31 | public AndExpression(Expression left, Expression right)
32 | {
33 | isValid = (left instanceof LogicalExpression && right instanceof LogicalExpression);
34 | if (isValid)
35 | {
36 | this.left = (LogicalExpression)left;
37 | this.right = (LogicalExpression)right;
38 | isValid = left.isValid() && right.isValid();
39 | }
40 | }
41 | @Override
42 | public boolean isValid()
43 | {
44 | return isValid;
45 | }
46 | @Override
47 | public Boolean isTrue(Map env) throws SQLException
48 | {
49 | Boolean leftIsTrue = left.isTrue(env);
50 | if (leftIsTrue == null)
51 | {
52 | return null;
53 | }
54 | else if (leftIsTrue.booleanValue())
55 | {
56 | Boolean rightIsTrue = right.isTrue(env);
57 | if (rightIsTrue == null)
58 | {
59 | return null;
60 | }
61 | else if (rightIsTrue.booleanValue())
62 | {
63 | return Boolean.TRUE;
64 | }
65 | else
66 | {
67 | return Boolean.FALSE;
68 | }
69 | }
70 | else
71 | {
72 | return Boolean.FALSE;
73 | }
74 | }
75 | @Override
76 | public String toString()
77 | {
78 | return "AND "+left+" "+right;
79 | }
80 | @Override
81 | public List usedColumns(Set availableColumns)
82 | {
83 | List result = new LinkedList<>();
84 | result.addAll(left.usedColumns(availableColumns));
85 | result.addAll(right.usedColumns(availableColumns));
86 | return result;
87 | }
88 | @Override
89 | public List aggregateFunctions()
90 | {
91 | List result = new LinkedList<>();
92 | result.addAll(left.aggregateFunctions());
93 | result.addAll(right.aggregateFunctions());
94 | return result;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/AsteriskExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.List;
22 | import java.util.Set;
23 |
24 | class AsteriskExpression extends Expression
25 | {
26 | String expression;
27 | public AsteriskExpression(String expression)
28 | {
29 | this.expression = expression;
30 | }
31 | @Override
32 | public String toString()
33 | {
34 | return expression;
35 | }
36 | @Override
37 | public List usedColumns(Set availableColumns)
38 | {
39 | return List.of();
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/BetweenExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class BetweenExpression extends LogicalExpression
28 | {
29 | Expression obj, left, right;
30 | public BetweenExpression(Expression obj, Expression left, Expression right)
31 | {
32 | this.obj = obj;
33 | this.left = left;
34 | this.right = right;
35 | }
36 | @Override
37 | public Boolean isTrue(Map env) throws SQLException
38 | {
39 | Comparable leftValue = (Comparable)left.eval(env);
40 | Comparable rightValue = (Comparable)right.eval(env);
41 | Comparable objValue = (Comparable)obj.eval(env);
42 | Integer comparedLeft = RelopExpression.compare(leftValue, objValue, env);
43 | if (comparedLeft == null)
44 | return null;
45 | if (comparedLeft.intValue() <= 0)
46 | {
47 | Integer comparedRight = RelopExpression.compare(rightValue, objValue, env);
48 | if (comparedRight == null)
49 | return null;
50 | if (comparedRight.intValue() >= 0)
51 | {
52 | return Boolean.TRUE;
53 | }
54 | }
55 | return Boolean.FALSE;
56 | }
57 | @Override
58 | public String toString()
59 | {
60 | return "B "+obj+" "+left+" "+right;
61 | }
62 | @Override
63 | public List usedColumns(Set availableColumns)
64 | {
65 | List result = new LinkedList<>();
66 | result.addAll(obj.usedColumns(availableColumns));
67 | result.addAll(left.usedColumns(availableColumns));
68 | result.addAll(right.usedColumns(availableColumns));
69 | return result;
70 | }
71 | @Override
72 | public List aggregateFunctions()
73 | {
74 | List result = new LinkedList<>();
75 | result.addAll(obj.aggregateFunctions());
76 | result.addAll(left.aggregateFunctions());
77 | result.addAll(right.aggregateFunctions());
78 | return result;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ClasspathTableReader.java:
--------------------------------------------------------------------------------
1 | package org.relique.jdbc.csv;
2 |
3 | import java.io.InputStream;
4 | import java.io.InputStreamReader;
5 | import java.io.Reader;
6 | import java.io.UnsupportedEncodingException;
7 | import java.sql.Connection;
8 | import java.sql.SQLException;
9 | import java.sql.Statement;
10 | import java.util.List;
11 | import java.util.stream.Collectors;
12 |
13 | import org.relique.io.TableReader;
14 |
15 | import io.github.classgraph.ClassGraph;
16 | import io.github.classgraph.ScanResult;
17 |
18 | public class ClasspathTableReader implements TableReader
19 | {
20 | private final String path;
21 | private final String charset;
22 | private String fileExtension;
23 |
24 | public ClasspathTableReader(String path, String charset)
25 | {
26 | this.path = path;
27 | this.charset = charset;
28 | }
29 |
30 | public void setExtension(String fileExtension)
31 | {
32 | this.fileExtension = fileExtension;
33 | }
34 |
35 | public String getPath()
36 | {
37 | return path;
38 | }
39 |
40 | @Override
41 | public Reader getReader(Statement statement, String tableName) throws SQLException
42 | {
43 | InputStream inputStream = getClass().getClassLoader().getResourceAsStream(
44 | path + "/" + tableName + fileExtension);
45 | if (inputStream == null)
46 | {
47 | throw new SQLException(CsvResources.getString("tableNotFound") + ": " + tableName);
48 | }
49 | try
50 | {
51 | return charset != null ? new InputStreamReader(inputStream, charset) : new InputStreamReader(inputStream);
52 | }
53 | catch (UnsupportedEncodingException e)
54 | {
55 | throw new SQLException(e);
56 | }
57 | }
58 |
59 | @Override
60 | public List getTableNames(Connection connection) throws SQLException
61 | {
62 | try (ScanResult scanResult = new ClassGraph().acceptPaths(path).scan())
63 | {
64 | return scanResult.getResourcesWithExtension(fileExtension.substring(1))
65 | .getPaths()
66 | .stream()
67 | .map(p -> p.substring(path.length() + 1, p.length() - fileExtension.length()))
68 | .filter(p -> !p.contains("/"))
69 | .collect(Collectors.toList());
70 | }
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ColumnName.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.LinkedList;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | class ColumnName extends Expression
27 | {
28 | private String columnName;
29 |
30 | public ColumnName(String columnName)
31 | {
32 | this.columnName = columnName.toUpperCase();
33 | }
34 |
35 | public String getColumnName()
36 | {
37 | return columnName;
38 | }
39 |
40 | @Override
41 | public Object eval(Map env)
42 | {
43 | return env.get(columnName);
44 | }
45 |
46 | @Override
47 | public String toString()
48 | {
49 | return "["+columnName+"]";
50 | }
51 |
52 | @Override
53 | public List usedColumns(Set availableColumns)
54 | {
55 | List result = new LinkedList<>();
56 | result.add(columnName);
57 | return result;
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/CsvResources.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2014 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Locale;
22 | import java.util.MissingResourceException;
23 | import java.util.PropertyResourceBundle;
24 | import java.util.ResourceBundle;
25 |
26 | public class CsvResources
27 | {
28 | private static ResourceBundle messages = PropertyResourceBundle.getBundle("org.relique.jdbc.csv.messages", Locale.getDefault());
29 |
30 | public static String getString(String key)
31 | {
32 | try
33 | {
34 | return messages.getString(key);
35 | }
36 | catch (MissingResourceException e)
37 | {
38 | return "[" + key + "]";
39 | }
40 | }
41 |
42 | public static int getMajorVersion()
43 | {
44 | return parseVersion(getVersionString(), 0,1);
45 | }
46 |
47 | public static int getMinorVersion()
48 | {
49 | return parseVersion(getVersionString(), 1,0);
50 | }
51 |
52 | public static String getVersionString()
53 | {
54 | return messages.containsKey("versionString") ? CsvResources.getString("versionString"): "1.0";
55 | }
56 |
57 | public static int parseVersion(String versionString, int index, int defaultValue)
58 | {
59 | try {
60 | if (versionString != null) {
61 | return Integer.parseInt(versionString.split("\\.")[index]);
62 | }
63 | } catch (NumberFormatException e)
64 | {
65 | // We just return the default
66 | }
67 | return defaultValue;
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/CsvSavepoint.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.jdbc.csv;
17 |
18 | import java.sql.SQLException;
19 | import java.sql.Savepoint;
20 |
21 | /**
22 | * Savepoint implementation that does nothing, simply to satisfy the
23 | * JDBC savepoint interfaces.
24 | */
25 | public class CsvSavepoint implements Savepoint
26 | {
27 | private int id;
28 | private String name;
29 |
30 | CsvSavepoint(int id)
31 | {
32 | this.id = id;
33 | }
34 |
35 | CsvSavepoint(String name)
36 | {
37 | this.name = name;
38 | }
39 |
40 | @Override
41 | public int getSavepointId() throws SQLException
42 | {
43 | if (name != null)
44 | throw new SQLException(CsvResources.getString("namedSavepoint"));
45 | return id;
46 | }
47 |
48 | @Override
49 | public String getSavepointName() throws SQLException
50 | {
51 | if (name == null)
52 | throw new SQLException(CsvResources.getString("notNamedSavepoint"));
53 | return name;
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/CurrentDateConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | class CurrentDateConstant extends Expression
26 | {
27 | ExpressionParser parent;
28 | public CurrentDateConstant(ExpressionParser parent)
29 | {
30 | this.parent = parent;
31 | }
32 | @Override
33 | public Object eval(Map env)
34 | {
35 | return parent.getCurrentDate();
36 | }
37 | @Override
38 | public String toString()
39 | {
40 | return "CURRENT_DATE";
41 | }
42 | @Override
43 | public List usedColumns(Set availableColumns)
44 | {
45 | return List.of();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/CurrentTimeConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | class CurrentTimeConstant extends Expression
26 | {
27 | ExpressionParser parent;
28 | public CurrentTimeConstant(ExpressionParser parent)
29 | {
30 | this.parent = parent;
31 | }
32 | @Override
33 | public Object eval(Map env)
34 | {
35 | return parent.getCurrentTime();
36 | }
37 | @Override
38 | public String toString()
39 | {
40 | return "CURRENT_TIME";
41 | }
42 | @Override
43 | public List usedColumns(Set availableColumns)
44 | {
45 | return List.of();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ExistsExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | class ExistsExpression extends LogicalExpression
27 | {
28 | SubQueryExpression subQuery = null;
29 |
30 | public ExistsExpression(SubQueryExpression subQuery)
31 | {
32 | this.subQuery = subQuery;
33 | }
34 | @Override
35 | public Boolean isTrue(Map env) throws SQLException
36 | {
37 | boolean matches = subQuery.evalList(env, new ExistsExpressionSubQueryRowMatcher());
38 | return Boolean.valueOf(matches);
39 | }
40 | @Override
41 | public String toString()
42 | {
43 | return "EXISTS " + subQuery.toString();
44 | }
45 | @Override
46 | public List usedColumns(Set availableColumns)
47 | {
48 | return subQuery.usedColumns(availableColumns);
49 | }
50 | @Override
51 | public List aggregateFunctions()
52 | {
53 | return subQuery.aggregateFunctions();
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ExistsExpressionSubQueryRowMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 |
23 | public class ExistsExpressionSubQueryRowMatcher implements SubQueryRowMatcher
24 | {
25 | @Override
26 | public boolean matches(Object expr) throws SQLException
27 | {
28 | /*
29 | * WHERE EXISTS (SELECT ...) matches any row from the sub-query.
30 | */
31 | return true;
32 | }
33 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/Expression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | * You should have received a copy of the GNU Lesser General Public
14 | * License along with this library; if not, write to the Free Software
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 | */
17 | package org.relique.jdbc.csv;
18 |
19 | import java.sql.SQLException;
20 | import java.util.List;
21 | import java.util.Map;
22 | import java.util.Set;
23 |
24 | public abstract class Expression
25 | {
26 | /**
27 | * @throws SQLException if error evaluating expression.
28 | */
29 | public Object eval(Map env) throws SQLException
30 | {
31 | return null;
32 | }
33 | public List usedColumns(Set availableColumns)
34 | {
35 | return null;
36 | }
37 |
38 | public List aggregateFunctions()
39 | {
40 | return List.of();
41 | }
42 |
43 | /**
44 | * Is this a valid expression such as A > 5 or an invalid
45 | * mix of logical and arithmetic such as (A > 5) + 1 that we
46 | * cannot detect during parsing.
47 | * @return true if valid.
48 | */
49 | public boolean isValid()
50 | {
51 | return true;
52 | }
53 |
54 | /**
55 | * Reset aggregate function each time it is used in a subquery.
56 | */
57 | public void resetAggregateFunctions()
58 | {
59 | }
60 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/InExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class InExpression extends LogicalExpression
28 | {
29 | Expression obj;
30 | List inList = null;
31 | SubQueryExpression subQuery = null;
32 |
33 | public InExpression(Expression obj, List inList)
34 | {
35 | this.obj = obj;
36 | this.inList = inList;
37 | }
38 | public InExpression(Expression obj, SubQueryExpression subQuery)
39 | {
40 | this.obj = obj;
41 | this.subQuery = subQuery;
42 | }
43 | @Override
44 | public Boolean isTrue(Map env) throws SQLException
45 | {
46 | Comparable objValue = (Comparable)obj.eval(env);
47 | if (objValue == null)
48 | return null;
49 | if (inList != null)
50 | {
51 | for (Expression expr: inList)
52 | {
53 | Comparable exprValue = (Comparable)expr.eval(env);
54 | Integer compared = RelopExpression.compare(objValue, exprValue, env);
55 | if (compared != null && compared.intValue() == 0)
56 | return Boolean.TRUE;
57 | }
58 | }
59 | else
60 | {
61 | boolean matches = subQuery.evalList(env, new InExpressionSubQueryRowMatcher(env, objValue));
62 | return Boolean.valueOf(matches);
63 | }
64 | return Boolean.FALSE;
65 | }
66 | @Override
67 | public String toString()
68 | {
69 | StringBuilder sb = new StringBuilder();
70 | sb.append("IN ");
71 | sb.append(obj.toString());
72 |
73 | if (inList != null)
74 | {
75 | sb.append(" (");
76 | String delimiter = "";
77 | for (Expression expr: inList)
78 | {
79 | sb.append(delimiter);
80 | sb.append(expr.toString());
81 | delimiter = ", ";
82 | }
83 | sb.append(")");
84 | }
85 | else
86 | {
87 | sb.append(subQuery.toString());
88 | }
89 | return sb.toString();
90 | }
91 | @Override
92 | public List usedColumns(Set availableColumns)
93 | {
94 | List result = new LinkedList<>();
95 | result.addAll(obj.usedColumns(availableColumns));
96 | if (inList != null)
97 | {
98 | for (Expression expr: inList)
99 | {
100 | result.addAll(expr.usedColumns(availableColumns));
101 | }
102 | }
103 | if (subQuery != null)
104 | {
105 | result.addAll(subQuery.usedColumns(availableColumns));
106 | }
107 | return result;
108 | }
109 | @Override
110 | public List aggregateFunctions()
111 | {
112 | List result = new LinkedList<>();
113 | if (inList != null)
114 | {
115 | for (Expression expr: inList)
116 | {
117 | result.addAll(expr.aggregateFunctions());
118 | }
119 | }
120 | if (subQuery != null)
121 | {
122 | result.addAll(subQuery.aggregateFunctions());
123 | }
124 | return result;
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/InExpressionSubQueryRowMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Map;
23 |
24 | public class InExpressionSubQueryRowMatcher implements SubQueryRowMatcher
25 | {
26 | private Map env;
27 | private Comparable objValue;
28 |
29 | public InExpressionSubQueryRowMatcher(Map env, Comparable objValue)
30 | {
31 | this.env = env;
32 | this.objValue = objValue;
33 | }
34 |
35 | @Override
36 | public boolean matches(Object expr) throws SQLException
37 | {
38 | /*
39 | * Does this row from the sub-query match the IN expression value
40 | * from the outer/parent SQL statement?
41 | */
42 | Comparable exprValue = (Comparable)expr;
43 | Integer compared = RelopExpression.compare(objValue, exprValue, env);
44 | return (compared != null && compared.intValue() == 0);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/IsNullExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class IsNullExpression extends LogicalExpression
28 | {
29 | Expression arg;
30 | public IsNullExpression(Expression arg)
31 | {
32 | this.arg = arg;
33 | }
34 | @Override
35 | public Boolean isTrue(Map env) throws SQLException
36 | {
37 | Object o = arg.eval(env);
38 | if (o == null)
39 | return Boolean.TRUE;
40 | else
41 | return Boolean.FALSE;
42 | }
43 | @Override
44 | public String toString()
45 | {
46 | return "N "+arg;
47 | }
48 | @Override
49 | public List usedColumns(Set availableColumns)
50 | {
51 | List result = new LinkedList<>();
52 | result.addAll(arg.usedColumns(availableColumns));
53 | return result;
54 | }
55 | @Override
56 | public List aggregateFunctions()
57 | {
58 | List result = new LinkedList<>();
59 | result.addAll(arg.aggregateFunctions());
60 | return result;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/JoinType.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2014 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | /**
22 | * Types of SQL joins between tables.
23 | */
24 | public enum JoinType
25 | {
26 | NONE,
27 | CROSS,
28 | INNER,
29 | LEFT_OUTER,
30 | RIGHT_OUTER,
31 | FULL_OUTER
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/LikeExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class LikeExpression extends LogicalExpression
28 | {
29 | Expression arg1, arg2;
30 | Expression escapeArg;
31 | public LikeExpression(Expression arg1, Expression arg2, Expression escapeArg)
32 | {
33 | this.arg1 = arg1;
34 | this.arg2 = arg2;
35 | this.escapeArg = escapeArg;
36 | }
37 | @Override
38 | public Boolean isTrue(Map env) throws SQLException
39 | {
40 | Object left = arg1.eval(env);
41 | Object right = arg2.eval(env);
42 | String escape = LikePattern.DEFAULT_ESCAPE_STRING;
43 |
44 | if (escapeArg != null)
45 | {
46 | escape = "";
47 | Object o = escapeArg.eval(env);
48 | if (o != null)
49 | {
50 | String s = o.toString();
51 | if (s.length() > 0)
52 | escape = s.substring(0, 1);
53 | }
54 | }
55 |
56 | Boolean result = null;
57 | if (left != null && right != null)
58 | result = Boolean.valueOf(LikePattern.matches(right.toString(), escape, left.toString()));
59 | return result;
60 | }
61 | @Override
62 | public String toString()
63 | {
64 | StringBuilder sb = new StringBuilder();
65 | sb.append("L ");
66 | sb.append(arg1);
67 | sb.append(" ");
68 | sb.append(arg2);
69 | if (escapeArg != null)
70 | {
71 | sb.append(" ESCAPE ");
72 | sb.append(escapeArg);
73 | }
74 | return sb.toString();
75 | }
76 | @Override
77 | public List usedColumns(Set availableColumns)
78 | {
79 | List result = new LinkedList<>();
80 | result.addAll(arg1.usedColumns(availableColumns));
81 | result.addAll(arg2.usedColumns(availableColumns));
82 | if (escapeArg != null)
83 | result.addAll(escapeArg.usedColumns(availableColumns));
84 | return result;
85 | }
86 | @Override
87 | public List aggregateFunctions()
88 | {
89 | List result = new LinkedList<>();
90 | result.addAll(arg1.aggregateFunctions());
91 | result.addAll(arg2.aggregateFunctions());
92 | if (escapeArg != null)
93 | result.addAll(escapeArg.aggregateFunctions());
94 | return result;
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/LikePattern.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.jdbc.csv;
17 |
18 | import java.util.Hashtable;
19 | import java.util.StringTokenizer;
20 | import java.util.regex.Pattern;
21 |
22 | /**
23 | * Performs string matching for SQL LIKE patterns.
24 | */
25 | public class LikePattern
26 | {
27 | public static final String DEFAULT_ESCAPE_STRING = "\\";
28 |
29 | /**
30 | * Global lookup table of LIKE pattern to compiled regular expression.
31 | */
32 | private static Hashtable compiledRegexs = new Hashtable<>();
33 |
34 | /**
35 | *
36 | * @param likePattern an SQL LIKE pattern including % and _ characters.
37 | * @param escape SQL ESCAPE character, or empty string for no escaping.
38 | * @param input string to be matched.
39 | * @return true if input string matches LIKE pattern.
40 | */
41 | public static boolean matches(String likePattern, String escape, CharSequence input)
42 | {
43 | boolean retval;
44 | int percentIndex = likePattern.indexOf('%');
45 | int underscoreIndex = likePattern.indexOf('_');
46 | if (percentIndex < 0 && underscoreIndex < 0)
47 | {
48 | /*
49 | * No wildcards in pattern so we can just compare strings.
50 | */
51 | retval = likePattern.equals(input);
52 | }
53 | else
54 | {
55 | Pattern p = compiledRegexs.get(likePattern);
56 | if (p == null)
57 | {
58 | /*
59 | * First convert LIKE pattern to a regular expression.
60 | */
61 | boolean isEscaped = false;
62 | StringBuilder regex = new StringBuilder();
63 | StringTokenizer tokenizer = new StringTokenizer(likePattern, "%_" + escape, true);
64 | while (tokenizer.hasMoreTokens())
65 | {
66 | String token = tokenizer.nextToken();
67 | if (token.equals(escape))
68 | {
69 | if (isEscaped)
70 | {
71 | /*
72 | * Two escaped characters in a row result match a
73 | * single literal escape character.
74 | */
75 | regex.append(Pattern.quote(token));
76 | }
77 | else
78 | {
79 | isEscaped = true;
80 | }
81 | }
82 | else
83 | {
84 | if (isEscaped)
85 | regex.append(Pattern.quote(token));
86 | else if (token.equals("%"))
87 | regex.append(".*");
88 | else if (token.equals("_"))
89 | regex.append(".");
90 | else
91 | regex.append(Pattern.quote(token));
92 | isEscaped = false;
93 | }
94 | }
95 |
96 | /*
97 | * Cache compiled regular expression because we will probably be
98 | * using the same one again and again.
99 | *
100 | * DOTALL flag required so that dots in regular expression match
101 | * any newline character in input string.
102 | */
103 | p = Pattern.compile(regex.toString(), Pattern.DOTALL);
104 | compiledRegexs.put(likePattern, p);
105 | }
106 | retval = p.matcher(input).matches();
107 | }
108 | return retval;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/LogicalExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Map;
23 |
24 | abstract class LogicalExpression extends Expression
25 | {
26 | /**
27 | * Returns evaluation of expression using given environment.
28 | * @param env key, value pairs of environment.
29 | * @return TRUE or FALSE or null if evaluation contains SQL NULL.
30 | * @throws SQLException if error evaluating logical expression.
31 | */
32 | public Boolean isTrue(Map env) throws SQLException
33 | {
34 | return Boolean.FALSE;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/MultipleSqlParser.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2013 Simon Chenery
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.jdbc.csv;
17 |
18 | import java.io.StringReader;
19 | import java.sql.SQLException;
20 | import java.util.LinkedList;
21 | import java.util.List;
22 |
23 | /**
24 | * Parses one or many SQL statements.
25 | */
26 | public class MultipleSqlParser
27 | {
28 | public List parse(String sql) throws ParseException, SQLException
29 | {
30 | // Ensure last line of SQL statement ends with newline so we can
31 | // correctly skip single-line comments.
32 | sql = sql + "\n";
33 |
34 | ExpressionParser cs2 = new ExpressionParser(new StringReader(sql));
35 | PlaceholderFactory placeholderFactory = new PlaceholderFactory();
36 | List statements = cs2.parseMultipleStatements(placeholderFactory);
37 | LinkedList retval = new LinkedList<>();
38 | for (ParsedStatement parsedStatement : statements)
39 | {
40 | SqlParser sqlParser = new SqlParser();
41 | sqlParser.setParsedStatement(parsedStatement);
42 | retval.add(sqlParser);
43 | }
44 | return retval;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/NotExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.List;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | class NotExpression extends LogicalExpression
27 | {
28 | LogicalExpression content;
29 | boolean isValid;
30 | public NotExpression(Expression arg)
31 | {
32 | isValid = (arg instanceof LogicalExpression);
33 | if (isValid)
34 | {
35 | this.content = (LogicalExpression)arg;
36 | isValid = this.content.isValid();
37 | }
38 | }
39 | @Override
40 | public boolean isValid()
41 | {
42 | return isValid;
43 | }
44 | @Override
45 | public Boolean isTrue(Map env) throws SQLException
46 | {
47 | Boolean b = content.isTrue(env);
48 | if (b == null)
49 | return null;
50 | else if (b.booleanValue())
51 | return Boolean.FALSE;
52 | else
53 | return Boolean.TRUE;
54 | }
55 | @Override
56 | public String toString()
57 | {
58 | return "NOT "+content;
59 | }
60 | @Override
61 | public List usedColumns(Set availableColumns)
62 | {
63 | return content.usedColumns(availableColumns);
64 | }
65 | @Override
66 | public List aggregateFunctions()
67 | {
68 | return content.aggregateFunctions();
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/NullConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | class NullConstant extends Expression
26 | {
27 | @Override
28 | public Object eval(Map env)
29 | {
30 | return null;
31 | }
32 | @Override
33 | public String toString()
34 | {
35 | return "null";
36 | }
37 | @Override
38 | public List usedColumns(Set availableColumns)
39 | {
40 | return List.of();
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/NumericConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Map;
22 | import java.util.List;
23 | import java.util.Set;
24 |
25 | class NumericConstant extends Expression
26 | {
27 | Number value;
28 | public NumericConstant(Number d)
29 | {
30 | value = d;
31 | }
32 | @Override
33 | public Object eval(Map env)
34 | {
35 | return value;
36 | }
37 | @Override
38 | public String toString()
39 | {
40 | return value.toString();
41 | }
42 | @Override
43 | public List usedColumns(Set availableColumns)
44 | {
45 | return List.of();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/OrExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class OrExpression extends LogicalExpression
28 | {
29 | LogicalExpression left, right;
30 | boolean isValid;
31 | public OrExpression(Expression left, Expression right)
32 | {
33 | isValid = (left instanceof LogicalExpression && right instanceof LogicalExpression);
34 | if (isValid)
35 | {
36 | this.left = (LogicalExpression)left;
37 | this.right = (LogicalExpression)right;
38 | isValid = left.isValid() && right.isValid();
39 | }
40 | }
41 | @Override
42 | public boolean isValid()
43 | {
44 | return isValid;
45 | }
46 | @Override
47 | public Boolean isTrue(Map env) throws SQLException
48 | {
49 | Boolean leftIsTrue = left.isTrue(env);
50 | if (leftIsTrue != null && leftIsTrue.booleanValue())
51 | {
52 | return Boolean.TRUE;
53 | }
54 | else
55 | {
56 | Boolean rightIsTrue = right.isTrue(env);
57 | if (rightIsTrue != null && rightIsTrue.booleanValue())
58 | return Boolean.TRUE;
59 |
60 | if (leftIsTrue == null && rightIsTrue == null)
61 | return null;
62 | else
63 | return Boolean.FALSE;
64 | }
65 | }
66 | @Override
67 | public String toString()
68 | {
69 | return "OR "+left+" "+right;
70 | }
71 | @Override
72 | public List usedColumns(Set availableColumns)
73 | {
74 | List result = new LinkedList<>();
75 | result.addAll(left.usedColumns(availableColumns));
76 | result.addAll(right.usedColumns(availableColumns));
77 | return result;
78 | }
79 | @Override
80 | public List aggregateFunctions()
81 | {
82 | List result = new LinkedList<>();
83 | result.addAll(left.aggregateFunctions());
84 | result.addAll(right.aggregateFunctions());
85 | return result;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/OrderByEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | class OrderByEntry extends Expression
22 | {
23 | String order;
24 | Expression expression;
25 | public OrderByEntry(Expression expression, String order)
26 | {
27 | this.order = order.toUpperCase();
28 | this.expression = expression;
29 | }
30 |
31 | @Override
32 | public String toString()
33 | {
34 | return expression.toString() + " " + order;
35 | }
36 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ParsedExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.HashMap;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class ParsedExpression extends LogicalExpression
28 | {
29 | public Expression content;
30 | private Map placeholders;
31 | public ParsedExpression(Expression left)
32 | {
33 | content = left;
34 | placeholders = new HashMap<>();
35 | }
36 | @Override
37 | public boolean isValid()
38 | {
39 | return content.isValid();
40 | }
41 | @Override
42 | public Boolean isTrue(Map env) throws SQLException
43 | {
44 | if(!placeholders.isEmpty())
45 | {
46 | /*
47 | * Add prepared statement placeholders to environment.
48 | */
49 | Map useThisEnv = new HashMap<>();
50 | useThisEnv.putAll(env);
51 | useThisEnv.putAll(placeholders);
52 | env = useThisEnv;
53 | }
54 | return ((LogicalExpression)content).isTrue(env);
55 | }
56 | @Override
57 | public Object eval(Map env) throws SQLException
58 | {
59 | if(!placeholders.isEmpty())
60 | {
61 | /*
62 | * Add prepared statement placeholders to environment.
63 | */
64 | Map useThisEnv = new HashMap<>();
65 | useThisEnv.putAll(env);
66 | useThisEnv.putAll(placeholders);
67 | env = useThisEnv;
68 | }
69 | return content.eval(env);
70 | }
71 | @Override
72 | public String toString()
73 | {
74 | return content.toString();
75 | }
76 | @Override
77 | public List usedColumns(Set availableColumns)
78 | {
79 | return content.usedColumns(availableColumns);
80 | }
81 | @Override
82 | public List aggregateFunctions()
83 | {
84 | return content.aggregateFunctions();
85 | }
86 | @Override
87 | public void resetAggregateFunctions()
88 | {
89 | content.resetAggregateFunctions();
90 | }
91 | public int getPlaceholdersCount()
92 | {
93 | return placeholders.size();
94 | }
95 | public void setPlaceholdersValues(Object[] values)
96 | {
97 | for(int i=1; i env)
45 | {
46 | return env.get("?" + position);
47 | }
48 | @Override
49 | public String toString()
50 | {
51 | return "?";
52 | }
53 | @Override
54 | public List usedColumns(Set availableColumns)
55 | {
56 | return List.of();
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/PlaceholderFactory.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2024 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | /**
22 | * Generates sequential placeholder positions in a prepared statement,
23 | * counting from 1.
24 | */
25 | public class PlaceholderFactory
26 | {
27 | private int count = 0;
28 |
29 | public Placeholder createPlaceholder()
30 | {
31 | count++;
32 | return new Placeholder(count);
33 | }
34 |
35 | public int getPlaceholderCount()
36 | {
37 | return count;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/QueryEnvEntry.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Map;
23 |
24 | class QueryEnvEntry extends Expression
25 | {
26 | private String key;
27 | private Expression expression;
28 |
29 | public QueryEnvEntry(String fieldName, Expression exp)
30 | {
31 | this.key = fieldName.toUpperCase();
32 | this.expression = exp;
33 | }
34 |
35 | public Expression getExpression()
36 | {
37 | return expression;
38 | }
39 |
40 | public String getKey()
41 | {
42 | return key;
43 | }
44 |
45 | @Override
46 | public Object eval(Map env) throws SQLException
47 | {
48 | return expression.eval(env);
49 | }
50 |
51 | @Override
52 | public String toString()
53 | {
54 | return key+": "+expression.toString();
55 | }
56 |
57 | @Override
58 | public void resetAggregateFunctions()
59 | {
60 | expression.resetAggregateFunctions();
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLAbsFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLAbsFunction extends Expression
28 | {
29 | Expression expression;
30 | public SQLAbsFunction(Expression expression)
31 | {
32 | this.expression = expression;
33 | }
34 | @Override
35 | public Object eval(Map env) throws SQLException
36 | {
37 | Object retval = null;
38 | Object o = expression.eval(env);
39 | if (o != null)
40 | {
41 | if (!(o instanceof Number))
42 | {
43 | try
44 | {
45 | o = Double.valueOf(o.toString());
46 | }
47 | catch(NumberFormatException e)
48 | {
49 | o = null;
50 | }
51 | }
52 |
53 | if (o != null)
54 | {
55 | if (o instanceof Short)
56 | {
57 | int i = ((Short)o).intValue();
58 | if (i < 0)
59 | i = -i;
60 | retval = Integer.valueOf(i);
61 | }
62 | else if (o instanceof Integer)
63 | {
64 | int i = ((Integer)o).intValue();
65 | if (i < 0)
66 | i = -i;
67 | retval = Integer.valueOf(i);
68 | }
69 | else if (o instanceof Long)
70 | {
71 | long l = ((Long)o).intValue();
72 | if (l < 0)
73 | l = -l;
74 | retval = Long.valueOf(l);
75 | }
76 | else
77 | {
78 | double d = ((Number)o).doubleValue();
79 | if (d < 0)
80 | d = -d;
81 | retval = Double.valueOf(d);
82 | }
83 | }
84 | }
85 | return retval;
86 | }
87 | @Override
88 | public String toString()
89 | {
90 | return "ABS("+expression+")";
91 | }
92 | @Override
93 | public List usedColumns(Set availableColumns)
94 | {
95 | List result = new LinkedList<>();
96 | result.addAll(expression.usedColumns(availableColumns));
97 | return result;
98 | }
99 | @Override
100 | public List aggregateFunctions()
101 | {
102 | List result = new LinkedList<>();
103 | result.addAll(expression.aggregateFunctions());
104 | return result;
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLArrayAggFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | CsvJdbc - a JDBC driver for CSV files
3 | Copyright (C) 2023 Peter Fokkinga
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.*;
23 |
24 | public class SQLArrayAggFunction extends AggregateFunction
25 | {
26 | final boolean isDistinct;
27 | final Expression expression;
28 | final ArrayList aggregateValues = new ArrayList<>();
29 | final LinkedHashSet distinctAggregateValues = new LinkedHashSet<>();
30 |
31 | public SQLArrayAggFunction(boolean isDistinct, Expression expression)
32 | {
33 | this.isDistinct = isDistinct;
34 | this.expression = expression;
35 | }
36 |
37 | @Override
38 | public Object eval(Map env) throws SQLException
39 | {
40 | List values = new ArrayList<>();
41 | Object o = env.get(GROUPING_COLUMN_NAME);
42 | if (o != null)
43 | {
44 | List groupRows = (List)o;
45 | for (int i = 0; i < groupRows.size(); i++)
46 | {
47 | o = expression.eval((Map)groupRows.get(i));
48 | if (o != null)
49 | {
50 | values.add(o);
51 | }
52 | }
53 | }
54 | else
55 | {
56 | Iterator it = aggregateValues.iterator();
57 | while (it.hasNext())
58 | {
59 | values.add(it.next());
60 | }
61 | it = distinctAggregateValues.iterator();
62 | while (it.hasNext())
63 | {
64 | values.add(it.next());
65 | }
66 | }
67 | StringConverter converter = (StringConverter)env.get(StringConverter.COLUMN_NAME);
68 | CsvStatement statement = (CsvStatement)env.get(CsvStatement.STATEMENT_COLUMN_NAME);
69 | return new SqlArray(values, converter, statement.getConnection());
70 |
71 | }
72 |
73 | @Override
74 | public List usedColumns(Set availableColumns)
75 | {
76 | return Collections.emptyList();
77 | }
78 |
79 | @Override
80 | public List aggregateColumns(Set availableColumns)
81 | {
82 | return new LinkedList<>(expression.usedColumns(availableColumns));
83 | }
84 |
85 | @Override
86 | public List aggregateFunctions()
87 | {
88 | List result = new LinkedList<>();
89 | result.add(this);
90 | return result;
91 | }
92 |
93 | @Override
94 | public void resetAggregateFunctions()
95 | {
96 | distinctAggregateValues.clear();
97 | aggregateValues.clear();
98 | }
99 |
100 | @Override
101 | public void processRow(Map env) throws SQLException
102 | {
103 | /*
104 | * Only consider non-null values.
105 | */
106 | Object o = expression.eval(env);
107 | if (o != null)
108 | {
109 | if (isDistinct)
110 | distinctAggregateValues.add(o);
111 | else
112 | aggregateValues.add(o);
113 | }
114 | }
115 |
116 | @Override
117 | public String toString()
118 | {
119 | StringBuilder sb = new StringBuilder("ARRAY_AGG(");
120 | if (isDistinct)
121 | sb.append("DISTINCT ");
122 | sb.append(expression);
123 | sb.append(")");
124 | return sb.toString();
125 | }
126 | }
127 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLAvgFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Map;
23 |
24 | class SQLAvgFunction extends SQLSumFunction
25 | {
26 | public SQLAvgFunction(boolean isDistinct, Expression expression)
27 | {
28 | super(isDistinct, expression);
29 | }
30 | @Override
31 | public Object eval(Map env) throws SQLException
32 | {
33 | Object o = super.eval(env);
34 | if (o != null)
35 | {
36 | double average = ((Number)o).doubleValue() / counter;
37 | o = Double.valueOf(average);
38 | }
39 | return o;
40 | }
41 | @Override
42 | public String toString()
43 | {
44 | StringBuilder sb = new StringBuilder("AVG(");
45 | if (distinctValues != null)
46 | sb.append("DISTINCT ");
47 | sb.append(expression);
48 | sb.append(")");
49 | return sb.toString();
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLCalendarFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Calendar;
23 | import java.util.LinkedList;
24 | import java.util.List;
25 | import java.util.Map;
26 | import java.util.Set;
27 |
28 | class SQLCalendarFunction extends Expression
29 | {
30 | String functionName;
31 | int calendarField;
32 | Expression expression;
33 | public SQLCalendarFunction(String functionName, int calendarField,
34 | Expression expression)
35 | {
36 | this.functionName = functionName;
37 | this.calendarField = calendarField;
38 | this.expression = expression;
39 | }
40 | @Override
41 | public Object eval(Map env) throws SQLException
42 | {
43 | Object retval = null;
44 | Object o = expression.eval(env);
45 | if (o != null)
46 | {
47 | /*
48 | * Accept either java.sql.Date, java.sql.Time or java.sql.Timestamp.
49 | */
50 | java.util.Date date = null;
51 | if (o instanceof java.util.Date)
52 | {
53 | date = (java.util.Date)o;
54 | }
55 | else
56 | {
57 | /*
58 | * Try and convert from String to a Timestamp or Date/Time.
59 | */
60 | Expression stringConverter = new ColumnName(StringConverter.COLUMN_NAME);
61 | StringConverter sc = (StringConverter) stringConverter.eval(env);
62 | date = sc.parseTimestamp(o.toString());
63 | if (date == null)
64 | {
65 | if (calendarField == Calendar.DAY_OF_MONTH ||
66 | calendarField == Calendar.MONTH ||
67 | calendarField == Calendar.YEAR)
68 | {
69 | date = sc.parseDate(o.toString());
70 | }
71 | else
72 | {
73 | date = sc.parseTime(o.toString());
74 | }
75 | }
76 | }
77 | if (date != null)
78 | {
79 | Calendar cal = Calendar.getInstance();
80 | cal.setTime(date);
81 | int fieldValue = cal.get(calendarField);
82 | if (calendarField == Calendar.MONTH)
83 | fieldValue++;
84 | retval = Integer.valueOf(fieldValue);
85 | }
86 | }
87 | return retval;
88 | }
89 | @Override
90 | public String toString()
91 | {
92 | return functionName+"("+expression+")";
93 | }
94 | @Override
95 | public List usedColumns(Set availableColumns)
96 | {
97 | List result = new LinkedList<>();
98 | result.addAll(expression.usedColumns(availableColumns));
99 | return result;
100 | }
101 | @Override
102 | public List aggregateFunctions()
103 | {
104 | List result = new LinkedList<>();
105 | result.addAll(expression.aggregateFunctions());
106 | return result;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLCoalesceFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2014 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Iterator;
25 | import java.util.Map;
26 | import java.util.Set;
27 |
28 | class SQLCoalesceFunction extends Expression
29 | {
30 | List expressions;
31 | public SQLCoalesceFunction(List expressions)
32 | {
33 | this.expressions = expressions;
34 | }
35 | @Override
36 | public Object eval(Map env) throws SQLException
37 | {
38 | Object retval = null;
39 |
40 | /*
41 | * Find first expression that does not evaluate to NULL.
42 | */
43 | Iterator it = expressions.iterator();
44 | while (retval == null && it.hasNext())
45 | {
46 | Expression expr = it.next();
47 | retval = expr.eval(env);
48 | }
49 | return retval;
50 | }
51 | @Override
52 | public String toString()
53 | {
54 | StringBuilder sb = new StringBuilder("COALESCE(");
55 | String delimiter = "";
56 | Iterator it = expressions.iterator();
57 | while (it.hasNext())
58 | {
59 | sb.append(delimiter);
60 | sb.append(it.next().toString());
61 | delimiter = ",";
62 | }
63 | sb.append(")");
64 | return sb.toString();
65 | }
66 | @Override
67 | public List usedColumns(Set availableColumns)
68 | {
69 | List result = new LinkedList<>();
70 | Iterator it = expressions.iterator();
71 | while (it.hasNext())
72 | {
73 | result.addAll(it.next().usedColumns(availableColumns));
74 | }
75 | return result;
76 | }
77 | @Override
78 | public List aggregateFunctions()
79 | {
80 | List result = new LinkedList<>();
81 | Iterator it = expressions.iterator();
82 | while (it.hasNext())
83 | {
84 | result.addAll(it.next().aggregateFunctions());
85 | }
86 | return result;
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLDayOfMonthFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLDayOfMonthFunction extends SQLCalendarFunction
24 | {
25 | public SQLDayOfMonthFunction(Expression expression)
26 | {
27 | super("DAYOFMONTH", Calendar.DAY_OF_MONTH, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLHourOfDayFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLHourOfDayFunction extends SQLCalendarFunction
24 | {
25 | public SQLHourOfDayFunction(Expression expression)
26 | {
27 | super("HOUROFDAY", Calendar.HOUR_OF_DAY, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLLengthFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLLengthFunction extends Expression
28 | {
29 | Expression expression;
30 | public SQLLengthFunction(Expression expression)
31 | {
32 | this.expression = expression;
33 | }
34 | @Override
35 | public Object eval(Map env) throws SQLException
36 | {
37 | Object retval = expression.eval(env);
38 | if (retval != null)
39 | retval = Integer.valueOf(retval.toString().length());
40 | return retval;
41 | }
42 | @Override
43 | public String toString()
44 | {
45 | return "LENGTH("+expression+")";
46 | }
47 | @Override
48 | public List usedColumns(Set availableColumns)
49 | {
50 | List result = new LinkedList<>();
51 | result.addAll(expression.usedColumns(availableColumns));
52 | return result;
53 | }
54 | @Override
55 | public List aggregateFunctions()
56 | {
57 | List result = new LinkedList<>();
58 | result.addAll(expression.aggregateFunctions());
59 | return result;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLLineNumberFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2023 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLLineNumberFunction extends Expression
28 | {
29 | /*
30 | * Key for column name in database rows for accessing line number in CSV file.
31 | */
32 | public static final String LINE_NUMBER_COLUMN_NAME = "@LINE_NUMBER";
33 |
34 | private Expression expression = new ColumnName(LINE_NUMBER_COLUMN_NAME);
35 |
36 | public SQLLineNumberFunction()
37 | {
38 | }
39 | @Override
40 | public Object eval(Map env) throws SQLException
41 | {
42 | return expression.eval(env);
43 | }
44 | @Override
45 | public String toString()
46 | {
47 | return "LINE_NUMBER()";
48 | }
49 | @Override
50 | public List usedColumns(Set availableColumns)
51 | {
52 | return new LinkedList<>();
53 | }
54 | @Override
55 | public List aggregateFunctions()
56 | {
57 | return new LinkedList<>();
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLLowerFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLLowerFunction extends Expression
28 | {
29 | Expression expression;
30 | public SQLLowerFunction(Expression expression)
31 | {
32 | this.expression = expression;
33 | }
34 | @Override
35 | public Object eval(Map env) throws SQLException
36 | {
37 | Object retval = expression.eval(env);
38 | if (retval != null)
39 | retval = retval.toString().toLowerCase();
40 | return retval;
41 | }
42 | @Override
43 | public String toString()
44 | {
45 | return "LOWER("+expression+")";
46 | }
47 | @Override
48 | public List usedColumns(Set availableColumns)
49 | {
50 | List result = new LinkedList<>();
51 | result.addAll(expression.usedColumns(availableColumns));
52 | return result;
53 | }
54 | @Override
55 | public List aggregateFunctions()
56 | {
57 | List result = new LinkedList<>();
58 | result.addAll(expression.aggregateFunctions());
59 | return result;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLMaxFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLMaxFunction extends AggregateFunction
28 | {
29 | boolean isDistinct;
30 | Expression expression;
31 | Object max = null;
32 | public SQLMaxFunction(boolean isDistinct, Expression expression)
33 | {
34 | this.isDistinct = isDistinct;
35 | this.expression = expression;
36 | }
37 | @Override
38 | public Object eval(Map env) throws SQLException
39 | {
40 | Object o = env.get(GROUPING_COLUMN_NAME);
41 | if (o != null)
42 | {
43 | /*
44 | * Find the maximum from the rows grouped together
45 | * by the GROUP BY clause.
46 | */
47 | List groupRows = (List)o;
48 | Object maxInGroup = null;
49 | for (int i = 0; i < groupRows.size(); i++)
50 | {
51 | o = expression.eval((Map)groupRows.get(i));
52 | if (o != null)
53 | {
54 | if (maxInGroup == null || ((Comparable)maxInGroup).compareTo(o) < 0)
55 | maxInGroup = o;
56 | }
57 | }
58 | return maxInGroup;
59 | }
60 | return max;
61 | }
62 | @Override
63 | public String toString()
64 | {
65 | StringBuilder sb = new StringBuilder("MAX(");
66 | if (isDistinct)
67 | sb.append("DISTINCT ");
68 | sb.append(expression);
69 | sb.append(")");
70 | return sb.toString();
71 | }
72 | @Override
73 | public List usedColumns(Set availableColumns)
74 | {
75 | return List.of();
76 | }
77 | @Override
78 | public List aggregateColumns(Set availableColumns)
79 | {
80 | List result = new LinkedList<>();
81 | result.addAll(expression.usedColumns(availableColumns));
82 | return result;
83 | }
84 | @Override
85 | public List aggregateFunctions()
86 | {
87 | List result = new LinkedList<>();
88 | result.add(this);
89 | return result;
90 | }
91 | @Override
92 | public void resetAggregateFunctions()
93 | {
94 | this.max = null;
95 | }
96 | @Override
97 | public void processRow(Map env) throws SQLException
98 | {
99 | /*
100 | * Only consider non-null values.
101 | */
102 | Object o = expression.eval(env);
103 | if (o != null)
104 | {
105 | if (max == null || ((Comparable)max).compareTo(o) < 0)
106 | max = o;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLMinFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLMinFunction extends AggregateFunction
28 | {
29 | boolean isDistinct;
30 | Expression expression;
31 | Object min = null;
32 | public SQLMinFunction(boolean isDistinct, Expression expression)
33 | {
34 | this.isDistinct = isDistinct;
35 | this.expression = expression;
36 | }
37 | @Override
38 | public Object eval(Map env) throws SQLException
39 | {
40 | Object o = env.get(GROUPING_COLUMN_NAME);
41 | if (o != null)
42 | {
43 | /*
44 | * Find the minimum from the rows grouped together
45 | * by the GROUP BY clause.
46 | */
47 | List groupRows = (List)o;
48 | Object minInGroup = null;
49 | for (int i = 0; i < groupRows.size(); i++)
50 | {
51 | o = expression.eval((Map)groupRows.get(i));
52 | if (o != null)
53 | {
54 | if (minInGroup == null || ((Comparable)minInGroup).compareTo(o) > 0)
55 | minInGroup = o;
56 | }
57 | }
58 | return minInGroup;
59 | }
60 | return min;
61 | }
62 | @Override
63 | public String toString()
64 | {
65 | StringBuilder sb = new StringBuilder("MIN(");
66 | if (isDistinct)
67 | sb.append("DISTINCT ");
68 | sb.append(expression);
69 | sb.append(")");
70 | return sb.toString();
71 | }
72 | @Override
73 | public List usedColumns(Set availableColumns)
74 | {
75 | return List.of();
76 | }
77 | @Override
78 | public List aggregateColumns(Set availableColumns)
79 | {
80 | List result = new LinkedList<>();
81 | result.addAll(expression.usedColumns(availableColumns));
82 | return result;
83 | }
84 | @Override
85 | public List aggregateFunctions()
86 | {
87 | List result = new LinkedList<>();
88 | result.add(this);
89 | return result;
90 | }
91 | @Override
92 | public void resetAggregateFunctions()
93 | {
94 | this.min = null;
95 | }
96 | @Override
97 | public void processRow(Map env) throws SQLException
98 | {
99 | /*
100 | * Only consider non-null values.
101 | */
102 | Object o = expression.eval(env);
103 | if (o != null)
104 | {
105 | if (min == null || ((Comparable)min).compareTo(o) > 0)
106 | min = o;
107 | }
108 | }
109 | }
110 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLMinuteFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLMinuteFunction extends SQLCalendarFunction
24 | {
25 | public SQLMinuteFunction(Expression expression)
26 | {
27 | super("MINUTE", Calendar.MINUTE, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLMonthFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLMonthFunction extends SQLCalendarFunction
24 | {
25 | public SQLMonthFunction(Expression expression)
26 | {
27 | super("MONTH", Calendar.MONTH, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLNullIfFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLNullIfFunction extends Expression
28 | {
29 | Expression expression1;
30 | Expression expression2;
31 | public SQLNullIfFunction(Expression expression1, Expression expression2)
32 | {
33 | this.expression1 = expression1;
34 | this.expression2 = expression2;
35 | }
36 | @Override
37 | public Object eval(Map env) throws SQLException
38 | {
39 | Object retval;
40 | Comparable value1 = (Comparable)expression1.eval(env);
41 | Comparable value2 = (Comparable)expression2.eval(env);
42 | Integer compared = RelopExpression.compare(value1, value2, env);
43 |
44 | if (compared != null && compared.intValue() == 0)
45 | retval = null;
46 | else
47 | retval = value1;
48 | return retval;
49 | }
50 | @Override
51 | public String toString()
52 | {
53 | return "NULLIF("+expression1+","+expression2+")";
54 | }
55 | @Override
56 | public List usedColumns(Set availableColumns)
57 | {
58 | List result = new LinkedList<>();
59 | result.addAll(expression1.usedColumns(availableColumns));
60 | result.addAll(expression2.usedColumns(availableColumns));
61 | return result;
62 | }
63 | @Override
64 | public List aggregateFunctions()
65 | {
66 | List result = new LinkedList<>();
67 | result.addAll(expression1.aggregateFunctions());
68 | result.addAll(expression2.aggregateFunctions());
69 | return result;
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLRandomFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2024 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.ArrayList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Random;
26 | import java.util.Set;
27 |
28 | class SQLRandomFunction extends Expression
29 | {
30 | private Random random = null;
31 |
32 | /**
33 | * Remembers random numbers already generated for rows.
34 | */
35 | private ArrayList randomsForRows = new ArrayList<>();
36 |
37 | private Expression expression = new SQLLineNumberFunction();
38 |
39 | public SQLRandomFunction()
40 | {
41 | }
42 |
43 | @Override
44 | public Object eval(Map env) throws SQLException
45 | {
46 | /*
47 | * Delay creation of random number generator until first evaluation,
48 | * when we are able to access any random seed set for the connection.
49 | */
50 | if (random == null)
51 | {
52 | CsvStatement statement = (CsvStatement)env.get(CsvStatement.STATEMENT_COLUMN_NAME);
53 | Long randomSeed = ((CsvConnection)statement.getConnection()).getRandomSeed();
54 | if (randomSeed != null)
55 | {
56 | random = new Random(randomSeed.longValue());
57 | }
58 | else
59 | {
60 | random = new Random();
61 | }
62 | }
63 |
64 | /*
65 | * Random function will be evaluated several times if the application
66 | * calls ResultSet.getDouble(n) to fetch the column value several times.
67 | *
68 | * Cache the random number generated for each row, and return the same
69 | * value if the random function is evaluated again for the same row.
70 | */
71 | Integer lineNumber = (Integer)expression.eval(env);
72 | if (lineNumber != null && lineNumber.intValue() < randomsForRows.size())
73 | {
74 | Double previousValue = randomsForRows.get(lineNumber);
75 | if (previousValue != null)
76 | {
77 | return previousValue;
78 | }
79 | }
80 | Double nextDouble = Double.valueOf(random.nextDouble());
81 | if (lineNumber != null)
82 | {
83 | /*
84 | * Extend array for this row.
85 | */
86 | int i = lineNumber.intValue();
87 | randomsForRows.ensureCapacity(i + 1);
88 | while (randomsForRows.size() < i + 1)
89 | {
90 | randomsForRows.add(null);
91 | }
92 | randomsForRows.set(i, nextDouble);
93 | }
94 | return Double.valueOf(nextDouble);
95 | }
96 |
97 | @Override
98 | public String toString()
99 | {
100 | return "RANDOM";
101 | }
102 |
103 | @Override
104 | public List usedColumns(Set availableColumns)
105 | {
106 | return List.of();
107 | }
108 |
109 | @Override
110 | public List aggregateFunctions()
111 | {
112 | return List.of();
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLReplaceFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2022 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | * This library is distributed in the hope that it will be useful,
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * Lesser General Public License for more details.
13 | * You should have received a copy of the GNU Lesser General Public
14 | * License along with this library; if not, write to the Free Software
15 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 | */
17 | package org.relique.jdbc.csv;
18 |
19 | import java.sql.SQLException;
20 | import java.util.LinkedList;
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | class SQLReplaceFunction extends Expression
26 | {
27 | Expression expr;
28 | Expression from;
29 | Expression to;
30 |
31 | public SQLReplaceFunction(Expression expr, Expression from, Expression to)
32 | {
33 | this.expr = expr;
34 | this.from = from;
35 | this.to = to;
36 | }
37 |
38 | @Override
39 | public Object eval(Map env) throws SQLException
40 | {
41 | Object retval = null;
42 |
43 | Object str = expr.eval(env);
44 | if (str != null)
45 | {
46 | Object fromObj = from.eval(env);
47 | if (fromObj != null)
48 | {
49 | Object toObj = to.eval(env);
50 | if (toObj != null)
51 | {
52 | String fromStr = fromObj.toString();
53 | if (fromStr.isEmpty())
54 | {
55 | // Return original string if nothing to replace from.
56 | retval = str.toString();
57 | }
58 | else
59 | {
60 | retval = str.toString().replace(fromStr, toObj.toString());
61 | }
62 | }
63 | }
64 | }
65 |
66 | return retval;
67 | }
68 |
69 | @Override
70 | public String toString()
71 | {
72 | StringBuilder sb = new StringBuilder("REPLACE(");
73 | sb.append(expr);
74 | sb.append(",");
75 | sb.append(from);
76 | sb.append(",");
77 | sb.append(to);
78 | return sb.toString();
79 | }
80 | @Override
81 | public List usedColumns(Set availableColumns)
82 | {
83 | List result = new LinkedList<>();
84 | result.addAll(expr.usedColumns(availableColumns));
85 | result.addAll(from.usedColumns(availableColumns));
86 | result.addAll(to.usedColumns(availableColumns));
87 | return result;
88 | }
89 | @Override
90 | public List aggregateFunctions()
91 | {
92 | List result = new LinkedList<>();
93 | result.addAll(expr.aggregateFunctions());
94 | result.addAll(from.aggregateFunctions());
95 | result.addAll(to.aggregateFunctions());
96 | return result;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLSecondFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLSecondFunction extends SQLCalendarFunction
24 | {
25 | public SQLSecondFunction(Expression expression)
26 | {
27 | super("SECOND", Calendar.SECOND, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLToArrayFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | CsvJdbc - a JDBC driver for CSV files
3 | Copyright (C) 2023 Peter Fokkinga
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.*;
23 |
24 | public class SQLToArrayFunction extends SQLCoalesceFunction
25 | {
26 |
27 | private HashSet distinctValues;
28 |
29 | public SQLToArrayFunction(boolean isDistinct, List expressions)
30 | {
31 | super(expressions);
32 |
33 | if (isDistinct)
34 | this.distinctValues = new HashSet<>();
35 | }
36 |
37 | @Override
38 | public Object eval(Map env) throws SQLException
39 | {
40 | List values = new ArrayList<>(expressions.size());
41 | if (distinctValues != null)
42 | distinctValues.clear();
43 | for (Expression expr : expressions)
44 | {
45 | Object val = expr.eval(env);
46 | if (distinctValues == null)
47 | {
48 | values.add(val);
49 | }
50 | else if (!distinctValues.contains(val))
51 | {
52 | values.add(val);
53 | distinctValues.add(val);
54 | }
55 | }
56 | StringConverter converter = (StringConverter)env.get(StringConverter.COLUMN_NAME);
57 | CsvStatement statement = (CsvStatement)env.get(CsvStatement.STATEMENT_COLUMN_NAME);
58 | return new SqlArray(values, converter, statement.getConnection());
59 | }
60 |
61 | @Override
62 | public String toString()
63 | {
64 | StringBuilder sb = new StringBuilder("TO_ARRAY(");
65 | if (distinctValues != null)
66 | sb.append("DISTINCT ");
67 |
68 | String delimiter = "";
69 | for (Expression expression : expressions)
70 | {
71 | sb.append(delimiter);
72 | sb.append(expression.toString());
73 | delimiter = ",";
74 | }
75 | sb.append(")");
76 | return sb.toString();
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLToNumberFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2024 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | public class SQLToNumberFunction extends Expression
28 | {
29 | private Expression expr;
30 | private Expression pattern;
31 |
32 | public SQLToNumberFunction(Expression expr, Expression pattern)
33 | {
34 | this.expr = expr;
35 | this.pattern = pattern;
36 | }
37 |
38 | @Override
39 | public Object eval(Map env) throws SQLException
40 | {
41 | Object retval = null;
42 |
43 | Object exprObj = expr.eval(env);
44 | if (exprObj != null)
45 | {
46 | Object patternObj = pattern.eval(env);
47 | if (patternObj != null)
48 | {
49 | Expression stringConverter = new ColumnName(StringConverter.COLUMN_NAME);
50 | StringConverter sc = (StringConverter)stringConverter.eval(env);
51 |
52 | String exprStr = exprObj.toString();
53 | String patternStr = patternObj.toString();
54 | retval = sc.parseNumberPattern(exprStr, patternStr);
55 | }
56 | }
57 |
58 | return retval;
59 | }
60 |
61 | @Override
62 | public String toString()
63 | {
64 | StringBuilder sb = new StringBuilder("TO_NUMBER(");
65 | sb.append(expr);
66 | sb.append(",");
67 | sb.append(pattern);
68 | sb.append(")");
69 | return sb.toString();
70 | }
71 | @Override
72 | public List usedColumns(Set availableColumns)
73 | {
74 | List result = new LinkedList<>();
75 | result.addAll(expr.usedColumns(availableColumns));
76 | result.addAll(pattern.usedColumns(availableColumns));
77 | return result;
78 | }
79 | @Override
80 | public List aggregateFunctions()
81 | {
82 | List result = new LinkedList<>();
83 | result.addAll(expr.aggregateFunctions());
84 | result.addAll(pattern.aggregateFunctions());
85 | return result;
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLUpperFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.LinkedList;
23 | import java.util.List;
24 | import java.util.Map;
25 | import java.util.Set;
26 |
27 | class SQLUpperFunction extends Expression
28 | {
29 | Expression expression;
30 | public SQLUpperFunction(Expression expression)
31 | {
32 | this.expression = expression;
33 | }
34 | @Override
35 | public Object eval(Map env) throws SQLException
36 | {
37 | Object retval = expression.eval(env);
38 | if (retval != null)
39 | retval = retval.toString().toUpperCase();
40 | return retval;
41 | }
42 | @Override
43 | public String toString()
44 | {
45 | return "UPPER("+expression+")";
46 | }
47 | @Override
48 | public List usedColumns(Set availableColumns)
49 | {
50 | List result = new LinkedList<>();
51 | result.addAll(expression.usedColumns(availableColumns));
52 | return result;
53 | }
54 | @Override
55 | public List aggregateFunctions()
56 | {
57 | List result = new LinkedList<>();
58 | result.addAll(expression.aggregateFunctions());
59 | return result;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLVersionFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2024 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.*;
23 |
24 | class SQLVersionFunction extends Expression
25 | {
26 |
27 | private final String version;
28 |
29 | public SQLVersionFunction()
30 | {
31 | this.version = CsvResources.getVersionString();
32 | }
33 |
34 | @Override
35 | public Object eval(Map env) throws SQLException
36 | {
37 | return this.version;
38 | }
39 |
40 | @Override
41 | public String toString()
42 | {
43 | return "VERSION";
44 | }
45 |
46 | @Override
47 | public List usedColumns(Set availableColumns)
48 | {
49 | return List.of();
50 | }
51 |
52 | @Override
53 | public List aggregateFunctions()
54 | {
55 | return List.of();
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SQLYearFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.Calendar;
22 |
23 | class SQLYearFunction extends SQLCalendarFunction
24 | {
25 | public SQLYearFunction(Expression expression)
26 | {
27 | super("YEAR", Calendar.YEAR, expression);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SearchedCaseExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Iterator;
23 | import java.util.LinkedList;
24 | import java.util.List;
25 | import java.util.Map;
26 | import java.util.Set;
27 |
28 | class SearchedCaseExpression extends Expression
29 | {
30 | private List conditions;
31 | private List values;
32 | private Expression elseExpression;
33 |
34 | public SearchedCaseExpression(List conditions,
35 | List values, Expression elseExpression)
36 | {
37 | this.conditions = conditions;
38 | this.values = values;
39 | this.elseExpression = elseExpression;
40 | }
41 |
42 | @Override
43 | public Object eval(Map env) throws SQLException
44 | {
45 | for (int i = 0; i < conditions.size(); i++)
46 | {
47 | Expression condition = conditions.get(i);
48 | if (!(condition instanceof LogicalExpression && condition.isValid()))
49 | {
50 | throw new SQLException(CsvResources.getString("caseNotLogical"));
51 | }
52 | Boolean b = ((LogicalExpression)condition).isTrue(env);
53 | if (b != null && b.booleanValue())
54 | return values.get(i).eval(env);
55 | }
56 | if (elseExpression != null)
57 | return elseExpression.eval(env);
58 |
59 | return null;
60 | }
61 |
62 | @Override
63 | public String toString()
64 | {
65 | StringBuilder sb = new StringBuilder("CASE");
66 | for (int i = 0; i < conditions.size(); i++)
67 | {
68 | Expression condition = conditions.get(i);
69 | sb.append(" WHEN ").append(condition.toString()).append(" THEN ").append(values.get(i));
70 | }
71 | if (elseExpression != null)
72 | sb.append(" ELSE ").append(elseExpression);
73 | sb.append(" END");
74 | return sb.toString();
75 | }
76 |
77 | @Override
78 | public List usedColumns(Set availableColumns)
79 | {
80 | List result = new LinkedList<>();
81 | Iterator it = conditions.iterator();
82 | while (it.hasNext())
83 | {
84 | result.addAll(it.next().usedColumns(availableColumns));
85 | }
86 | it = values.iterator();
87 | while (it.hasNext())
88 | {
89 | result.addAll(it.next().usedColumns(availableColumns));
90 | }
91 | if (elseExpression != null)
92 | result.addAll(elseExpression.usedColumns(availableColumns));
93 | return result;
94 | }
95 |
96 | @Override
97 | public List aggregateFunctions()
98 | {
99 | List result = new LinkedList<>();
100 | Iterator it = conditions.iterator();
101 | while (it.hasNext())
102 | {
103 | result.addAll(it.next().aggregateFunctions());
104 | }
105 | it = values.iterator();
106 | while (it.hasNext())
107 | {
108 | result.addAll(it.next().aggregateFunctions());
109 | }
110 | if (elseExpression != null)
111 | result.addAll(elseExpression.aggregateFunctions());
112 | return result;
113 | }
114 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SimpleCaseExpression.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.Iterator;
23 | import java.util.LinkedList;
24 | import java.util.List;
25 | import java.util.Map;
26 | import java.util.Set;
27 |
28 | class SimpleCaseExpression extends Expression
29 | {
30 | private Expression caseExpression;
31 | private List switches;
32 | private List values;
33 | private Expression elseExpression;
34 |
35 | public SimpleCaseExpression(Expression caseExpression,
36 | List switches, List values, Expression elseExpression)
37 | {
38 | this.caseExpression = caseExpression;
39 | this.switches = switches;
40 | this.values = values;
41 | this.elseExpression = elseExpression;
42 | }
43 |
44 | @Override
45 | public Object eval(Map env) throws SQLException
46 | {
47 | Object o1 = caseExpression.eval(env);
48 | for (int i = 0; i < switches.size(); i++)
49 | {
50 | Expression expr = switches.get(i);
51 | Object o2 = expr.eval(env);
52 | Integer comparison = RelopExpression.compare((Comparable)o1, (Comparable)o2, env);
53 | if (comparison.intValue() == 0)
54 | return values.get(i).eval(env);
55 | }
56 | if (elseExpression != null)
57 | return elseExpression.eval(env);
58 |
59 | return null;
60 | }
61 |
62 | @Override
63 | public String toString()
64 | {
65 | StringBuilder sb = new StringBuilder("CASE ");
66 | sb.append(caseExpression.toString());
67 | for (int i = 0; i < switches.size(); i++)
68 | {
69 | Expression expr = switches.get(i);
70 | sb.append(" WHEN ").append(expr.toString()).append(" THEN ").append(values.get(i));
71 | }
72 | if (elseExpression != null)
73 | sb.append(" ELSE ").append(elseExpression);
74 | sb.append(" END");
75 | return sb.toString();
76 | }
77 |
78 | @Override
79 | public List usedColumns(Set availableColumns)
80 | {
81 | List result = new LinkedList<>();
82 | result.addAll(caseExpression.usedColumns(availableColumns));
83 | Iterator it = switches.iterator();
84 | while (it.hasNext())
85 | {
86 | result.addAll(it.next().usedColumns(availableColumns));
87 | }
88 | it = values.iterator();
89 | while (it.hasNext())
90 | {
91 | result.addAll(it.next().usedColumns(availableColumns));
92 | }
93 | if (elseExpression != null)
94 | result.addAll(elseExpression.usedColumns(availableColumns));
95 | return result;
96 | }
97 |
98 | @Override
99 | public List aggregateFunctions()
100 | {
101 | List result = new LinkedList<>();
102 | Iterator it = switches.iterator();
103 | while (it.hasNext())
104 | {
105 | result.addAll(it.next().aggregateFunctions());
106 | }
107 | it = values.iterator();
108 | while (it.hasNext())
109 | {
110 | result.addAll(it.next().aggregateFunctions());
111 | }
112 | if (elseExpression != null)
113 | result.addAll(elseExpression.aggregateFunctions());
114 | return result;
115 | }
116 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/StringConstant.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2008 Mario Frasca
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.util.List;
22 | import java.util.Map;
23 | import java.util.Set;
24 |
25 | class StringConstant extends Expression
26 | {
27 | String value;
28 | public StringConstant(String s)
29 | {
30 | value = s;
31 | }
32 | @Override
33 | public Object eval(Map env)
34 | {
35 | return value;
36 | }
37 | @Override
38 | public String toString()
39 | {
40 | return "'"+value+"'";
41 | }
42 | @Override
43 | public List usedColumns(Set availableColumns)
44 | {
45 | return List.of();
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SubQueryEqualsRowMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 | import java.util.ArrayList;
23 |
24 | public class SubQueryEqualsRowMatcher implements SubQueryRowMatcher
25 | {
26 | ArrayList values = new ArrayList<>();
27 |
28 | @Override
29 | public boolean matches(Object expr) throws SQLException
30 | {
31 | /*
32 | * For WHERE X = (SELECT ...) type sub-query we expect a
33 | * maximum of one matching row. Stop if we get more than
34 | * one row, so parent/out SQL statement can throw an
35 | * SQLException.
36 | */
37 | values.add(expr);
38 | return values.size() > 1;
39 | }
40 |
41 | public ArrayList getValues()
42 | {
43 | return values;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/SubQueryRowMatcher.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.sql.SQLException;
22 |
23 | public interface SubQueryRowMatcher
24 | {
25 | /**
26 | * Called with value for each row of sub-query, to determine whether outer/parent SQL expression is evaluated.
27 | * @param expr value for current row.
28 | * @return true if value completes SQL sub-query evaluation and sub-query should stop.
29 | * @throws SQLException if there is an error evaluating the expression.
30 | */
31 | boolean matches(Object expr) throws SQLException;
32 | }
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/csv/ZipFileTableReader.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2001 Jonathan Ackerman
4 | * This library is free software; you can redistribute it and/or
5 | * modify it under the terms of the GNU Lesser General Public
6 | * License as published by the Free Software Foundation; either
7 | * version 2.1 of the License, or (at your option) any later version.
8 | * This library is distributed in the hope that it will be useful,
9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 | * Lesser General Public License for more details.
12 | * You should have received a copy of the GNU Lesser General Public
13 | * License along with this library; if not, write to the Free Software
14 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
15 | */
16 | package org.relique.jdbc.csv;
17 |
18 | import java.io.IOException;
19 | import java.io.InputStreamReader;
20 | import java.io.Reader;
21 | import java.sql.Connection;
22 | import java.sql.SQLException;
23 | import java.sql.Statement;
24 | import java.util.Enumeration;
25 | import java.util.List;
26 | import java.util.Vector;
27 | import java.util.zip.ZipEntry;
28 | import java.util.zip.ZipFile;
29 |
30 | import org.relique.io.TableReader;
31 |
32 | /**
33 | * Enables reading CSV files packed in a ZIP file as database tables.
34 | */
35 | public class ZipFileTableReader implements TableReader
36 | {
37 | private String zipFilename;
38 | private ZipFile zipFile;
39 | private String fileExtension;
40 | private String charset;
41 |
42 | public ZipFileTableReader(String zipFilename, String charset) throws IOException
43 | {
44 | this.zipFilename = zipFilename;
45 | this.zipFile = new ZipFile(zipFilename);
46 | this.charset = charset;
47 | }
48 |
49 | public void setExtension(String fileExtension)
50 | {
51 | this.fileExtension = fileExtension;
52 | }
53 |
54 | public String getZipFilename()
55 | {
56 | return zipFilename;
57 | }
58 |
59 | @Override
60 | public Reader getReader(Statement statement, String tableName) throws SQLException
61 | {
62 | try
63 | {
64 | ZipEntry zipEntry = zipFile.getEntry(tableName + fileExtension);
65 | if (zipEntry == null)
66 | throw new SQLException(CsvResources.getString("tableNotFound") + ": " + tableName);
67 |
68 | Reader reader;
69 | if (charset != null)
70 | reader = new InputStreamReader(zipFile.getInputStream(zipEntry), charset);
71 | else
72 | reader = new InputStreamReader(zipFile.getInputStream(zipEntry));
73 | return reader;
74 | }
75 | catch (IOException e)
76 | {
77 | throw new SQLException(e);
78 | }
79 | }
80 |
81 | @Override
82 | public List getTableNames(Connection connection) throws SQLException
83 | {
84 | Vector v = new Vector<>();
85 | Enumeration extends ZipEntry> en = zipFile.entries();
86 | while (en.hasMoreElements())
87 | {
88 | /*
89 | * Strip file extensions.
90 | */
91 | String name = ((ZipEntry)en.nextElement()).getName();
92 | if (name.endsWith(fileExtension))
93 | name = name.substring(0, name.length() - fileExtension.length());
94 | v.add(name);
95 | }
96 | return v;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/org/relique/jdbc/dbf/DbfClassNotFoundException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2015 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.dbf;
20 |
21 | import java.sql.SQLException;
22 |
23 | public class DbfClassNotFoundException extends SQLException
24 | {
25 | public DbfClassNotFoundException(String reason)
26 | {
27 | super(reason);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/main/resources/META-INF/services/java.sql.Driver:
--------------------------------------------------------------------------------
1 | org.relique.jdbc.csv.CsvDriver
2 |
--------------------------------------------------------------------------------
/src/test/java/org/relique/jdbc/csv/RunSuite.java:
--------------------------------------------------------------------------------
1 | /*
2 | CsvJdbc - a JDBC driver for CSV files
3 | Copyright (C) 2001 Jonathan Ackerman
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import org.junit.platform.suite.api.SelectClasses;
22 | import org.junit.platform.suite.api.Suite;
23 |
24 | @Suite
25 | @SelectClasses({
26 | TestSqlParser.class,
27 | TestCsvDriver.class,
28 | TestDbfDriver.class,
29 | TestScrollableDriver.class,
30 | TestFileSetInputStream.class,
31 | TestJoinedTables.class,
32 | TestCryptoFilter.class,
33 | TestPrepareStatement.class,
34 | TestStringConverter.class,
35 | TestZipFiles.class,
36 | TestAggregateFunctions.class,
37 | TestArrayFunctions.class,
38 | TestRandomFunction.class,
39 | TestToNumberFunction.class,
40 | TestVersionFunction.class,
41 | TestOrderBy.class,
42 | TestGroupBy.class,
43 | TestLimitOffset.class,
44 | TestLineNumber.class,
45 | TestFixedWidthFiles.class,
46 | TestDoubleQuoting.class,
47 | TestSubQuery.class,
48 | TestClasspathResources.class,
49 | TestTime.class
50 | })
51 |
52 | /**
53 | * Junit5 test suite for the CsvJdbc driver.
54 | *
55 | * @author Jonathan Ackerman
56 | */
57 | public class RunSuite
58 | {
59 | }
60 |
--------------------------------------------------------------------------------
/src/test/java/org/relique/jdbc/csv/TableReaderTester.java:
--------------------------------------------------------------------------------
1 | /*
2 | * CsvJdbc - a JDBC driver for CSV files
3 | * Copyright (C) 2013 Simon Chenery
4 | *
5 | * This library is free software; you can redistribute it and/or
6 | * modify it under the terms of the GNU Lesser General Public
7 | * License as published by the Free Software Foundation; either
8 | * version 2.1 of the License, or (at your option) any later version.
9 | *
10 | * This library is distributed in the hope that it will be useful,
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * Lesser General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU Lesser General Public
16 | * License along with this library; if not, write to the Free Software
17 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import java.io.Reader;
22 | import java.io.StringReader;
23 | import java.sql.Connection;
24 | import java.sql.SQLException;
25 | import java.sql.Statement;
26 | import java.util.List;
27 |
28 | import org.relique.io.TableReader;
29 |
30 | /**
31 | * Class for testing TableReader functionality that enables user to provide the
32 | * database tables from a Java class.
33 | */
34 | public class TableReaderTester implements TableReader
35 | {
36 | @Override
37 | public Reader getReader(Statement statement, String tableName) throws SQLException
38 | {
39 | if (tableName.equalsIgnoreCase("AIRLINE"))
40 | return new StringReader("CODE,NAME\nLH,Lufthansa\nBA,British Airways\nAF,Air France\n");
41 | else if (tableName.equalsIgnoreCase("AIRPORT"))
42 | return new StringReader("CODE,NAME\nFRA,Frankfurt\nLHR,London Heathrow\nCDG,Paris Charles De Gaulle");
43 | throw new SQLException("Table does not exist: " + tableName);
44 | }
45 |
46 | @Override
47 | public List getTableNames(Connection connection) throws SQLException
48 | {
49 | return List.of("AIRLINE", "AIRPORT");
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/test/java/org/relique/jdbc/csv/TestTime.java:
--------------------------------------------------------------------------------
1 | /*
2 | CsvJdbc - a JDBC driver for CSV files
3 | Copyright (C) 2024 Simon Chenery
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import static org.junit.jupiter.api.Assertions.assertEquals;
22 | import static org.junit.jupiter.api.Assertions.assertTrue;
23 | import static org.junit.jupiter.api.Assertions.fail;
24 |
25 | import java.io.File;
26 | import java.sql.Connection;
27 | import java.sql.DriverManager;
28 | import java.sql.ResultSet;
29 | import java.sql.SQLException;
30 | import java.sql.Statement;
31 | import java.sql.Time;
32 | import java.time.LocalTime;
33 | import java.util.Properties;
34 |
35 | import org.junit.jupiter.api.BeforeAll;
36 | import org.junit.jupiter.api.Test;
37 |
38 | /**
39 | * This class tests columns with type TIME and arithmetic using these columns.
40 | */
41 | public class TestTime
42 | {
43 | private static String filePath;
44 |
45 | @BeforeAll
46 | public static void setUp()
47 | {
48 | filePath = ".." + File.separator + "src" + File.separator + "testdata";
49 | if (!new File(filePath).isDirectory())
50 | filePath = "src" + File.separator + "testdata";
51 | assertTrue(new File(filePath).isDirectory(), "Sample files directory not found: " + filePath);
52 |
53 | // load CSV driver
54 | try
55 | {
56 | Class.forName("org.relique.jdbc.csv.CsvDriver");
57 | }
58 | catch (ClassNotFoundException e)
59 | {
60 | fail("Driver is not in the CLASSPATH -> " + e);
61 | }
62 | }
63 |
64 | @Test
65 | public void testTimePlusMinusNumber() throws SQLException
66 | {
67 | Properties props = new Properties();
68 | props.put("columnTypes", "String,Date,Time,Date,Time,String,String,String");
69 |
70 | try (Connection conn = DriverManager.getConnection("jdbc:relique:csv:" + filePath, props);
71 |
72 | Statement stmt = conn.createStatement();
73 |
74 | ResultSet results = stmt
75 | .executeQuery("SELECT Start_time, Start_time + 3600000, Start_time - 1000 FROM calendar"))
76 | {
77 | assertTrue(results.next());
78 | Time expectedTime1 = Time.valueOf(LocalTime.of(9, 0, 0));
79 | assertEquals(expectedTime1, results.getTime(1));
80 | Time expectedTime2 = Time.valueOf(LocalTime.of(9 + 1, 0, 0));
81 | assertEquals(expectedTime2, results.getTime(2));
82 | Time expectedTime3 = Time.valueOf(LocalTime.of(8, 59, 59));
83 | assertEquals(expectedTime3, results.getTime(3));
84 | }
85 | }
86 |
87 | @Test
88 | public void testTimeMinusTime() throws SQLException
89 | {
90 | Properties props = new Properties();
91 | props.put("columnTypes", "String,Date,Time,Date,Time,String,String,String");
92 | props.put("useDateTimeFormatter", "true");
93 |
94 | try (Connection conn = DriverManager.getConnection("jdbc:relique:csv:" + filePath, props);
95 |
96 | Statement stmt = conn.createStatement();
97 |
98 | ResultSet results = stmt
99 | .executeQuery("SELECT End_time - Start_time FROM calendar"))
100 | {
101 | assertTrue(results.next());
102 | long expectedDifference = 3 * 3600 * 1000;
103 | assertEquals(expectedDifference, results.getLong(1));
104 | }
105 | }
106 | }
107 |
--------------------------------------------------------------------------------
/src/test/java/org/relique/jdbc/csv/TestVersionFunction.java:
--------------------------------------------------------------------------------
1 | /*
2 | CsvJdbc - a JDBC driver for CSV files
3 | Copyright (C) 2024 Simon Chenery
4 |
5 | This library is free software; you can redistribute it and/or
6 | modify it under the terms of the GNU Lesser General Public
7 | License as published by the Free Software Foundation; either
8 | version 2.1 of the License, or (at your option) any later version.
9 |
10 | This library is distributed in the hope that it will be useful,
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | Lesser General Public License for more details.
14 |
15 | You should have received a copy of the GNU Lesser General Public
16 | License along with this library; if not, write to the Free Software
17 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18 | */
19 | package org.relique.jdbc.csv;
20 |
21 | import org.junit.jupiter.api.BeforeAll;
22 | import org.junit.jupiter.api.Test;
23 |
24 | import java.io.File;
25 | import java.sql.*;
26 | import java.util.ArrayList;
27 | import java.util.HashSet;
28 | import java.util.Properties;
29 | import java.util.regex.Matcher;
30 | import java.util.regex.Pattern;
31 |
32 | import static org.junit.jupiter.api.Assertions.*;
33 |
34 | public class TestVersionFunction
35 | {
36 | public static String filePath;
37 |
38 | @BeforeAll
39 | public static void setUp()
40 | {
41 | filePath = ".." + File.separator + "src" + File.separator + "testdata";
42 | if (!new File(filePath).isDirectory())
43 | filePath = "src" + File.separator + "testdata";
44 | assertTrue(new File(filePath).isDirectory(), "Sample files directory not found: " + filePath);
45 |
46 | // load CSV driver
47 | try
48 | {
49 | Class.forName("org.relique.jdbc.csv.CsvDriver");
50 | }
51 | catch (ClassNotFoundException e)
52 | {
53 | fail("Driver is not in the CLASSPATH -> " + e);
54 | }
55 | }
56 |
57 | @Test
58 | public void testVersionFunction() throws SQLException
59 | {
60 | try (Connection conn = DriverManager.getConnection("jdbc:relique:csv:" + filePath);
61 | Statement stmt = conn.createStatement();
62 | ResultSet results = stmt.executeQuery("SELECT VERSION()"))
63 | {
64 | assertTrue(results.next());
65 | String version = results.getString(1);
66 | assertEquals(version, conn.getMetaData().getDriverVersion());
67 |
68 | Pattern semverPattern = Pattern.compile("^(\\d+\\.\\d+|\\d+\\.\\d+\\.\\d+)(?:-SNAPSHOT)?$");
69 | assertTrue(semverPattern.asMatchPredicate().test(version),
70 | "Version is not valid semver version: "+version);
71 |
72 | int major = conn.getMetaData().getDriverMajorVersion();
73 | int minor = conn.getMetaData().getDriverMinorVersion();
74 |
75 | assertTrue(version.startsWith(major+"."+minor),
76 | "Driver version '"+major+"."+minor+"' does not match "+version);
77 | }
78 | }
79 |
80 | }
81 |
--------------------------------------------------------------------------------
/src/test/resources/testdata/encodings/iso8859-1.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/test/resources/testdata/encodings/iso8859-1.txt
--------------------------------------------------------------------------------
/src/test/resources/testdata/encodings/utf-16.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/test/resources/testdata/encodings/utf-16.txt
--------------------------------------------------------------------------------
/src/test/resources/testdata/encodings/utf-8.txt:
--------------------------------------------------------------------------------
1 | LABEL
2 | KØBENHAVN
3 | 100°
4 | © Copyright
5 |
--------------------------------------------------------------------------------
/src/test/resources/testdata/olympic-medals/medals2004.csv:
--------------------------------------------------------------------------------
1 | YEAR,COUNTRY,CODE,GOLD,SILVER,BRONZE
2 | 2004,United States,USA,36,39,28
3 | 2004,China,CHN,32,17,14
4 | 2004,Russia,RUS,28,26,38
5 | 2004,Australia,AUS,17,16,16
6 | 2004,Japan,JPN,16,9,12
7 | 2004,Germany,GER,13,16,20
8 | 2004,France,FRA,11,9,13
9 | 2004,Italy,ITA,10,11,11
10 | 2004,South Korea,KOR,9,12,9
11 | 2004,Great Britain,GBR,9,9,13
12 |
--------------------------------------------------------------------------------
/src/test/resources/testdata/olympic-medals/medals2008.csv:
--------------------------------------------------------------------------------
1 | YEAR,COUNTRY,CODE,GOLD,SILVER,BRONZE
2 | 2008,China,CHN,51,21,28
3 | 2008,United States,USA,36,38,36
4 | 2008,Russia,RUS,23,21,29
5 | 2008,Great Britain,GBR,19,13,15
6 | 2008,Germany,GER,16,10,15
7 | 2008,Australia,AUS,14,15,17
8 | 2008,South Korea,KOR,13,10,8
9 | 2008,Japan,JPN,9,6,10
10 | 2008,Italy,ITA,8,9,10
11 | 2008,France,FRA,7,16,18
12 |
--------------------------------------------------------------------------------
/src/testdata/C D.csv:
--------------------------------------------------------------------------------
1 | A,B,[A],A-B,A B
2 | 1,2,3,4,5
3 | 6,7,8,9,10
4 |
--------------------------------------------------------------------------------
/src/testdata/Hutchenson_011020182.txt:
--------------------------------------------------------------------------------
1 | Col1,Col2
2 | "1
3 | value spread across multiple lines",one
4 | "2 value on single a line","two"
5 | "3
6 | 3
7 | value spread across three lines",three
8 | "4 value containing ""quotes""",four
9 |
--------------------------------------------------------------------------------
/src/testdata/Purchase.csv:
--------------------------------------------------------------------------------
1 | AccountNo,CampaignNo,PurchaseCt,PurchaseDate,PurchaseTime
2 | 19685,21,1,1/9/2013,11:23:01
3 | 58375,21,3,1/11/2013,14:07:33
4 | 34625,1,4,1/15/2013,11:44:37
5 | 34771,1,4,1/15/2013,12:01:19
6 | 51002,1,1,1/16/2013,09:11:23
7 | 22021,61,4,1/17/2013,10:10:06
8 | 23103,1,11,1/17/2013,15:53:30
9 |
--------------------------------------------------------------------------------
/src/testdata/arrays_sample.csv:
--------------------------------------------------------------------------------
1 | name,role_1,role_2,role_id_1,role_id_2
2 | alice,teacher,grader,31,76
3 | bob,,admin,,1
4 | eve,teacher,teacher,31,31
5 | eve,,teacher,,31
6 |
--------------------------------------------------------------------------------
/src/testdata/bad_values.csv:
--------------------------------------------------------------------------------
1 | ID,NAME,START_DATE,START_TIME
2 | ?,Simon,????-??-??,??:??:??
3 | ,Wally,,
4 | 3,Alfie,2000-01-01,09:00:00
5 |
--------------------------------------------------------------------------------
/src/testdata/badquoted.csv:
--------------------------------------------------------------------------------
1 | F1;F2;F3
2 | 010;"Rechtsform unbekannt";1
3 | 012;"Rechtsform
4 | unbekannt";2
5 | 013;"Rechtsform unbekannt";3
6 | 014;"Rechtsform
7 |
--------------------------------------------------------------------------------
/src/testdata/banks.txt:
--------------------------------------------------------------------------------
1 | # Bank identification numbers (Bankleitzahlen) from bundesbank.de
2 | 10000000,"Bundesbank (Berlin)"
3 | 10010010,"Postbank (Berlin)"
4 | 10010111,"SEB (Berlin)"
5 | 10010222,"The Royal Bank of Scotland, Niederlassung Deutschland (Berlin)"
6 | 10010424,"Aareal Bank (Berlin)"
7 | 10019610,"Dexia Kommunalbank Deutschland (Berlin)"
8 | 10020000,"Berliner Bank -alt- (Berlin)"
9 | 10020200,"BHF-BANK (Berlin)"
10 | 10020400,"Citadele Bank Zndl Deutschland (München)"
11 | 10020500,"Bank für Sozialwirtschaft (Berlin)"
12 |
--------------------------------------------------------------------------------
/src/testdata/bool.csv:
--------------------------------------------------------------------------------
1 | I,J,K,L
2 | 0,1,AAA,true
3 | 1,2,COM,false
4 |
--------------------------------------------------------------------------------
/src/testdata/calendar.csv:
--------------------------------------------------------------------------------
1 | Subject,Start_Date,Start_Time,End_Date,End_Time,All_Day_Event,Description,Location
2 | Networks,2021-10-04,09:00:00,2021-10-04,12:00:00,False,NA,Blackwood HS
3 | Q&A,2021-10-04,13:00:00,2021-10-04,15:30:00,False,NA,Blackwood HS
4 |
--------------------------------------------------------------------------------
/src/testdata/currency-exchange-rates-fixed.txt:
--------------------------------------------------------------------------------
1 | Country CurrencyISO YESTERDYTODAY_ % Change
2 | GERMANY Euro EUR 0.7616450.7632460.002102
3 | GREECE Euro EUR 0.7616450.7632460.002102
4 | HONG KONG Dollar HKD 7.7599137.7615650.000213
5 | HUNGARY Forint HUF 226.1222226.67130.002429
6 | ICELAND Krona ISK 126.9465127.10940.001283
7 | INDIA Rupee INR 51.4632951.79421 0.00643
8 | INTNL MON. FUND SDR XDR 0.6482810.6496960.002183
9 | IRELAND Euro EUR 0.7616450.7632460.002102
10 | ISRAEL Sheqel ILS 3.754363 3.762920.002279
11 | ITALY Euro EUR 0.7616450.7632460.002102
12 | JAPAN Yen JPY 80.6580281.371980.008852
13 | KOREA (SOUTH) Won KRW 1137.8081138.5540.000656
14 | KUWAIT Dinar KWD 0.2781180.278118 0
15 | MEXICO Peso MXN 13.1032213.137330.002603
16 | NETHERLANDS Euro EUR 0.7616450.7632460.002102
17 | NEW ZEALAND Dollar NZD 1.2176591.2239170.005139
18 | NORWAY Krone NOK 5.745243 5.762320.002972
19 | PAKISTAN Rupee PKR 90.7503390.74667-0.00004
20 | PERU Sol PEN 2.6618362.661836 0
21 | PHILIPPINES Peso PHP 42.6512542.63851 -0.0003
22 | POLAND Zloty PLN 3.1841963.1914640.002283
23 | PORTUGAL Euro EUR 0.7616450.7632460.002102
24 | ROMANIA Leu RON 3.3249163.324916 0
25 | RUSSIA Ruble RUB 29.5512529.52079-0.00103
26 | SAUDI ARABIA Riyal SAR 3.7504133.750361-1.4E-05
27 | SINGAPORE Dollar SGD 1.2488331.2510090.001742
28 | SLOVAKIA Euro EUR 0.7616450.7632460.002102
29 | SOUTH AFRICA Rand ZAR 7.8049317.8226710.002273
30 | SPAIN Euro EUR 0.7616450.7632460.002102
31 | SWEDEN Krona SEK 6.76557 6.752711 -0.0019
32 | SWITZERLAND Franc CHF 0.9153470.9178320.002715
33 | TAIWAN Dollar TWD 29.5072829.52026 0.00044
34 | THAILAND Baht THB 30.80298 30.8649 0.00201
35 | U.A.E. Dirham AED 3.6729943.672994 0
36 | UKRAINE Hryvnia UAH 8.0028098.0040550.000156
37 | UNITED KINGDOM Pound GBP 0.62723 0.625089-0.00341
38 | UNITED STATES Dollar USD 1 1 0
39 |
--------------------------------------------------------------------------------
/src/testdata/d.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/d.dbf
--------------------------------------------------------------------------------
/src/testdata/defectiveheader.csv:
--------------------------------------------------------------------------------
1 | IDX,,,COMMENT,
2 | 178,AAX,ED+,NONE,T
3 |
--------------------------------------------------------------------------------
/src/testdata/doublequoted.csv:
--------------------------------------------------------------------------------
1 | F1;F2;F3;F4;F5;F6;F7;F8;F9;F10;F11;F12
2 | 010;00000000027;0000000000;Rechtsform unbekannt ;RUM ;Simulation ;O ;Nein ;Nein ;"Rechtsform unbekannt" entsteht durch die Simulation zTELKUS. Es werden Simulationsregeln angewandt.;1;
3 | 'doubling \"\"quotechar';F2;F3;F4;F5;F6;F7;F8;F9;F10;F11;F12
4 | 'escaping quotechar\"';;;;F5;F6;F7;F8;F9;F10;F11;F12
5 | 'doubling ''quotechar';F2;F3;F4;F5;F6;F7;F8;F9;F10;F11;F12
6 | 'escaping quotechar'';;;;F5;F6;F7;F8;F9;F10;F11;F12
7 |
--------------------------------------------------------------------------------
/src/testdata/duplicate_headers.csv:
--------------------------------------------------------------------------------
1 | ID,ID,Name,Name
2 | 1,2,george,joe
3 | 2,2,aworth,smith
--------------------------------------------------------------------------------
/src/testdata/embassies.txt:
--------------------------------------------------------------------------------
1 | "Germany","Wallstrasse 76-79,
2 | 10179 Berlin"
3 | "United Kingdom","Australia House
4 | Strand
5 | London WC2B 4LA"
6 |
--------------------------------------------------------------------------------
/src/testdata/empty-1.txt:
--------------------------------------------------------------------------------
1 | ID,NAME,EXTRA_FIELD
2 | A123,Jonathan Ackerman,A
3 |
--------------------------------------------------------------------------------
/src/testdata/empty-2.txt:
--------------------------------------------------------------------------------
1 | ID,NAME,EXTRA_FIELD
--------------------------------------------------------------------------------
/src/testdata/empty-3.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/empty-3.txt
--------------------------------------------------------------------------------
/src/testdata/empty-glued.txt:
--------------------------------------------------------------------------------
1 | ID,NAME,EXTRA_FIELD,EMPTY_ID
2 | A123,Jonathan Ackerman,A,1
3 |
--------------------------------------------------------------------------------
/src/testdata/encodings.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/encodings.zip
--------------------------------------------------------------------------------
/src/testdata/escape.csv:
--------------------------------------------------------------------------------
1 | ID
2 | index_1
3 | index22
4 | index_2
5 | index%%
6 | index%3
7 | index_3
8 |
--------------------------------------------------------------------------------
/src/testdata/events.csv:
--------------------------------------------------------------------------------
1 | start_date,duration,description
2 | 2023-01-01,365,"centenary year"
3 | 2023-03-01,31,"book month"
4 |
--------------------------------------------------------------------------------
/src/testdata/evonix.csv:
--------------------------------------------------------------------------------
1 | rem I am a comment
2 | rem Another comment
3 | ID#@Name#@Birthday
4 | 0#@(Florian)#@01.01.1990
5 | 1#@(Tobias)#@01.01.1990
6 | 2#@(#Mark)#@01.01.1990
7 | 3#@(@Jason)#@01.01.1990
8 | 4#@"Robert"#@01.01.1990
9 |
--------------------------------------------------------------------------------
/src/testdata/flights.txt:
--------------------------------------------------------------------------------
1 | FLIGHTDESTINATION SCHEESTITGATS
2 | LH1096Toulouse 1150 1A18C
3 | DE6474Fuerteventura 1215 1B2 D
4 | MH005 Kuala Lumpur 1230 2D4 D
5 | LH252 Milan-Malpensa124013201A22C
6 |
--------------------------------------------------------------------------------
/src/testdata/foodstuffs.csv:
--------------------------------------------------------------------------------
1 | "key", "value"
2 | "orange", "fruit"
3 | "apple","fruit"
4 | "corn", "vegetable"
5 | "lemon" , "fruit"
6 | tomato, who knows?
7 | " - " , " - "
8 |
--------------------------------------------------------------------------------
/src/testdata/fox_samp.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/fox_samp.dbf
--------------------------------------------------------------------------------
/src/testdata/headerless-001-20081112.txt:
--------------------------------------------------------------------------------
1 | 20-12-2007,10:59:00,007,0.0,26.54
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 |
--------------------------------------------------------------------------------
/src/testdata/headerless-002-20081112.txt:
--------------------------------------------------------------------------------
1 | 20-12-2007,10:59:00,007,0.0,26.54
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 |
--------------------------------------------------------------------------------
/src/testdata/headerless-003-20081112.txt:
--------------------------------------------------------------------------------
1 | 20-12-2007,10:59:00,007,0.0,26.54
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 |
--------------------------------------------------------------------------------
/src/testdata/headerless-004-20081112.txt:
--------------------------------------------------------------------------------
1 | 20-12-2007,10:59:00,007,0.0,26.54
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 |
--------------------------------------------------------------------------------
/src/testdata/headerless-glued-leading.txt:
--------------------------------------------------------------------------------
1 | 001,20081112,20-12-2007,10:59:00,007,0.0,26.54
2 | 001,20081112,20-12-2007,11:14:00,007,0.0,0.0
3 | 001,20081112,20-12-2007,11:29:00,007,0.0,0.0
4 | 001,20081112,20-12-2007,11:44:00,007,26.54,0.0
5 | 001,20081112,20-12-2007,11:59:00,007,0.0,22.99
6 | 001,20081112,20-12-2007,12:14:00,007,25.72,0.0
7 | 001,20081112,20-12-2007,12:29:00,007,0.0,0.0
8 | 001,20081112,20-12-2007,12:44:00,007,0.0,25.45
9 | 001,20081112,20-12-2007,12:59:00,007,26.27,0.0
10 | 001,20081112,20-12-2007,13:14:00,007,0.0,0.0
11 | 001,20081112,20-12-2007,13:29:00,007,0.0,0.0
12 | 001,20081112,20-12-2007,13:44:00,007,25.45,0.0
13 | 002,20081112,20-12-2007,10:59:00,007,0.0,26.54
14 | 002,20081112,20-12-2007,11:14:00,007,0.0,0.0
15 | 002,20081112,20-12-2007,11:29:00,007,0.0,0.0
16 | 002,20081112,20-12-2007,11:44:00,007,26.54,0.0
17 | 002,20081112,20-12-2007,11:59:00,007,0.0,22.99
18 | 002,20081112,20-12-2007,12:14:00,007,25.72,0.0
19 | 002,20081112,20-12-2007,12:29:00,007,0.0,0.0
20 | 002,20081112,20-12-2007,12:44:00,007,0.0,25.45
21 | 002,20081112,20-12-2007,12:59:00,007,26.27,0.0
22 | 002,20081112,20-12-2007,13:14:00,007,0.0,0.0
23 | 002,20081112,20-12-2007,13:29:00,007,0.0,0.0
24 | 002,20081112,20-12-2007,13:44:00,007,25.45,0.0
25 | 003,20081112,20-12-2007,10:59:00,007,0.0,26.54
26 | 003,20081112,20-12-2007,11:14:00,007,0.0,0.0
27 | 003,20081112,20-12-2007,11:29:00,007,0.0,0.0
28 | 003,20081112,20-12-2007,11:44:00,007,26.54,0.0
29 | 003,20081112,20-12-2007,11:59:00,007,0.0,22.99
30 | 003,20081112,20-12-2007,12:14:00,007,25.72,0.0
31 | 003,20081112,20-12-2007,12:29:00,007,0.0,0.0
32 | 003,20081112,20-12-2007,12:44:00,007,0.0,25.45
33 | 003,20081112,20-12-2007,12:59:00,007,26.27,0.0
34 | 003,20081112,20-12-2007,13:14:00,007,0.0,0.0
35 | 003,20081112,20-12-2007,13:29:00,007,0.0,0.0
36 | 003,20081112,20-12-2007,13:44:00,007,25.45,0.0
37 | 004,20081112,20-12-2007,10:59:00,007,0.0,26.54
38 | 004,20081112,20-12-2007,11:14:00,007,0.0,0.0
39 | 004,20081112,20-12-2007,11:29:00,007,0.0,0.0
40 | 004,20081112,20-12-2007,11:44:00,007,26.54,0.0
41 | 004,20081112,20-12-2007,11:59:00,007,0.0,22.99
42 | 004,20081112,20-12-2007,12:14:00,007,25.72,0.0
43 | 004,20081112,20-12-2007,12:29:00,007,0.0,0.0
44 | 004,20081112,20-12-2007,12:44:00,007,0.0,25.45
45 | 004,20081112,20-12-2007,12:59:00,007,26.27,0.0
46 | 004,20081112,20-12-2007,13:14:00,007,0.0,0.0
47 | 004,20081112,20-12-2007,13:29:00,007,0.0,0.0
48 | 004,20081112,20-12-2007,13:44:00,007,25.45,0.0
49 |
--------------------------------------------------------------------------------
/src/testdata/hotel.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/hotel.dbf
--------------------------------------------------------------------------------
/src/testdata/jo.txt:
--------------------------------------------------------------------------------
1 | RC UFI UNI LAT LONG DMS_LAT DMS_LONG MGRS JOG FC DSG PC CC1 ADM1 ADM2 POP ELEV CC2 NT LC SHORT_FORM GENERIC SORT_NAME FULL_NAME FULL_NAME_ND MODIFY_DATE
2 | 3 -3097420 6485621 29.3475 35.110833 292051 350639 36RYT0492848337 NH36-12 T HLL JO 00 NS ara جبلالمبرك جَبَل اَلْمَبْرَك جبل المبرك 2006-06-30
3 | 3 -971151 -1442236 30.966667 35.7 305800 354200 36RYV5789329036 NH36-08 T MT JO 09 V JEBELDHIKRETTANNURA Jebel Dhikr et Tannura Jebel Dhikr et Tannura 1993-12-23
4 | 3 -971144 -1442222 32.633333 36.016667 323800 360100 37SBS2010914571 NI37-13 T HLL JO 00 JO N ara TALLDHAYL Tall Dhayl Tall Dhayl 1994-04-29
5 | 3 -971134 -1442187 32.05 35.533333 320300 353200 36SYA3919148785 NI36-16 T TRR JO 02 V ZORDEIRSHAMAN Zor Deir Shāmān Zor Deir Shaman 1993-12-23
6 |
--------------------------------------------------------------------------------
/src/testdata/nikesh.csv:
--------------------------------------------------------------------------------
1 | N,Message
2 | 1,"100 SSL Error"
3 | 2,"200 SSL
4 | Error"
5 | 3,"300 DNS Error"
6 | 4,"400 SSL Error"
7 |
--------------------------------------------------------------------------------
/src/testdata/nodata.txt:
--------------------------------------------------------------------------------
1 | #only_header
2 | Aleph,Beth,Ghimel,Daleth
--------------------------------------------------------------------------------
/src/testdata/numbers_de.csv:
--------------------------------------------------------------------------------
1 | N
2 | 3
3 | 1.234,56
4 | (45.678,90)
5 | 045,678
6 |
--------------------------------------------------------------------------------
/src/testdata/numeric.csv:
--------------------------------------------------------------------------------
1 | C1,C2,C3,C4,C5,C6,C7
2 | 99,-1010,300100,-4400,3.14,2.94e+12,8.65e-6
3 | -22,15,2147483647,990000000000,0.0,-0,10
4 |
--------------------------------------------------------------------------------
/src/testdata/olympic-medals.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/olympic-medals.zip
--------------------------------------------------------------------------------
/src/testdata/only_comments.txt:
--------------------------------------------------------------------------------
1 | # Source CIA World Factbook
2 | # https://www.cia.gov/library/publications/the-world-factbook/
3 |
--------------------------------------------------------------------------------
/src/testdata/petr-333-444.csv:
--------------------------------------------------------------------------------
1 | column1,column2
2 | abc,def
3 | ghi,jkl
--------------------------------------------------------------------------------
/src/testdata/petr-555-666.csv:
--------------------------------------------------------------------------------
1 | column1,column2
2 | mno,qrs
3 | tuv,wxy
--------------------------------------------------------------------------------
/src/testdata/recording-2015-06-28.log:
--------------------------------------------------------------------------------
1 | c1:c2:c3:c4
2 | 2015-01-01:start
3 | 2015-01-02:new:event
4 | 2015-01-03:repeat:previous:100
5 |
--------------------------------------------------------------------------------
/src/testdata/sample:
--------------------------------------------------------------------------------
1 | ID;NAME;EXTRA_FIELD
2 | Q123;"""S;""";F
3 | A123;Jonathan Ackerman;A
4 | B234;Grady O'Neil;B
5 | C456;"Susan; Peter and Dave";C
6 | D789;"Amelia ""meals"" Maurice";E
7 | X234;"Peter ""peg leg""; Jimmy & Samantha ""Sam""";G
8 | J371;Mackie Messer;34.1
9 | J739;Polly Peachum;30,5
10 |
--------------------------------------------------------------------------------
/src/testdata/sample.csv:
--------------------------------------------------------------------------------
1 | ID,NAME,EXTRA_FIELD
2 | Q123,"""S,""",F
3 | A123,Jonathan Ackerman,A
4 | B234,Grady O'Neil,B
5 | C456,"Susan, Peter and Dave",C
6 | D789,"Amelia ""meals"" Maurice",E
7 | X234,"Peter ""peg leg"", Jimmy & Samantha ""Sam""",G
--------------------------------------------------------------------------------
/src/testdata/sample.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/sample.dbf
--------------------------------------------------------------------------------
/src/testdata/sample.txt:
--------------------------------------------------------------------------------
1 | ID;NAME;EXTRA_FIELD
2 | Q123;"""S;""";F
3 | A123;Jonathan Ackerman;A
4 | B234;Grady O'Neil;B
5 | C456;"Susan; Peter and Dave";C
6 | D789;"Amelia ""meals"" Maurice";E
7 | X234;"Peter ""peg leg""; Jimmy & Samantha ""Sam""";G
--------------------------------------------------------------------------------
/src/testdata/sample2.csv:
--------------------------------------------------------------------------------
1 | ID,Name
2 | A123,Aman
3 | B223,Binoy
4 | C334,Chetan
5 | D456,"Dilip ""meals"" Maurice
6 | ~In New LIne~
7 | Done"
8 | E589,"""Elephant"""
9 | F634,"Fandu """"peg leg"""", Jimmy & Samantha
10 | ~In Another New LIne~
11 | """"Sam"""""
12 |
--------------------------------------------------------------------------------
/src/testdata/sample3.csv:
--------------------------------------------------------------------------------
1 | "column 1","column ""2"" two",Column 3,CoLuMn4,COLumn5
2 | 1,2,3,4,5
--------------------------------------------------------------------------------
/src/testdata/sample4.csv:
--------------------------------------------------------------------------------
1 | ID,Name,Job
2 | 01,Juan Pablo Morales,Project Manager
3 | 02,Mauricio Hernandez,Project Manager
4 | 03,Maria Cristina Lucero,Finance Manager
5 | 04,Felipe Grajales,Project Manager
--------------------------------------------------------------------------------
/src/testdata/sample5.csv:
--------------------------------------------------------------------------------
1 | ID,Name,Job,Start,timeoffset
2 | 41,Juan Pablo Montoya,Piloto,2001-04-02 12:30:00,1230
3 | 01,Juan Pablo Morales,Project Manager,2001-01-02 12:30:00,1235
4 | 02,Mauricio Hernandez,Finance Manager,2002-02-02 12:30:00,1240
5 | 03,Maria Cristina Lucero,Project Manager,2003-03-02 12:30:00,1245
6 | 04,Felipe Grajales,Project Manager,2004-04-02 12:30:00,0100
7 | 05,Melquisedec Rojas Castillo,Office Manager,2004-04-02 12:30:00,100
8 | 06,Sandra María Rosales Ceballos,Office Employee,2004-04-02 12:30:00, 100
9 | 07,Lucía Carolina Ortega Costa,Office Employee,2004-04-02 12:30:00, 0
10 | 08,Érica Jeanine Méndez Méndez,Office Employee,2004-04-02 12:30:00, 10
11 | 09,María Luisa Franco Fernández,Office Employee,2004-04-02 12:30:00,123
--------------------------------------------------------------------------------
/src/testdata/sample8.csv:
--------------------------------------------------------------------------------
1 | ID,Name,d,t
2 | 01,Juan Pablo Morales,2010-01-02,01:30:00
3 | 02,Mauricio Hernandez,2010-02-02,01:30:00
4 | 03,Maria Cristina Lucero,2010-03-28,01:30:00
5 | 06,Angela Martines Alife,2010-03-28,05:30:00
6 | 04,Felipe Grajales Alterpater,2009-10-25,01:30:00
7 | 05,Melquisedec Rojas Castillo,2009-10-25,05:30:00
8 |
--------------------------------------------------------------------------------
/src/testdata/scores.csv:
--------------------------------------------------------------------------------
1 | NAME,SCORE
2 | Daniel,68
3 | Mark,79
4 | Maria,47
5 | Daniel,82
6 | Mark,77
7 | Maria,NA
8 | Daniel,NA
9 | Mark,74
10 | Maria,NA
11 |
--------------------------------------------------------------------------------
/src/testdata/scrambled.txt:
--------------------------------------------------------------------------------
1 | YAyPB*SKzRK
--------------------------------------------------------------------------------
/src/testdata/scrambled_trailing.txt:
--------------------------------------------------------------------------------
1 | YAyPB*kU^
kTM*|
--------------------------------------------------------------------------------
/src/testdata/single-char-cols-fixed.txt:
--------------------------------------------------------------------------------
1 | TwoChars,OneChar,ThreeChars,YetAnotherOneChar
2 | BBACCCD
3 | 2213334
4 | XXyZZZa
5 |
--------------------------------------------------------------------------------
/src/testdata/singlerecord.csv:
--------------------------------------------------------------------------------
1 | ID,NAME,EXTRA_FIELD
2 | A123,Jonathan Ackerman,A
--------------------------------------------------------------------------------
/src/testdata/sunil_date_time.csv:
--------------------------------------------------------------------------------
1 | ID,D,T,TS
2 | 100,25-NOV-13,01:29:07.613 PM,2013-11-25T01:29:07.613
3 | 200,06-DEC-13,11:52:21.342 AM,2013-12-06T11:52:21.342
4 |
--------------------------------------------------------------------------------
/src/testdata/test-001-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,10:59:00,007,0.0,26.54
3 | 20-12-2007,11:14:00,007,0.0,0.0
4 | 20-12-2007,11:29:00,007,0.0,0.0
5 | 20-12-2007,11:44:00,007,26.54,0.0
6 | 20-12-2007,11:59:00,007,0.0,22.99
7 | 20-12-2007,12:14:00,007,25.72,0.0
8 | 20-12-2007,12:29:00,007,0.0,0.0
9 | 20-12-2007,12:44:00,007,0.0,25.45
10 | 20-12-2007,12:59:00,007,26.27,0.0
11 | 20-12-2007,13:14:00,007,0.0,0.0
12 | 20-12-2007,13:29:00,007,0.0,0.0
13 | 20-12-2007,13:44:00,007,25.45,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-001-20081113.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 | 20-12-2007,13:59:00,007,0.0,3.55
14 |
--------------------------------------------------------------------------------
/src/testdata/test-001-20081114.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI013.000,AI013.001
2 | 20-12-2007,10:59:00,013,0.0,0.0
3 | 20-12-2007,11:14:00,013,0.0,0.0
4 | 20-12-2007,11:29:00,013,0.0,0.0
5 | 20-12-2007,11:44:00,013,0.0,0.0
6 | 20-12-2007,11:59:00,013,0.0,0.0
7 | 20-12-2007,12:14:00,013,0.0,0.0
8 | 20-12-2007,12:29:00,013,0.0,0.0
9 | 20-12-2007,12:44:00,013,0.0,0.0
10 | 20-12-2007,12:59:00,013,0.0,0.0
11 | 20-12-2007,13:14:00,013,0.0,0.0
12 | 20-12-2007,13:29:00,013,0.0,0.0
13 | 20-12-2007,13:44:00,013,0.0,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-002-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,10:59:00,007,0.0,26.54
3 | 20-12-2007,11:14:00,007,0.0,0.0
4 | 20-12-2007,11:29:00,007,0.0,0.0
5 | 20-12-2007,11:44:00,007,26.54,0.0
6 | 20-12-2007,11:59:00,007,0.0,22.99
7 | 20-12-2007,12:14:00,007,25.72,0.0
8 | 20-12-2007,12:29:00,007,0.0,0.0
9 | 20-12-2007,12:44:00,007,0.0,25.45
10 | 20-12-2007,12:59:00,007,26.27,0.0
11 | 20-12-2007,13:14:00,007,0.0,0.0
12 | 20-12-2007,13:29:00,007,0.0,0.0
13 | 20-12-2007,13:44:00,007,25.45,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-002-20081113.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 | 20-12-2007,13:59:00,007,0.0,3.55
14 |
--------------------------------------------------------------------------------
/src/testdata/test-002-20081114.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI013.000,AI013.001
2 | 20-12-2007,10:59:00,013,0.0,0.0
3 | 20-12-2007,11:14:00,013,0.0,0.0
4 | 20-12-2007,11:29:00,013,0.0,0.0
5 | 20-12-2007,11:44:00,013,0.0,0.0
6 | 20-12-2007,11:59:00,013,0.0,0.0
7 | 20-12-2007,12:14:00,013,0.0,0.0
8 | 20-12-2007,12:29:00,013,0.0,0.0
9 | 20-12-2007,12:44:00,013,0.0,0.0
10 | 20-12-2007,12:59:00,013,0.0,0.0
11 | 20-12-2007,13:14:00,013,0.0,0.0
12 | 20-12-2007,13:29:00,013,0.0,0.0
13 | 20-12-2007,13:44:00,013,0.0,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-003-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,10:59:00,007,0.0,26.54
3 | 20-12-2007,11:14:00,007,0.0,0.0
4 | 20-12-2007,11:29:00,007,0.0,0.0
5 | 20-12-2007,11:44:00,007,26.54,0.0
6 | 20-12-2007,11:59:00,007,0.0,22.99
7 | 20-12-2007,12:14:00,007,25.72,0.0
8 | 20-12-2007,12:29:00,007,0.0,0.0
9 | 20-12-2007,12:44:00,007,0.0,25.45
10 | 20-12-2007,12:59:00,007,26.27,0.0
11 | 20-12-2007,13:14:00,007,0.0,0.0
12 | 20-12-2007,13:29:00,007,0.0,0.0
13 | 20-12-2007,13:44:00,007,25.45,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-003-20081113.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 | 20-12-2007,13:59:00,007,0.0,3.55
14 |
--------------------------------------------------------------------------------
/src/testdata/test-003-20081114.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI013.000,AI013.001
2 | 20-12-2007,10:59:00,013,0.0,0.0
3 | 20-12-2007,11:14:00,013,0.0,0.0
4 | 20-12-2007,11:29:00,013,0.0,0.0
5 | 20-12-2007,11:44:00,013,0.0,0.0
6 | 20-12-2007,11:59:00,013,0.0,0.0
7 | 20-12-2007,12:14:00,013,0.0,0.0
8 | 20-12-2007,12:29:00,013,0.0,0.0
9 | 20-12-2007,12:44:00,013,0.0,0.0
10 | 20-12-2007,12:59:00,013,0.0,0.0
11 | 20-12-2007,13:14:00,013,0.0,0.0
12 | 20-12-2007,13:29:00,013,0.0,0.0
13 | 20-12-2007,13:44:00,013,0.0,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-004-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,10:59:00,007,0.0,26.54
3 | 20-12-2007,11:14:00,007,0.0,0.0
4 | 20-12-2007,11:29:00,007,0.0,0.0
5 | 20-12-2007,11:44:00,007,26.54,0.0
6 | 20-12-2007,11:59:00,007,0.0,22.99
7 | 20-12-2007,12:14:00,007,25.72,0.0
8 | 20-12-2007,12:29:00,007,0.0,0.0
9 | 20-12-2007,12:44:00,007,0.0,25.45
10 | 20-12-2007,12:59:00,007,26.27,0.0
11 | 20-12-2007,13:14:00,007,0.0,0.0
12 | 20-12-2007,13:29:00,007,0.0,0.0
13 | 20-12-2007,13:44:00,007,25.45,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/test-004-20081113.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI007.000,AI007.001
2 | 20-12-2007,11:14:00,007,0.0,0.0
3 | 20-12-2007,11:29:00,007,0.0,0.0
4 | 20-12-2007,11:44:00,007,26.54,0.0
5 | 20-12-2007,11:59:00,007,0.0,22.99
6 | 20-12-2007,12:14:00,007,25.72,0.0
7 | 20-12-2007,12:29:00,007,0.0,0.0
8 | 20-12-2007,12:44:00,007,0.0,25.45
9 | 20-12-2007,12:59:00,007,26.27,0.0
10 | 20-12-2007,13:14:00,007,0.0,0.0
11 | 20-12-2007,13:29:00,007,0.0,0.0
12 | 20-12-2007,13:44:00,007,25.45,0.0
13 | 20-12-2007,13:59:00,007,0.0,3.55
14 |
--------------------------------------------------------------------------------
/src/testdata/test-004-20081114.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,AI013.000,AI013.001
2 | 20-12-2007,10:59:00,013,0.0,0.0
3 | 20-12-2007,11:14:00,013,0.0,0.0
4 | 20-12-2007,11:29:00,013,0.0,0.0
5 | 20-12-2007,11:44:00,013,0.0,0.0
6 | 20-12-2007,11:59:00,013,0.0,0.0
7 | 20-12-2007,12:14:00,013,0.0,0.0
8 | 20-12-2007,12:29:00,013,0.0,0.0
9 | 20-12-2007,12:44:00,013,0.0,0.0
10 | 20-12-2007,12:59:00,013,0.0,0.0
11 | 20-12-2007,13:14:00,013,0.0,0.0
12 | 20-12-2007,13:29:00,013,0.0,0.0
13 | 20-12-2007,13:44:00,013,0.0,0.0
14 |
--------------------------------------------------------------------------------
/src/testdata/transactions.txt:
--------------------------------------------------------------------------------
1 | # Example bank transactions from one account and bank to another
2 | 19-10-2011,3670345,10010010,027853256,10020500,250.00
3 | 21-10-2011,3670345,10010010,027234813,10020500,21.23
4 | 21-10-2011,3670345,10010010,81824588,10010424,460.00
5 | 21-10-2011,97540210,10020500,80032697,10010424,999.00
6 | 24-10-2011,58340576,10010010,027234813,10020500,55.25
7 | 27-10-2011,97540210,10020500,026443583,10020500,190.50
8 | 27-10-2011,3670345,10010010,027234813,10020500,43.07
9 | 28-10-2011,2340529,10020200,66123747,10020400,1012.74
10 | 31-10-2011,97540210,10020500,3670345,10010010,7.23
11 |
--------------------------------------------------------------------------------
/src/testdata/twoheaders.txt:
--------------------------------------------------------------------------------
1 | ,600-P1201,600-P1202,600-P1203,600-P1221,600-P1222,600-P1223,600-P1204,600-P1205,600-P1206,600-P1224,600-P1225,600-P1226,600-P2101,600-P2102,600-P2103,600-P2104,600-P2105,600-P2202,600-P2301,600-P2401,600-P5101,600-P5102,600-P5103,600-P5104,600-P5111,600-P5112,600-M1201,600-M1202,600-M1203,600-M1204,600-P6101,600-P6102,600-P6103,600-P6104,600-P1207,600-S1301,600-P1208,600-S1302,600-S2301,600-S2401,600-P1209,600-P1210,600-A1101,600-P1110,600-S1101,600-P2504,600-P1105,600-P1107,600-S1102,600-P1101,600-P1102,600-S2101
2 | ,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925,WNS925
3 | 2010-02-21 00:00:00,21,20,24,20,20,24,13,11,24,12,12,24,12,0,8,1,0,24,2,0,2,2,1,2,2,0,24,24,24,24,24,24,24,24,24,24,24,24,24,0,24,24,12,0,12,-999,0,0,24,3,3,24
4 | 2010-02-22 00:00:00,23,18,24,23,17,25,18,19,24,18,18,24,8,0,13,1,0,24,1,0,2,2,2,1,2,0,24,24,24,24,24,24,24,24,24,24,24,25,24,0,24,24,12,0,12,-999,0,0,24,3,3,24
5 | 2010-02-23 00:00:00,18,16,24,18,17,23,11,18,24,12,18,24,8,0,12,1,0,24,2,0,3,1,2,2,2,0,24,24,24,24,24,24,24,24,24,24,24,23,24,0,24,24,12,0,12,-999,0,1,24,3,2,24
6 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtables01.txt:
--------------------------------------------------------------------------------
1 | L,l1,l2,l3
2 | P,p1,p2,p3
3 | K,k1,k2,k3
4 | U,u1,u2,u3
5 | W,w1,w2,w3
6 | d1,t1,v11,v12,v13
7 | d2,t2,v21,v22,v23
8 | d3,t3,v31,v32,v33
9 | d4,t4,v41,v42,v43
10 | d5,t5,v51,v52,v53
11 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtables01joined.txt:
--------------------------------------------------------------------------------
1 | L,P,K,U,W,D,T,V
2 | l1,p1,k1,u1,w1,d1,t1,v11
3 | l2,p2,k2,u2,w2,d1,t1,v12
4 | l3,p3,k3,u3,w3,d1,t1,v13
5 | l1,p1,k1,u1,w1,d2,t2,v21
6 | l2,p2,k2,u2,w2,d2,t2,v22
7 | l3,p3,k3,u3,w3,d2,t2,v23
8 | l1,p1,k1,u1,w1,d3,t3,v31
9 | l2,p2,k2,u2,w2,d3,t3,v32
10 | l3,p3,k3,u3,w3,d3,t3,v33
11 | l1,p1,k1,u1,w1,d4,t4,v41
12 | l2,p2,k2,u2,w2,d4,t4,v42
13 | l3,p3,k3,u3,w3,d4,t4,v43
14 | l1,p1,k1,u1,w1,d5,t5,v51
15 | l2,p2,k2,u2,w2,d5,t5,v52
16 | l3,p3,k3,u3,w3,d5,t5,v53
17 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtables02.txt:
--------------------------------------------------------------------------------
1 | D,T,p1,p2,p3,p4,p5
2 | d1,t1,v11,v12,v13,v14,v15
3 | d2,t2,v21,v22,v23,v24,v25
4 | d3,t3,v31,v32,v33,v34,v35
5 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtables02joined.txt:
--------------------------------------------------------------------------------
1 | P,D,T,V
2 | p1,d1,t1,v11
3 | p2,d1,t1,v12
4 | p3,d1,t1,v13
5 | p4,d1,t1,v14
6 | p5,d1,t1,v15
7 | p1,d2,t2,v21
8 | p2,d2,t2,v22
9 | p3,d2,t2,v23
10 | p4,d2,t2,v24
11 | p5,d2,t2,v25
12 | p1,d3,t3,v31
13 | p2,d3,t3,v32
14 | p3,d3,t3,v33
15 | p4,d3,t3,v34
16 | p5,d3,t3,v35
17 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtablesindex_1.txt:
--------------------------------------------------------------------------------
1 | D,T,p1,p2,p3
2 | d1,t1,v11,v12,v13
3 | d2,t2,v21,v22,v23
4 | d3,t3,v31,v32,v33
5 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtablesindex_2.txt:
--------------------------------------------------------------------------------
1 | D,T,p1,p2,p3
2 | d7,t7,v71,v72,v73
3 | d8,t8,v81,v82,v83
4 | d9,t9,v91,v92,v93
5 |
--------------------------------------------------------------------------------
/src/testdata/twojoinedtablesindex_3.txt:
--------------------------------------------------------------------------------
1 | D,T,p1,p2
2 | d1,t1,v11,v12
3 | d2,t2,v21,v22
4 | d3,t3,v31,v32
5 |
--------------------------------------------------------------------------------
/src/testdata/uses_quotes.txt:
--------------------------------------------------------------------------------
1 | COLUMN1,COLUMN2,COLUMN3
2 | 1,uno,one
3 | 2,a 'quote' (source unknown),two
4 | 3,another "quote" (also unkown),three
5 | 4,a 'quote" that gives error,four
6 | 5,another not parsable "quote',five
7 | 6,collecting quotes ""'',six
8 |
--------------------------------------------------------------------------------
/src/testdata/utf16le_01102018.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/utf16le_01102018.txt
--------------------------------------------------------------------------------
/src/testdata/utf16le_04112020.txt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/utf16le_04112020.txt
--------------------------------------------------------------------------------
/src/testdata/utf8_bom.csv:
--------------------------------------------------------------------------------
1 | "foo","bar","b☺z"
2 | 1,3,5
3 | 2,4,6
4 |
--------------------------------------------------------------------------------
/src/testdata/varlen1-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,P000,P001,P002,P003
2 | 20-12-2007,10:59:00,007,0.0,26.54,0.0,26.54
3 | 20-12-2007,11:59:00,007,0.0,22.99,0.0,26.54
4 |
--------------------------------------------------------------------------------
/src/testdata/varlen1-20081113.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,P000,P001,P002,P003
2 | 20-12-2007,12:59:00,007,0.0,22.99,0.0,26.54
3 | 20-12-2007,13:59:00,001,26.27,0.0,0.0,26.55
4 |
--------------------------------------------------------------------------------
/src/testdata/varlen2-20081112.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,P000,P001
2 | 20-12-2007,10:59:00,007,0.0,26.54
3 | 20-12-2007,11:59:00,007,0.0,22.99
4 |
--------------------------------------------------------------------------------
/src/testdata/varlen2-20081114.txt:
--------------------------------------------------------------------------------
1 | Datum,Tijd,Station,P000,P001
2 | 20-12-2007,12:59:00,013,0.0,0.0
3 | 20-12-2007,13:59:00,013,0.0,0.0
4 |
--------------------------------------------------------------------------------
/src/testdata/with_comments.txt:
--------------------------------------------------------------------------------
1 | # comment line
2 | #second comment line
3 | #next comes the header
4 | name, id, value, comment
5 | alpha,1, 12.34, some field
6 | beta,2, 13.24, other parameter
7 | #hash#,3, 41.32, still a field
--------------------------------------------------------------------------------
/src/testdata/with_leading_trash.txt:
--------------------------------------------------------------------------------
1 | Databank=MSW
2 | Locatie=DENH
3 | Parameter=TW10
4 | Waarnemingsgroepcode=-
5 | X_coordinaat=11185000
6 | Y_coordinaat=55323000
7 | 2009/01/26;12:20;MET;gr.C;10;2.6
8 | 2009/01/26;12:30;MET;gr.C;10;2.4
9 | 2009/01/26;12:40;MET;gr.C;10;2.5
10 |
--------------------------------------------------------------------------------
/src/testdata/witheol.txt:
--------------------------------------------------------------------------------
1 | key,value
2 | 1,"due"
3 | 2,"tre"
4 | 3,"123
5 | 456
6 | 789"
7 |
--------------------------------------------------------------------------------
/src/testdata/wrong_column_count.csv:
--------------------------------------------------------------------------------
1 | A,B
2 | 1,hello
3 | 2,hello
4 | 3,hello
5 | 4,hello
6 | 5,hello
7 | 6,hello
8 | 7,hello
9 | 8,hello
10 | 9,hello
11 | 10,hello
12 | 11,hello
13 | 12,hello
14 | 13,hello
15 | 14,hello
16 | 15,hello
17 | 16,hello
18 | 17,hello
19 | 18,hello
20 | 19,hello
21 | 20,hello
22 | 21,hello
23 | 22,hello
24 | 23,hello
25 | 24,hello
26 | 25,hello
27 | 26,hello
28 | 27,hello
29 | 28,hello
30 | 29,hello
31 | 30,hello
32 | 31,hello
33 | 32,hello
34 | 33,hello
35 | 34,hello
36 | 35,hello
37 | 36,hello
38 | 37,hello
39 | 38,hello
40 | 39,hello
41 | 40,hello
42 | 41,hello
43 | 42,hello
44 | 43,hello
45 | 44,hello
46 | 45,hello
47 | 46,hello
48 | 47,hello
49 | 48,hello
50 | 49,hello
51 | 50,hello
52 | 51,hello
53 | 52,hello
54 | 53,hello
55 | 54,hello
56 | 55,hello
57 | 56,hello
58 | 57,hello
59 | 58,hello
60 | 59,hello
61 | 60,hello
62 | 61,hello
63 | 62,hello
64 | 63,hello
65 | 64,hello
66 | 65,hello
67 | 66,hello
68 | 67,hello
69 | 68,hello
70 | 69,hello
71 | 70,hello
72 | 71,hello
73 | 72,hello
74 | 73,hello
75 | 74,hello
76 | 75,hello
77 | 76,hello
78 | 77,hello
79 | 78,hello
80 | 79,hello
81 | 80,hello
82 | 81,hello
83 | 82,hello
84 | 83,hello
85 | 84,hello
86 | 85,hello
87 | 86,hello
88 | 87,hello
89 | 88,hello
90 | 89,hello
91 | 90,hello
92 | 91,hello
93 | 92,hello
94 | 93,hello
95 | 94,hello
96 | 95,hello
97 | 96,hello
98 | 97,hello
99 | 98,hello
100 | 99,hello
101 | 100,hello
102 | 101,hello
103 | 102,hello
104 | 103,hello
105 | 104,hello
106 | 105,hello
107 | 106,hello
108 | 107,hello
109 | 108,hello
110 | 109,hello
111 | 110,hello
112 | 111,hello
113 | 112,hello
114 | 113,hello
115 | 114,hello
116 | 115,hello
117 | 116,hello
118 | 117,hello
119 | 118,hello
120 | 119,hello
121 | 120,hello
122 | 121,hello
123 | 122,hello
124 | 123,hello
125 | 124,hello
126 | 125,hello
127 | 126,hello
128 | 127,hello
129 | 128,hello
130 | 129,hello
131 | 130,hello
132 | 131,hello
133 | 132,hello
134 | 133,hello
135 | 134,hello
136 | 135,hello
137 | 136
138 | 137,hello
139 | 138,hello
140 | 139,hello
141 | 140,hello
142 | 141,hello
143 | 142,hello
144 | 143,hello
145 | 144,hello
146 | 145,hello
147 | 146,hello
148 | 147,hello
149 | 148,hello
150 | 149,hello
151 | 150,hello
152 | 151,hello
153 | 152,hello
154 | 153,hello
155 | 154,hello
156 | 155,hello
157 | 156,hello
158 | 157,hello
159 | 158,hello
160 | 159,hello
161 | 160,hello
162 | 161,hello
163 | 162,hello
164 | 163,hello
165 | 164,hello
166 | 165,hello
167 | 166,hello
168 | 167,hello
169 | 168,hello
170 | 169,hello
171 | 170,hello
172 | 171,hello
173 | 172,hello
174 | 173,hello
175 | 174,hello
176 | 175,hello
177 | 176,hello
178 | 177,hello
179 | 178,hello
180 | 179,hello
181 | 180,hello
182 | 181,hello
183 | 182,hello
184 | 183,hello
185 | 184,hello
186 | 185,hello
187 | 186,hello
188 | 187,hello
189 | 188,hello
190 | 189,hello
191 | 190,hello
192 | 191,hello
193 | 192,hello
194 | 193,hello
195 | 194,hello
196 | 195,hello
197 | 196,hello
198 | 197,hello
199 | 198,hello
200 | 199,hello
201 | 200,hello
202 |
--------------------------------------------------------------------------------
/src/testdata/xbase.dbf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/xbase.dbf
--------------------------------------------------------------------------------
/src/testdata/xbase.dbt:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/simoc/csvjdbc/e1c2b76d3fd8c1b79fdf137f64eb227a0d837142/src/testdata/xbase.dbt
--------------------------------------------------------------------------------
/src/testdata/yogesh.csv:
--------------------------------------------------------------------------------
1 | ID,T
2 | 100,25-NOV-13 01:29:07.613 PM
3 | 200,06-DEC-13 11:52:21.342 AM
4 |
--------------------------------------------------------------------------------
/src/testdata/yogesh_de.csv:
--------------------------------------------------------------------------------
1 | ID,T
2 | 100,25-OKT-13 13:29:07.613
3 | 200,06-DEZ-13 11:52:21.342
4 |
--------------------------------------------------------------------------------