Skip to content

Commit e3fd2c6

Browse files
committed
minor code improvements
1 parent 546b71d commit e3fd2c6

File tree

14 files changed

+94
-96
lines changed

14 files changed

+94
-96
lines changed

src/test/java/net/sf/jsqlparser/test/create/CreateIndexTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
*/
1414
public class CreateIndexTest extends TestCase {
1515

16-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
16+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
1717

1818
public CreateIndexTest(String arg0) {
1919
super(arg0);

src/test/java/net/sf/jsqlparser/test/create/CreateTableTest.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class CreateTableTest extends TestCase {
2222

23-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
23+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
2424

2525
public CreateTableTest(String arg0) {
2626
super(arg0);
@@ -256,14 +256,14 @@ public void testRUBiSCreateList() throws Exception {
256256
break;
257257
}
258258

259-
if (!line.equals("#begin")) {
259+
if (!"#begin".equals(line)) {
260260
break;
261261
}
262262
line = getLine(in);
263263
StringBuilder buf = new StringBuilder(line);
264264
while (true) {
265265
line = getLine(in);
266-
if (line.equals("#end")) {
266+
if ("#end".equals(line)) {
267267
break;
268268
}
269269
buf.append("\n");
@@ -280,7 +280,7 @@ public void testRUBiSCreateList() throws Exception {
280280
try {
281281
CreateTable createTable = (CreateTable) parserManager.parse(new StringReader(query));
282282
String[] colsList = null;
283-
if (cols.equals("null")) {
283+
if ("null".equals(cols)) {
284284
colsList = new String[0];
285285
} else {
286286
StringTokenizer tokenizer = new StringTokenizer(cols, " ");
@@ -355,7 +355,6 @@ private String getLine(BufferedReader in) throws Exception {
355355
while (true) {
356356
line = in.readLine();
357357
if (line != null) {
358-
line.trim();
359358
if ((line.length() != 0)
360359
&& ((line.length() < 2) || (line.length() >= 2)
361360
&& !(line.charAt(0) == '/' && line.charAt(1) == '/'))) {

src/test/java/net/sf/jsqlparser/test/create/CreateViewTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
public class CreateViewTest extends TestCase {
1616

17-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
17+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
1818

1919
public CreateViewTest(String arg0) {
2020
super(arg0);

src/test/java/net/sf/jsqlparser/test/delete/DeleteTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
public class DeleteTest {
1515

16-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
16+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
1717

1818
@Test
1919
public void testDelete() throws JSQLParserException {

src/test/java/net/sf/jsqlparser/test/drop/DropTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
public class DropTest extends TestCase {
1212

13-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
13+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
1414

1515
public DropTest(String arg0) {
1616
super(arg0);

src/test/java/net/sf/jsqlparser/test/insert/InsertTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
public class InsertTest {
2222

23-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
23+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
2424

2525
@Test
2626
public void testRegularInsert() throws JSQLParserException {

src/test/java/net/sf/jsqlparser/test/replace/ReplaceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class ReplaceTest {
2020

21-
private static CCJSqlParserManager parserManager = new CCJSqlParserManager();
21+
private static final CCJSqlParserManager parserManager = new CCJSqlParserManager();
2222

2323

2424
@Test
Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,75 @@
1-
package net.sf.jsqlparser.test.select;
2-
3-
import java.io.StringReader;
4-
5-
import net.sf.jsqlparser.parser.CCJSqlParserManager;
6-
import net.sf.jsqlparser.statement.Statement;
7-
8-
public class MemoryTest {
9-
10-
public static void main(String[] args) throws Exception {
11-
System.gc();
12-
System.out.println(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
13-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
14-
15-
/*
16-
* String longQuery = new String(
17-
* "select * from ( SELECT intermediate.id as id , intermediate.date as " +
18-
* "date FROM ( SELECT DISTINCT ( id ) FROM ( SELECT " +
19-
* "wct_workflows.workflow_id as id , wct_transaction.date as date FROM " +
20-
* "wct_audit_entry , wct_transaction , wct_workflows WHERE " +
21-
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " +
22-
* "'C' ) and wct_audit_entry.outcome = 't' and " +
23-
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
24-
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
25-
* "wct_workflows.active_version_id ))) UNION SELECT wct_workflows.workflow_id as " +
26-
* "id , wct_transaction.date as date FROM wct_audit_entry , " +
27-
* "wct_transaction , wct_workflows WHERE ( wct_audit_entry.privilege = " +
28-
* "'W' or wct_audit_entry.privilege = 'C' ) and wct_audit_entry.outcome " +
29-
* "= 't' and wct_audit_entry.transaction_id = " +
30-
* "wct_transaction.transaction_id and wct_transaction.user_id = 164 and " +
31-
* "afdf= ( select wct_audit_entry.object_id from wct_audit_entry , " +
32-
* "wct_workflow_archive where wct_audit_entry.object_id = " +
33-
* "wct_workflow_archive.archive_id and wct_workflows.workflow_id = " +
34-
* "wct_workflow_archive.workflow_id ) " +
35-
* "UNION SELECT wct_workflows.workflow_id " +
36-
* "as id , wct_transaction.date as date FROM wct_audit_entry , " +
37-
* "wct_transaction , wct_workflows WHERE ( wct_audit_entry.privilege = " +
38-
* "'W' OR wct_audit_entry.privilege = 'E' OR wct_audit_entry.privilege = " +
39-
* "'A' ) and wct_audit_entry.outcome = 't' and " +
40-
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
41-
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
42-
* "wct_workflows.workflow_id UNION SELECT * FROM interm2 , wct_workflow_docs WHERE " +
43-
* "interm2.id = wct_workflow_docs.document_id ORDER BY id , date DESC ");
44-
*/
45-
String longQuery = new String("select * from k where ID > 4");
46-
47-
/*
48-
* String longQuery = "select * from ( SELECT intermediate.id as id , intermediate.date as "
49-
* + "date FROM ( SELECT DISTINCT ( id ) FROM ( SELECT " +
50-
* "wct_workflows.workflow_id as id , wct_transaction.date as date FROM " +
51-
* "wct_audit_entry , wct_transaction , wct_workflows WHERE " +
52-
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " + "'C' ))))";
53-
*/
54-
/*
55-
* String longQuery = "select * from d WHERE " +
56-
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " +
57-
* "'C' ) and wct_audit_entry.outcome = 't' and " +
58-
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
59-
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
60-
* "wct_workflows.active_version_id ";
61-
*/
62-
StringReader stringReader = new StringReader(longQuery);
63-
Statement statement = parserManager.parse(stringReader);
64-
// stringReader = new StringReader(longQuery);
65-
// Statement statement2 = parserManager.parse(stringReader);
66-
// stringReader = null;
67-
// statement2 = null;
68-
statement = null;
69-
parserManager = null;
70-
longQuery = null;
71-
System.gc();
72-
System.out.println(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
73-
74-
}
75-
}
1+
package net.sf.jsqlparser.test.select;
2+
3+
import java.io.StringReader;
4+
5+
import net.sf.jsqlparser.parser.CCJSqlParserManager;
6+
import net.sf.jsqlparser.statement.Statement;
7+
8+
public class MemoryTest {
9+
10+
public static void main(String[] args) throws Exception {
11+
System.gc();
12+
System.out.println(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
13+
CCJSqlParserManager parserManager = new CCJSqlParserManager();
14+
15+
/*
16+
* String longQuery = new String(
17+
* "select * from ( SELECT intermediate.id as id , intermediate.date as " +
18+
* "date FROM ( SELECT DISTINCT ( id ) FROM ( SELECT " +
19+
* "wct_workflows.workflow_id as id , wct_transaction.date as date FROM " +
20+
* "wct_audit_entry , wct_transaction , wct_workflows WHERE " +
21+
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " +
22+
* "'C' ) and wct_audit_entry.outcome = 't' and " +
23+
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
24+
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
25+
* "wct_workflows.active_version_id ))) UNION SELECT wct_workflows.workflow_id as " +
26+
* "id , wct_transaction.date as date FROM wct_audit_entry , " +
27+
* "wct_transaction , wct_workflows WHERE ( wct_audit_entry.privilege = " +
28+
* "'W' or wct_audit_entry.privilege = 'C' ) and wct_audit_entry.outcome " +
29+
* "= 't' and wct_audit_entry.transaction_id = " +
30+
* "wct_transaction.transaction_id and wct_transaction.user_id = 164 and " +
31+
* "afdf= ( select wct_audit_entry.object_id from wct_audit_entry , " +
32+
* "wct_workflow_archive where wct_audit_entry.object_id = " +
33+
* "wct_workflow_archive.archive_id and wct_workflows.workflow_id = " +
34+
* "wct_workflow_archive.workflow_id ) " +
35+
* "UNION SELECT wct_workflows.workflow_id " +
36+
* "as id , wct_transaction.date as date FROM wct_audit_entry , " +
37+
* "wct_transaction , wct_workflows WHERE ( wct_audit_entry.privilege = " +
38+
* "'W' OR wct_audit_entry.privilege = 'E' OR wct_audit_entry.privilege = " +
39+
* "'A' ) and wct_audit_entry.outcome = 't' and " +
40+
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
41+
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
42+
* "wct_workflows.workflow_id UNION SELECT * FROM interm2 , wct_workflow_docs WHERE " +
43+
* "interm2.id = wct_workflow_docs.document_id ORDER BY id , date DESC ");
44+
*/
45+
String longQuery = "select * from k where ID > 4";
46+
47+
/*
48+
* String longQuery = "select * from ( SELECT intermediate.id as id , intermediate.date as "
49+
* + "date FROM ( SELECT DISTINCT ( id ) FROM ( SELECT " +
50+
* "wct_workflows.workflow_id as id , wct_transaction.date as date FROM " +
51+
* "wct_audit_entry , wct_transaction , wct_workflows WHERE " +
52+
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " + "'C' ))))";
53+
*/
54+
/*
55+
* String longQuery = "select * from d WHERE " +
56+
* "( wct_audit_entry.privilege = 'W' or wct_audit_entry.privilege = " +
57+
* "'C' ) and wct_audit_entry.outcome = 't' and " +
58+
* "wct_audit_entry.transaction_id = wct_transaction.transaction_id and " +
59+
* "wct_transaction.user_id = 164 and wct_audit_entry.object_id = " +
60+
* "wct_workflows.active_version_id ";
61+
*/
62+
StringReader stringReader = new StringReader(longQuery);
63+
Statement statement = parserManager.parse(stringReader);
64+
// stringReader = new StringReader(longQuery);
65+
// Statement statement2 = parserManager.parse(stringReader);
66+
// stringReader = null;
67+
// statement2 = null;
68+
statement = null;
69+
parserManager = null;
70+
longQuery = null;
71+
System.gc();
72+
System.out.println(Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory());
73+
74+
}
75+
}

src/test/java/net/sf/jsqlparser/test/select/SelectTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
public class SelectTest extends TestCase {
2020

21-
CCJSqlParserManager parserManager = new CCJSqlParserManager();
21+
private CCJSqlParserManager parserManager = new CCJSqlParserManager();
2222

2323
public SelectTest(String arg0) {
2424
super(arg0);

src/test/java/net/sf/jsqlparser/test/simpleparsing/CCJSqlParserManagerTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ public static String getLine(BufferedReader in) throws Exception {
6363
while (true) {
6464
line = in.readLine();
6565
if (line != null) {
66-
line.trim();
67-
// if ((line.length() != 0) && ((line.length() < 2) || (line.length() >= 2) && !(line.charAt(0) == '/'
68-
// && line.charAt(1) == '/')))
6966
if (((line.length() < 2) || (line.length() >= 2) && !(line.charAt(0) == '/' && line.charAt(1) == '/'))) {
7067
break;
7168
}

0 commit comments

Comments
 (0)