You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by da...@apache.org on 2017/08/27 16:12:09 UTC
svn commit: r1806375 - in
/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql:
comphelper/OfficeResourceBundle.java util/DbTools.java
util/SharedResources.java
Author: damjan
Date: Sun Aug 27 16:12:09 2017
New Revision: 1806375
URL: http://svn.apache.org/viewvc?rev=1806375&view=rev
Log:
More Javadoc for helper classes.
Patch by: me
Modified:
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/comphelper/OfficeResourceBundle.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/SharedResources.java
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/comphelper/OfficeResourceBundle.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/comphelper/OfficeResourceBundle.java?rev=1806375&r1=1806374&r2=1806375&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/comphelper/OfficeResourceBundle.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/comphelper/OfficeResourceBundle.java Sun Aug 27 16:12:09 2017
@@ -42,8 +42,8 @@ public class OfficeResourceBundle implem
the component context to operate in
@param bundleBaseName
the base name of the resource file which should be accessed (*without* the SUPD!)
- @raises ::com::sun::star::lang::NullPointerException
- if the given component context is <NULL/>
+ @throws com.sun.star.lang.NullPointerException
+ if the given component context is null
*/
public OfficeResourceBundle(XComponentContext context, String bundleBaseName) throws NullPointerException {
if (context == null) {
@@ -64,8 +64,7 @@ public class OfficeResourceBundle implem
the id of the string to load
@return
the requested resource string. If no string with the given id exists in the resource bundle,
- an empty string is returned. In a non-product version, an OSL_ENSURE will notify you of this
- then.
+ an empty string is returned.
*/
public String loadString( int _resourceId ) {
synchronized (this) {
@@ -85,7 +84,7 @@ public class OfficeResourceBundle implem
@param _resourceId
the id of the string whose existence is to be checked
@return
- <TRUE/> if and only if a string with the given ID exists in the resource
+ true if and only if a string with the given ID exists in the resource
bundle.
*/
public boolean hasString( int _resourceId ) {
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java?rev=1806375&r1=1806374&r2=1806375&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/DbTools.java Sun Aug 27 16:12:09 2017
@@ -139,6 +139,8 @@ public class DbTools {
}
}
+ /** compose a complete table name from it's up to three parts, regarding to the database meta data composing rules
+ */
public static String composeTableName(
XDatabaseMetaData metadata, String catalog, String schema, String table, boolean quote, ComposeRule composeRule) throws SQLException {
if (metadata == null) {
@@ -182,6 +184,11 @@ public class DbTools {
shouldQuote, composeRule);
}
+ /** check if a specific property is enabled in the info sequence
+ * @deprecated
+ * Use getBooleanDataSourceSetting instead, which cares for the default of the property itself,
+ * instead of spreading this knowledge through all callers.
+ */
public static boolean isDataSourcePropertyEnabled(Object object, String property, boolean defaultValue) throws SQLException {
try {
boolean enabled = defaultValue;
@@ -201,6 +208,8 @@ public class DbTools {
}
}
+ /** search the parent hierarchy for a data source.
+ */
public static XDataSource findDataSource(Object parent) {
XOfficeDatabaseDocument databaseDocument = UnoRuntime.queryInterface(XOfficeDatabaseDocument.class, parent);
XDataSource dataSource = null;
@@ -252,6 +261,12 @@ public class DbTools {
return composedName.toString();
}
+ /** composes a table name for usage in a SELECT statement
+ *
+ * This includes quoting of the table as indicated by the connection's meta data, plus respecting
+ * the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
+ * in the data source which the connection belongs to.
+ */
public static String composeTableNameForSelect(XConnection connection, String catalog,
String schema, String table) throws SQLException {
boolean useCatalogInSelect = isDataSourcePropertyEnabled(connection, "UseCatalogInSelect", true);
@@ -260,6 +275,12 @@ public class DbTools {
useSchemaInSelect ? schema : "", table, true, ComposeRule.InDataManipulation);
}
+ /** composes a table name for usage in a SELECT statement
+ *
+ * This includes quoting of the table as indicated by the connection's meta data, plus respecting
+ * the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
+ * in the data source which the connection belongs to.
+ */
public static String composeTableNameForSelect(XConnection connection, XPropertySet table) throws SQLException {
NameComponents nameComponents = getTableNameComponents(table);
return composeTableNameForSelect(connection, nameComponents.getCatalog(), nameComponents.getSchema(), nameComponents.getTable());
@@ -285,6 +306,8 @@ public class DbTools {
}
}
+ /** quote the given name with the given quote string.
+ */
public static String quoteName(String quote, String name) {
if (!quote.isEmpty() && quote.codePointAt(0) != ' ') {
return quote + name + quote;
@@ -292,11 +315,19 @@ public class DbTools {
return name;
}
+ /** quote the given table name (which may contain a catalog and a schema) according to the rules provided by the meta data
+ */
public static String quoteTableName(XDatabaseMetaData metadata, String name, ComposeRule composeRule) throws SQLException {
NameComponents nameComponents = qualifiedNameComponents(metadata, name, composeRule);
return doComposeTableName(metadata, nameComponents.getCatalog(), nameComponents.getSchema(), nameComponents.getTable(), true, composeRule);
}
+ /** split a fully qualified table name (including catalog and schema, if applicable) into its component parts.
+ * @param _rxConnMetaData meta data describing the connection where you got the table name from
+ * @param _rQualifiedName fully qualified table name
+ * @param _eComposeRule where do you need the name for
+ * @return the NameComponents object with the catalog, schema and table
+ */
public static NameComponents qualifiedNameComponents(XDatabaseMetaData _rxConnMetaData, String _rQualifiedName,
ComposeRule _eComposeRule) throws SQLException {
Osl.ensure(_rxConnMetaData, "QualifiedNameComponents : invalid meta data!");
@@ -339,6 +370,19 @@ public class DbTools {
return ret;
}
+ /** creates a SQL CREATE TABLE statement
+ *
+ * @param descriptor
+ * The descriptor of the new table.
+ * @param connection
+ * The connection.
+ * @param helper
+ * Allow to add special SQL constructs.
+ * @param createPattern
+ *
+ * @return
+ * The CREATE TABLE statement.
+ */
public static String createSqlCreateTableStatement(XPropertySet descriptor, XConnection connection,
ISQLStatementHelper helper, String createPattern) throws SQLException {
@@ -352,6 +396,16 @@ public class DbTools {
return sql;
}
+ /** creates the standard sql create table statement without the key part.
+ * @param descriptor
+ * The descriptor of the new table.
+ * @param connection
+ * The connection.
+ * @param helper
+ * Allow to add special SQL constructs.
+ * @param createPattern
+ *
+ */
public static String createStandardCreateStatement(XPropertySet descriptor, XConnection connection,
ISQLStatementHelper helper, String createPattern) throws SQLException {
try {
@@ -394,6 +448,16 @@ public class DbTools {
}
}
+ /** creates the standard sql statement for the column part of a create table statement.
+ * @param columnProperties
+ * The descriptor of the column.
+ * @param connection
+ * The connection.
+ * @param helper
+ * Allow to add special SQL constructs.
+ * @param createPattern
+ *
+ */
public static String createStandardColumnPart(XPropertySet columnProperties, XConnection connection,
ISQLStatementHelper helper, String createPattern) throws SQLException {
try {
@@ -507,6 +571,12 @@ public class DbTools {
}
}
+ /** creates the standard sql statement for the key part of a create table statement.
+ * @param descriptor
+ * The descriptor of the new table.
+ * @param connection
+ * The connection.
+ */
public static String createStandardKeyStatement(XPropertySet descriptor, XConnection connection) throws SQLException {
try {
XDatabaseMetaData metadata = connection.getMetaData();
@@ -601,7 +671,17 @@ public class DbTools {
return sql.toString();
}
- /// We need some more information about the column.
+ /** collects the information about auto increment, currency and data type for the given column name.
+ * The column must be quoted, * is also valid.
+ * @param connection
+ * The connection.
+ * @param composedName
+ * The quoted table name. ccc.sss.ttt
+ * @param columnName
+ * The name of the column, or *
+ * @return
+ * The information about the column(s).
+ */
public static Map<String,ExtraColumnInfo> collectColumnInformation(XConnection connection, String composedName, String columnName) throws SQLException {
String sql = String.format("SELECT %s FROM %s WHERE 0 = 1", columnName, composedName);
XStatement statement = null;
@@ -632,6 +712,8 @@ public class DbTools {
}
}
+ /** returns the primary key columns of the table
+ */
public static XNameAccess getPrimaryKeyColumns(XPropertySet table) throws SQLException {
try {
XNameAccess keyColumns = null;
Modified: openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/SharedResources.java
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/SharedResources.java?rev=1806375&r1=1806374&r2=1806375&view=diff
==============================================================================
--- openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/SharedResources.java (original)
+++ openoffice/trunk/main/connectivity/java/sdbc_postgresql/src/com/sun/star/sdbcx/comp/postgresql/util/SharedResources.java Sun Aug 27 16:12:09 2017
@@ -105,7 +105,7 @@ public class SharedResources {
@param _nResId
the resource ID of the string to load
@param _pAsciiPatternToReplace
- the ASCII string which is to search in the string. Must not be <NULL/>.
+ the ASCII string which is to search in the string. Must not be null.
@param _rStringToSubstitute
the String which should substitute the ASCII pattern.
@@ -129,11 +129,11 @@ public class SharedResources {
@param _nResId
the resource ID of the string to load
@param _pAsciiPatternToReplace1
- the ASCII string (1) which is to search in the string. Must not be <NULL/>.
+ the ASCII string (1) which is to search in the string. Must not be null.
@param _rStringToSubstitute1
the String which should substitute the ASCII pattern (1)
@param _pAsciiPatternToReplace2
- the ASCII string (2) which is to search in the string. Must not be <NULL/>.
+ the ASCII string (2) which is to search in the string. Must not be null.
@param _rStringToSubstitute2
the String which should substitute the ASCII pattern (2)
@@ -160,15 +160,15 @@ public class SharedResources {
@param _nResId
the resource ID of the string to load
@param _pAsciiPatternToReplace1
- the ASCII string (1) which is to search in the string. Must not be <NULL/>.
+ the ASCII string (1) which is to search in the string. Must not be null.
@param _rStringToSubstitute1
the String which should substitute the ASCII pattern (1)
@param _pAsciiPatternToReplace2
- the ASCII string (2) which is to search in the string. Must not be <NULL/>.
+ the ASCII string (2) which is to search in the string. Must not be null.
@param _rStringToSubstitute2
the String which should substitute the ASCII pattern (2)
@param _pAsciiPatternToReplace3
- the ASCII string (3) which is to search in the string. Must not be <NULL/>.
+ the ASCII string (3) which is to search in the string. Must not be null.
@param _rStringToSubstitute3
the String which should substitute the ASCII pattern (3)
@@ -196,7 +196,7 @@ public class SharedResources {
@param _nResId
the resource ID of the string to load
- @param _aStringToSubstitutes
+ @param patternsAndSubstitutes
A list of substitutions.
@return