Skip to content

Commit

Permalink
Fix module visibility issues in org.firebirdsql.jdbc
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Jul 8, 2023
1 parent 1b49ac3 commit ba3bc94
Show file tree
Hide file tree
Showing 34 changed files with 266 additions and 277 deletions.
3 changes: 3 additions & 0 deletions src/docs/asciidoc/release_notes.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1200,6 +1200,9 @@ The new package is not exported from the module.
** `ReflectionHelper`
** `SQLExceptionChainBuilder`
** `StringUtils`
* `DbMetadataMediator` was moved to package `org.firebirdsql.jdbc` for module accessibility reasons.
+
Although uncommon, custom connection implementations may need this to be able to write custom database metadata implementations.

[#breaking-changes-unlikely]
=== Unlikely breaking changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
*
* All rights reserved.
*/
package org.firebirdsql.jdbc.metadata;
package org.firebirdsql.jdbc;

import org.firebirdsql.encodings.EncodingFactory;
import org.firebirdsql.gds.impl.GDSType;
import org.firebirdsql.gds.ng.DatatypeCoder;
import org.firebirdsql.gds.ng.DefaultDatatypeCoder;
import org.firebirdsql.jdbc.FBDatabaseMetaData;
import org.firebirdsql.gds.ng.fields.RowDescriptorBuilder;
import org.firebirdsql.util.FirebirdSupportInfo;
import org.firebirdsql.util.InternalApi;

Expand All @@ -43,15 +43,19 @@
@InternalApi
public abstract class DbMetadataMediator {

static final DatatypeCoder datatypeCoder =
private static final DatatypeCoder datatypeCoder =
DefaultDatatypeCoder.forEncodingFactory(EncodingFactory.createInstance(StandardCharsets.UTF_8));

public static RowDescriptorBuilder newRowDescriptorBuilder(int size) {
return new RowDescriptorBuilder(size, datatypeCoder);
}

/**
* Provides the {@link FirebirdSupportInfo} for the connection of the associated database metadata.
*
* @return Firebird support info object.
*/
protected abstract FirebirdSupportInfo getFirebirdSupportInfo();
public abstract FirebirdSupportInfo getFirebirdSupportInfo();

/**
* Executes the provided metadata query on the connection of the associated database metadata.
Expand All @@ -62,32 +66,32 @@ public abstract class DbMetadataMediator {
* @throws SQLException
* For failures to execute the query
*/
protected abstract ResultSet performMetaDataQuery(MetadataQuery metadataQuery) throws SQLException;
public abstract ResultSet performMetaDataQuery(MetadataQuery metadataQuery) throws SQLException;

/**
* A {@code FBDatabaseMetaData} instance of the connection that created this mediator.
*
* @return metadata instance
*/
protected abstract FBDatabaseMetaData getMetaData();
public abstract FBDatabaseMetaData getMetaData();

/**
* @return GDSType of the current connection
*/
protected abstract GDSType getGDSType();
public abstract GDSType getGDSType();

/**
* @return value of the {@code useCatalogAsPackage} connection property if packages are supported, otherwise
* {@code false}
* @since 6
*/
protected abstract boolean isUseCatalogAsPackage();
public abstract boolean isUseCatalogAsPackage();

/**
* @return the client info properties to report for {@link FBDatabaseMetaData#getClientInfoProperties()}.
* @since 6
*/
protected abstract Collection<String> getClientInfoPropertyNames();
public abstract Collection<String> getClientInfoPropertyNames();

/**
* Holder class for query text and parameters.
Expand Down
12 changes: 6 additions & 6 deletions src/main/org/firebirdsql/jdbc/FBDatabaseMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1990,33 +1990,33 @@ protected DbMetadataMediator getDbMetadataMediator() {
private final class DbMetadataMediatorImpl extends DbMetadataMediator {

@Override
protected FirebirdSupportInfo getFirebirdSupportInfo() {
public FirebirdSupportInfo getFirebirdSupportInfo() {
return firebirdSupportInfo;
}

@Override
protected ResultSet performMetaDataQuery(MetadataQuery metadataQuery) throws SQLException {
public ResultSet performMetaDataQuery(MetadataQuery metadataQuery) throws SQLException {
return doQuery(metadataQuery.getQueryText(), metadataQuery.getParameters(), metadataQuery.isStandalone());
}

@Override
protected FBDatabaseMetaData getMetaData() {
public FBDatabaseMetaData getMetaData() {
return FBDatabaseMetaData.this;
}

@Override
protected GDSType getGDSType() {
public GDSType getGDSType() {
return FBDatabaseMetaData.this.getGDSType();
}

@Override
protected boolean isUseCatalogAsPackage() {
public boolean isUseCatalogAsPackage() {
return gdsHelper.getConnectionProperties().isUseCatalogAsPackage()
&& firebirdSupportInfo.supportsPackages();
}

@Override
protected Collection<String> getClientInfoPropertyNames() {
public Collection<String> getClientInfoPropertyNames() {
if (firebirdSupportInfo.supportsGetSetContext()) {
try {
return connection.getClientInfoProvider().getDefaultClientInfoPropertyNames();
Expand Down
3 changes: 2 additions & 1 deletion src/main/org/firebirdsql/jdbc/FBFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
/**
* Instances of this class are able to fetch records from the server.
*/
interface FBFetcher {
public sealed interface FBFetcher
permits FBCachedFetcher, FBServerScrollFetcher, FBStatementFetcher, FBUpdatableFetcher {

int DEFAULT_FETCH_ROWS = 400;

Expand Down
36 changes: 23 additions & 13 deletions src/main/org/firebirdsql/jdbc/FBObjectListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,25 @@
package org.firebirdsql.jdbc;

import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.util.InternalApi;

import java.sql.ResultSet;
import java.sql.SQLException;

/**
* This interface defines set of listeners that will be called in different situations.
* Defines a set of listeners that will be called in different situations.
*
* @author Roman Rokytskyy
* @author Mark Rotteveel
*/
public interface FBObjectListener {
@InternalApi
public final class FBObjectListener {

interface FetcherListener {
private FBObjectListener() {
// no instances
}

public interface FetcherListener {

/**
* Notify listener that underlying fetcher is closed.
Expand Down Expand Up @@ -63,7 +69,7 @@ interface FetcherListener {
/**
* Listener for the events generated by the result set.
*/
interface ResultSetListener {
public interface ResultSetListener {

/**
* Notify listener that result set was closed.
Expand All @@ -88,7 +94,7 @@ interface ResultSetListener {
* @param updater
* instance of {@link FirebirdRowUpdater}
* @throws SQLException
* if somewthing went wrong.
* if something went wrong.
*/
void executionStarted(FirebirdRowUpdater updater) throws SQLException;

Expand All @@ -107,7 +113,7 @@ interface ResultSetListener {
* Implementation of {@link org.firebirdsql.jdbc.FBObjectListener.ResultSetListener} that implements all methods as
* empty methods.
*/
final class NoActionResultSetListener implements ResultSetListener {
public static final class NoActionResultSetListener implements ResultSetListener {

private static final ResultSetListener INSTANCE = new NoActionResultSetListener();

Expand All @@ -119,19 +125,23 @@ private NoActionResultSetListener() {
}

@Override
public void resultSetClosed(ResultSet rs) throws SQLException { }
public void resultSetClosed(ResultSet rs) { }

@Override
public void allRowsFetched(ResultSet rs) throws SQLException { }
public void allRowsFetched(ResultSet rs) { }

@Override
public void executionStarted(FirebirdRowUpdater updater) throws SQLException { }
public void executionStarted(FirebirdRowUpdater updater) { }

@Override
public void executionCompleted(FirebirdRowUpdater updater, boolean success) throws SQLException { }
public void executionCompleted(FirebirdRowUpdater updater, boolean success) { }

}

/**
* Listener for the events generated by statements.
*/
interface StatementListener {
public interface StatementListener {

/**
* Get the connection object to which this listener belongs to.
Expand Down Expand Up @@ -186,7 +196,7 @@ void statementCompleted(FBStatement stmt, boolean success)
/**
* Listener for the events generated by BLOBs.
*/
interface BlobListener {
public interface BlobListener {

/**
* Notify listener that execution of some BLOB operation had been started.
Expand All @@ -213,7 +223,7 @@ interface BlobListener {
* Implementation of {@link org.firebirdsql.jdbc.FBObjectListener.BlobListener} that implements all methods as
* empty methods.
*/
final class NoActionBlobListener implements BlobListener {
public static final class NoActionBlobListener implements BlobListener {

private static final BlobListener INSTANCE = new NoActionBlobListener();

Expand Down
2 changes: 1 addition & 1 deletion src/main/org/firebirdsql/jdbc/FBStatementFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
* by the cursor position after {@link #next()} call. This class changes cursor
* position to point to the next row.
*/
class FBStatementFetcher implements FBFetcher {
sealed class FBStatementFetcher implements FBFetcher permits FBUpdatableCursorFetcher {

private static final int NO_ASYNC_FETCH = -1;
private static final int MINIMUM_ASYNC_FETCH_ROW_COUNT = 10;
Expand Down
2 changes: 1 addition & 1 deletion src/main/org/firebirdsql/jdbc/FirebirdRowUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
* Interface for the clean separation of the classes between result set and corresponding row updater.
*/
@InternalApi
interface FirebirdRowUpdater {
public sealed interface FirebirdRowUpdater permits FBRowUpdater {

void cancelRowUpdates() throws SQLException;

Expand Down
24 changes: 9 additions & 15 deletions src/main/org/firebirdsql/jdbc/metadata/AbstractKeysMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowDescriptorBuilder;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.DbMetadataMediator;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
Expand All @@ -38,7 +38,7 @@
*/
abstract class AbstractKeysMethod extends AbstractMetadataMethod {

private static final RowDescriptor ROW_DESCRIPTOR = new RowDescriptorBuilder(14, DbMetadataMediator.datatypeCoder)
private static final RowDescriptor ROW_DESCRIPTOR = DbMetadataMediator.newRowDescriptorBuilder(14)
.at(0).simple(SQL_VARYING | 1, OBJECT_NAME_LENGTH, "PKTABLE_CAT", "COLUMNINFO").addField()
.at(1).simple(SQL_VARYING | 1, OBJECT_NAME_LENGTH, "PKTABLE_SCHEM", "COLUMNINFO").addField()
.at(2).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "PKTABLE_NAME", "COLUMNINFO").addField()
Expand Down Expand Up @@ -83,20 +83,14 @@ final RowValue createMetadataRow(ResultSet rs, RowValueBuilder valueBuilder) thr
* @return database metadata constant value
*/
private static Integer mapAction(String firebirdActionName) {
switch (firebirdActionName) {
case "RESTRICT":
return switch (firebirdActionName) {
// NOTE: Firebird has no "RESTRICT", however this mapping (to importedKeyNoAction) was also present in
// the previous implementation, so preserving it just in case.
case "NO ACTION":
return DatabaseMetaData.importedKeyNoAction;
case "CASCADE":
return DatabaseMetaData.importedKeyCascade;
case "SET NULL":
return DatabaseMetaData.importedKeySetNull;
case "SET DEFAULT":
return DatabaseMetaData.importedKeySetDefault;
default:
return null;
}
case "RESTRICT", "NO ACTION" -> DatabaseMetaData.importedKeyNoAction;
case "CASCADE" -> DatabaseMetaData.importedKeyCascade;
case "SET NULL" -> DatabaseMetaData.importedKeySetNull;
case "SET DEFAULT" -> DatabaseMetaData.importedKeySetDefault;
default -> null;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.DbMetadataMediator;
import org.firebirdsql.jdbc.DbMetadataMediator.MetadataQuery;
import org.firebirdsql.jdbc.FBResultSet;
import org.firebirdsql.jdbc.metadata.DbMetadataMediator.MetadataQuery;

import java.sql.ResultSet;
import java.sql.SQLException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
*/
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.jdbc.DbMetadataMediator;

/**
* Metadata information related to catalogs.
* <p>
Expand Down
4 changes: 2 additions & 2 deletions src/main/org/firebirdsql/jdbc/metadata/GetAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowDescriptorBuilder;
import org.firebirdsql.jdbc.DbMetadataMediator;
import org.firebirdsql.jdbc.FBResultSet;

import java.sql.ResultSet;
Expand All @@ -39,7 +39,7 @@
*/
public final class GetAttributes {

private static final RowDescriptor ROW_DESCRIPTOR = new RowDescriptorBuilder(21, DbMetadataMediator.datatypeCoder)
private static final RowDescriptor ROW_DESCRIPTOR = DbMetadataMediator.newRowDescriptorBuilder(21)
.at(0).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "TYPE_CAT", "ATTRIBUTES").addField()
.at(1).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "TYPE_SCHEM", "ATTRIBUTES").addField()
.at(2).simple(SQL_VARYING, 31, "TYPE_NAME", "ATTRIBUTES").addField()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowDescriptorBuilder;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.DbMetadataMediator;
import org.firebirdsql.jdbc.DbMetadataMediator.MetadataQuery;
import org.firebirdsql.jdbc.FBDatabaseMetaData;
import org.firebirdsql.jdbc.FBResultSet;
import org.firebirdsql.jdbc.metadata.DbMetadataMediator.MetadataQuery;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
Expand Down Expand Up @@ -58,7 +58,7 @@
*/
public final class GetBestRowIdentifier extends AbstractMetadataMethod {

private static final RowDescriptor ROW_DESCRIPTOR = new RowDescriptorBuilder(8, DbMetadataMediator.datatypeCoder)
private static final RowDescriptor ROW_DESCRIPTOR = DbMetadataMediator.newRowDescriptorBuilder(8)
.at(0).simple(SQL_SHORT, 0, "SCOPE", "ROWIDENTIFIER").addField()
.at(1).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "COLUMN_NAME", "ROWIDENTIFIER").addField()
.at(2).simple(SQL_LONG, 0, "DATA_TYPE", "ROWIDENTIFIER").addField()
Expand Down
6 changes: 3 additions & 3 deletions src/main/org/firebirdsql/jdbc/metadata/GetCatalogs.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
package org.firebirdsql.jdbc.metadata;

import org.firebirdsql.gds.ng.fields.RowDescriptor;
import org.firebirdsql.gds.ng.fields.RowDescriptorBuilder;
import org.firebirdsql.gds.ng.fields.RowValue;
import org.firebirdsql.jdbc.metadata.DbMetadataMediator.MetadataQuery;
import org.firebirdsql.jdbc.DbMetadataMediator;
import org.firebirdsql.jdbc.DbMetadataMediator.MetadataQuery;

import java.sql.DatabaseMetaData;
import java.sql.ResultSet;
Expand All @@ -39,7 +39,7 @@
*/
public sealed class GetCatalogs extends AbstractMetadataMethod {

private static final RowDescriptor ROW_DESCRIPTOR = new RowDescriptorBuilder(1, DbMetadataMediator.datatypeCoder)
private static final RowDescriptor ROW_DESCRIPTOR = DbMetadataMediator.newRowDescriptorBuilder(1)
.at(0).simple(SQL_VARYING, OBJECT_NAME_LENGTH, "TABLE_CAT", "TABLECATALOGS").addField()
.toRowDescriptor();

Expand Down
Loading

0 comments on commit ba3bc94

Please sign in to comment.