Skip to content

Commit dcea88f

Browse files
author
Stefan Steinhauser
committed
feat: Implement java classes for IMPORT statement
1 parent 482a993 commit dcea88f

24 files changed

+1254
-75
lines changed

src/main/java/net/sf/jsqlparser/schema/Table.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import net.sf.jsqlparser.expression.MySQLIndexHint;
1818
import net.sf.jsqlparser.expression.SQLServerHints;
1919
import net.sf.jsqlparser.parser.ASTNodeAccessImpl;
20+
import net.sf.jsqlparser.statement.ErrorDestination;
2021
import net.sf.jsqlparser.statement.select.FromItem;
2122
import net.sf.jsqlparser.statement.select.FromItemVisitor;
2223
import net.sf.jsqlparser.statement.select.IntoTableVisitor;
@@ -27,7 +28,7 @@
2728
/**
2829
* A table. It can have an alias and the schema name it belongs to.
2930
*/
30-
public class Table extends ASTNodeAccessImpl implements FromItem, MultiPartName {
31+
public class Table extends ASTNodeAccessImpl implements ErrorDestination, FromItem, MultiPartName {
3132

3233
// private Database database;
3334
// private String schemaName;
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
public class CSVColumn {
15+
private Long startIndex;
16+
private Long endIndex;
17+
private StringValue format;
18+
19+
public CSVColumn(Long startIndex, Long endIndex) {
20+
this.startIndex = startIndex;
21+
this.endIndex = endIndex;
22+
}
23+
24+
public CSVColumn(Long index) {
25+
this(index, null);
26+
}
27+
28+
public Long getStartIndex() {
29+
return startIndex;
30+
}
31+
32+
public void setStartIndex(Long startIndex) {
33+
this.startIndex = startIndex;
34+
}
35+
36+
public Long getIndex() {
37+
return getStartIndex();
38+
}
39+
40+
public void setIndex(Long index) {
41+
setStartIndex(index);
42+
}
43+
44+
public Long getEndIndex() {
45+
return endIndex;
46+
}
47+
48+
public void setEndIndex(Long endIndex) {
49+
this.endIndex = endIndex;
50+
}
51+
52+
public StringValue getFormat() {
53+
return format;
54+
}
55+
56+
public void setFormat(StringValue format) {
57+
this.format = format;
58+
}
59+
60+
@Override
61+
public String toString() {
62+
StringBuilder sql = new StringBuilder();
63+
64+
sql.append(startIndex);
65+
if (endIndex != null) {
66+
sql.append(" .. ");
67+
sql.append(endIndex);
68+
} else if (format != null) {
69+
sql.append(" FORMAT = ");
70+
sql.append(format);
71+
}
72+
73+
return sql.toString();
74+
}
75+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
public class CSVFileDestination implements ErrorDestination {
15+
private ConnectionDefinition connectionDefinition;
16+
private boolean local;
17+
private boolean secure;
18+
private StringValue filePath;
19+
20+
public ConnectionDefinition getConnectionDefinition() {
21+
return connectionDefinition;
22+
}
23+
24+
public void setConnectionDefinition(ConnectionDefinition connectionDefinition) {
25+
this.connectionDefinition = connectionDefinition;
26+
}
27+
28+
public boolean isLocal() {
29+
return local;
30+
}
31+
32+
public void setLocal(boolean local) {
33+
this.local = local;
34+
}
35+
36+
public boolean isSecure() {
37+
return secure;
38+
}
39+
40+
public void setSecure(boolean secure) {
41+
this.secure = secure;
42+
}
43+
44+
public StringValue getFilePath() {
45+
return filePath;
46+
}
47+
48+
public void setFilePath(StringValue filePath) {
49+
this.filePath = filePath;
50+
}
51+
52+
@Override
53+
public String toString() {
54+
StringBuilder sql = new StringBuilder();
55+
56+
if (local) {
57+
sql.append("LOCAL ");
58+
if (secure) {
59+
sql.append("SECURE ");
60+
}
61+
}
62+
63+
sql.append("CSV");
64+
65+
if (connectionDefinition != null) {
66+
sql.append(" ");
67+
sql.append(connectionDefinition);
68+
}
69+
70+
sql.append(" FILE ");
71+
sql.append(filePath);
72+
73+
return sql.toString();
74+
}
75+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package net.sf.jsqlparser.statement;
2+
3+
import net.sf.jsqlparser.expression.StringValue;
4+
5+
public class CertificateVerification {
6+
private Boolean ignoreCertificate;
7+
private StringValue publicKey;
8+
9+
public StringValue getPublicKey() {
10+
return publicKey;
11+
}
12+
13+
public void setPublicKey(StringValue publicKey) {
14+
this.publicKey = publicKey;
15+
}
16+
17+
public Boolean getIgnoreCertificate() {
18+
return ignoreCertificate;
19+
}
20+
21+
public void setIgnoreCertificate(Boolean ignoreCertificate) {
22+
this.ignoreCertificate = ignoreCertificate;
23+
}
24+
25+
public Boolean getVerifyCertificate() {
26+
return !ignoreCertificate;
27+
}
28+
29+
public void setVerifyCertificate(Boolean verifyCertificate) {
30+
this.ignoreCertificate = !verifyCertificate;
31+
}
32+
33+
@Override
34+
public String toString() {
35+
StringBuilder sql = new StringBuilder();
36+
37+
if (ignoreCertificate != null) {
38+
if (ignoreCertificate) {
39+
sql.append("IGNORE ");
40+
} else {
41+
sql.append("VERIFY ");
42+
}
43+
sql.append("CERTIFICATE");
44+
}
45+
46+
if (publicKey != null) {
47+
if (ignoreCertificate != null) {
48+
sql.append(" ");
49+
}
50+
sql.append("PUBLIC KEY ");
51+
sql.append(publicKey);
52+
}
53+
54+
return sql.toString();
55+
}
56+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
public class CloudConnectionDefinition extends ConnectionDefinition {
13+
private String storage;
14+
15+
public String getStorage() {
16+
return storage;
17+
}
18+
19+
public void setStorage(String storage) {
20+
this.storage = storage;
21+
}
22+
23+
@Override
24+
public void setCertificateVerification(CertificateVerification certificateVerification) {}
25+
26+
@Override
27+
public String toString() {
28+
StringBuilder sql = new StringBuilder();
29+
30+
sql.append("AT CLOUD ");
31+
sql.append(storage);
32+
appendConnectionDefinition(sql);
33+
34+
return sql.toString();
35+
}
36+
}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/*-
2+
* #%L
3+
* JSQLParser library
4+
* %%
5+
* Copyright (C) 2004 - 2022 JSQLParser
6+
* %%
7+
* Dual licensed under GNU LGPL 2.1 or Apache License 2.0
8+
* #L%
9+
*/
10+
package net.sf.jsqlparser.statement;
11+
12+
import net.sf.jsqlparser.expression.StringValue;
13+
14+
public class ConnectionDefinition {
15+
private String connectionObjectName;
16+
private StringValue connectionDefinition;
17+
private UserIdentification userIdentification;
18+
private CertificateVerification certificateVerification;
19+
20+
public String getConnectionObjectName() {
21+
return connectionObjectName;
22+
}
23+
24+
public void setConnectionObjectName(String connectionObjectName) {
25+
this.connectionObjectName = connectionObjectName;
26+
}
27+
28+
public StringValue getConnectionDefinition() {
29+
return connectionDefinition;
30+
}
31+
32+
public void setConnectionDefinition(StringValue connectionDefinition) {
33+
this.connectionDefinition = connectionDefinition;
34+
}
35+
36+
public void setConnection(String connectionObjectName) {
37+
this.connectionObjectName = connectionObjectName;
38+
}
39+
40+
public void setConnection(StringValue connectionDefinition) {
41+
this.connectionDefinition = connectionDefinition;
42+
}
43+
44+
public UserIdentification getUserIdentification() {
45+
return userIdentification;
46+
}
47+
48+
public void setUserIdentification(UserIdentification userIdentification) {
49+
this.userIdentification = userIdentification;
50+
}
51+
52+
public CertificateVerification getCertificateVerification() {
53+
return certificateVerification;
54+
}
55+
56+
public void setCertificateVerification(CertificateVerification certificateVerification) {
57+
this.certificateVerification = certificateVerification;
58+
}
59+
60+
protected StringBuilder appendConnectionDefinition(StringBuilder sql) {
61+
if (connectionObjectName != null) {
62+
sql.append(connectionObjectName);
63+
} else if (connectionDefinition != null) {
64+
sql.append(connectionDefinition);
65+
}
66+
67+
if (userIdentification != null) {
68+
sql.append(" ");
69+
sql.append(userIdentification);
70+
}
71+
72+
if (certificateVerification != null) {
73+
sql.append(" ");
74+
sql.append(certificateVerification);
75+
}
76+
77+
return sql;
78+
}
79+
80+
@Override
81+
public String toString() {
82+
StringBuilder sql = new StringBuilder();
83+
84+
sql.append("AT ");
85+
appendConnectionDefinition(sql);
86+
87+
return sql.toString();
88+
}
89+
}

0 commit comments

Comments
 (0)