Skip to content

Commit 084efc2

Browse files
author
Nikolai Malygin
committed
some javadoc
1 parent cb98c79 commit 084efc2

25 files changed

+219
-32
lines changed

src/main/java/com/nmalygin/superb/jdbc/api/Appendable.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@
2424

2525
package com.nmalygin.superb.jdbc.api;
2626

27+
/**
28+
* An object to which the sql fragment can be appended.
29+
*
30+
* @param <T> Type of return
31+
* @author Nikolai Malygin
32+
*/
2733
public interface Appendable<T> {
34+
/**
35+
* Appends the parametrized sql fragment with attributes to the object.
36+
*
37+
* @param sqlFragment Parametrized sql fragment
38+
* @param withArguments Arguments for the corresponding parameters in the sqlFragment
39+
* @return itself
40+
*/
2841
T append(String sqlFragment, Argument... withArguments);
2942
}

src/main/java/com/nmalygin/superb/jdbc/api/Argument.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,19 @@
2727
import java.sql.PreparedStatement;
2828
import java.sql.SQLException;
2929

30+
/**
31+
* Parameterized sql query argument.
32+
*
33+
* @author Nikolai Malygin
34+
*/
3035
public interface Argument {
36+
37+
/**
38+
*
39+
* @param preparedStatement PreparedStatement
40+
* @param position Index of the argument
41+
* @throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement;
42+
* if a database access error occurs or this method is called on a closed PreparedStatement
43+
*/
3144
void pass(PreparedStatement preparedStatement, int position) throws SQLException;
3245
}

src/main/java/com/nmalygin/superb/jdbc/api/Batch.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,37 @@
2626

2727
import java.sql.SQLException;
2828

29+
/**
30+
* An object representing a batch of operations.
31+
*
32+
* @author Nikolai Malygin
33+
*/
2934
public interface Batch extends AutoCloseable {
35+
36+
/**
37+
* Adding an operation to the batch.
38+
*
39+
* @param arguments Arguments of one operation
40+
* @throws SQLException if parameterIndex does not correspond to a parameter marker in the SQL statement;
41+
* if a database access error occurs or this method is called on a closed PreparedStatement
42+
*/
3043
void put(Argument... arguments) throws SQLException;
44+
45+
/**
46+
* Apply the batch to the database.
47+
*
48+
* @throws SQLException if a database access error occurs, this method is called on a closed Statement or the driver does not support batch statements.
49+
* if one of the commands sent to the database fails to execute properly or attempts to return a result set.
50+
* if the driver has determined that the timeout value that was specified by the setQueryTimeout method has been exceeded and has at least attempted to cancel the currently running Statement
51+
*/
3152
void apply() throws SQLException;
53+
54+
/**
55+
* Releases the batch object and JDBC resources. It is generally good practice to release resources as
56+
* soon as you are finished with them to avoid tying up database resources.
57+
*
58+
* @throws SQLException if a database access error occurs
59+
*/
3260
@Override
3361
void close() throws SQLException;
3462
}

src/main/java/com/nmalygin/superb/jdbc/api/Batches.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@
2929
/**
3030
* {@link Batch} factory.
3131
*
32-
* <p>
33-
* Example of use:
34-
* <pre>{@code
35-
* Batch batch = batches.batch("INSERT INTO books(id, title) VALUES (?, ?)");
36-
* }</pre>
37-
*
3832
* @author Nikolai Malygin
3933
*/
4034
public interface Batches {
@@ -44,6 +38,7 @@ public interface Batches {
4438
*
4539
* @param sql Parameterized sql query
4640
* @return The {@link Batch} object
41+
* @throws SQLException if a database access error occurs or database connection is closed
4742
*/
4843
Batch batch(String sql) throws SQLException;
4944
}

src/main/java/com/nmalygin/superb/jdbc/api/Change.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626

2727
import java.sql.SQLException;
2828

29+
/**
30+
* Represents a database query like DML or DDL.
31+
*
32+
* @author Nikolai Malygin
33+
*/
2934
public interface Change {
35+
36+
/**
37+
* Apply the change to the database.
38+
*
39+
* @throws SQLException if a database access error occurs or connection is closed
40+
*/
3041
void apply() throws SQLException;
3142
}

src/main/java/com/nmalygin/superb/jdbc/api/Changes.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@
2727
/**
2828
* {@link Change} factory.
2929
*
30-
* <p>
31-
* Example of use:
32-
* <pre>{@code
33-
* Change change = changes.change(
34-
* "INSERT INTO books (id, title) VALUES (?, ?)",
35-
* new IntParam(1),
36-
* new StringParam("Clean Code"));
37-
* }</pre>
38-
*
3930
* @author Nikolai Malygin
4031
*/
4132
public interface Changes {

src/main/java/com/nmalygin/superb/jdbc/api/Queries.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@
2727
/**
2828
* {@link Query} factory.
2929
*
30-
* <p>
31-
* Example of use:
32-
* <pre>{@code
33-
* Query query = queries.query("SELECT title FROM books);
34-
* }</pre>
35-
*
3630
* @author Nikolai Malygin
3731
*/
3832
public interface Queries {

src/main/java/com/nmalygin/superb/jdbc/api/Query.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,6 @@
2929
/**
3030
* Represents a data retrieval query.
3131
*
32-
* <p>
33-
* Example of use:
34-
* <pre>{@code
35-
* List<String> titles = queries
36-
* .query("SELECT title FROM books")
37-
* .executeWith(/* some handler *&#47;);
38-
* }</pre>
39-
*
4032
* @author Nikolai Malygin
4133
*/
4234
public interface Query extends Appendable<Query> {

src/main/java/com/nmalygin/superb/jdbc/api/Rdbms.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,10 @@
2424

2525
package com.nmalygin.superb.jdbc.api;
2626

27+
/**
28+
* The Relational Database Management System object.
29+
*
30+
* @author Nikolai Malygin
31+
*/
2732
public interface Rdbms extends Queries, Changes, Batches, Transactions {
2833
}

src/main/java/com/nmalygin/superb/jdbc/api/ResultSetHandler.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,20 @@
2727
import java.sql.ResultSet;
2828
import java.sql.SQLException;
2929

30+
/**
31+
* The object that processes the result set of a {@link Query}.
32+
*
33+
* @param <R> Type of the object that return the handle method.
34+
* @author Nikolai Malygin
35+
*/
3036
public interface ResultSetHandler<R> {
37+
38+
/**
39+
*
40+
*
41+
* @param resultSet ResultSet
42+
* @return Some object after processing resultSet
43+
* @throws SQLException
44+
*/
3145
R handle(ResultSet resultSet) throws SQLException;
3246
}

0 commit comments

Comments
 (0)