jena-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rve...@apache.org
Subject svn commit: r1464154 - /jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java
Date Wed, 03 Apr 2013 18:45:37 GMT
Author: rvesse
Date: Wed Apr  3 18:45:37 2013
New Revision: 1464154

URL: http://svn.apache.org/r1464154
Log:
Flesh out all the easy bits of DatasetMetadata

Modified:
    jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java

Modified: jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java
URL: http://svn.apache.org/viewvc/jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java?rev=1464154&r1=1464153&r2=1464154&view=diff
==============================================================================
--- jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java
(original)
+++ jena/Experimental/jena-jdbc/jena-jdbc-core/src/main/java/org/apache/jena/jdbc/metadata/JenaJdbcMetadata.java
Wed Apr  3 18:45:37 2013
@@ -38,11 +38,26 @@ public abstract class JenaJdbcMetadata i
     public static final String CATALOG_TERM = "RDF Store";
 
     /**
+     * Constant for the term used for schemas
+     */
+    public static final String SCHEMA_TERM = "Dataset";
+
+    /**
      * Constant for the default catalog which is the only catalog we report as
      * existing by default
      */
     public static final String DEFAULT_CATALOG = "RDF";
 
+    /**
+     * Constant for the default schema which is the only schema we report as
+     * existing by default
+     */
+    public static final String DEFAULT_SCHEMA = "Dataset";
+
+    protected static final int NO_LIMIT = 0;
+
+    protected static final int UNKNOWN_LIMIT = 0;
+
     private JenaJdbcConnection connection;
 
     /**
@@ -50,7 +65,7 @@ public abstract class JenaJdbcMetadata i
      * 
      * @param connection
      *            Connection
-     * @throws SQLException 
+     * @throws SQLException
      */
     public JenaJdbcMetadata(JenaJdbcConnection connection) throws SQLException {
         if (connection == null)
@@ -181,8 +196,10 @@ public abstract class JenaJdbcMetadata i
     }
 
     public String getExtraNameCharacters() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        // Since SPARQL doesn't really have a notion of identifiers like SQL
+        // does
+        // we return that there are no extra name characters
+        return "";
     }
 
     public ResultSet getFunctionColumns(String arg0, String arg1, String arg2, String arg3)
throws SQLException {
@@ -196,8 +213,8 @@ public abstract class JenaJdbcMetadata i
     }
 
     public String getIdentifierQuoteString() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        // Not supported in SPARQL so return space per the JDBC javadoc
+        return " ";
     }
 
     public ResultSet getImportedKeys(String arg0, String arg1, String arg2) throws SQLException
{
@@ -220,103 +237,105 @@ public abstract class JenaJdbcMetadata i
 
     public int getMaxBinaryLiteralLength() throws SQLException {
         // No limit on RDF term sizes
-        return Integer.MAX_VALUE;
+        return NO_LIMIT;
     }
 
     public int getMaxCatalogNameLength() throws SQLException {
         // No limit on catalog name lengths because we don't
         // really support catalogs
-        return Integer.MAX_VALUE;
+        return NO_LIMIT;
     }
 
     public int getMaxCharLiteralLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // No limit on RDF term sizes
+        return NO_LIMIT;
     }
 
     public int getMaxColumnNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // No limit on column name lengths
+        return NO_LIMIT;
     }
 
     public int getMaxColumnsInGroupBy() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // SPARQL allows arbitrarily many columns in a GROUP BY
+        return NO_LIMIT;
     }
 
     public int getMaxColumnsInIndex() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // RDF stores typically index on up to 3 columns since there are only 4
+        // columns
+        return 3;
     }
 
     public int getMaxColumnsInOrderBy() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // SPARQL allows arbitrarily many columns in ORDER BY
+        return NO_LIMIT;
     }
 
     public int getMaxColumnsInSelect() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // SPARQL allows arbitrarily many columns in SELECT clause
+        return NO_LIMIT;
     }
 
     public int getMaxColumnsInTable() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // RDF stores have up to 4 columns
+        return 4;
     }
 
     public int getMaxConnections() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // Max connections will typically be unlimited
+        return NO_LIMIT;
     }
 
     public int getMaxCursorNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // Named cursors aren't supported so there is no limit
+        return UNKNOWN_LIMIT;
     }
 
     public int getMaxIndexLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // RDF stores typically have no limit on index size, they are as big as
+        // they need to be
+        return NO_LIMIT;
     }
 
     public int getMaxProcedureNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // Procedures aren't supported so unknown
+        return UNKNOWN_LIMIT;
     }
 
     public int getMaxRowSize() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // No limit on triple size
+        return NO_LIMIT;
     }
 
     public int getMaxSchemaNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // We don't really support schemas so there is no limit
+        return NO_LIMIT;
     }
 
     public int getMaxStatementLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // SPARQL Queries/Updates may be arbitrarily large
+        return NO_LIMIT;
     }
 
     public int getMaxStatements() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // We don't impose any limit on this
+        return NO_LIMIT;
     }
 
     public int getMaxTableNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // We don't support tables so there is no limit
+        return NO_LIMIT;
     }
 
     public int getMaxTablesInSelect() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // No limit
+        return NO_LIMIT;
     }
 
     public int getMaxUserNameLength() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        // Authentication is an implementation specific detail so unknown
+        return UNKNOWN_LIMIT;
     }
 
     public String getNumericFunctions() throws SQLException {
@@ -335,7 +354,7 @@ public abstract class JenaJdbcMetadata i
     }
 
     public String getProcedureTerm() throws SQLException {
-        // TODO Auto-generated method stub
+        // Not supported
         return null;
     }
 
@@ -345,17 +364,17 @@ public abstract class JenaJdbcMetadata i
     }
 
     public int getResultSetHoldability() throws SQLException {
-        // TODO Auto-generated method stub
-        return 0;
+        return JenaJdbcConnection.DEFAULT_HOLDABILITY;
     }
 
     public RowIdLifetime getRowIdLifetime() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        // Not supported
+        return RowIdLifetime.ROWID_UNSUPPORTED;
     }
 
     public String getSQLKeywords() throws SQLException {
-        // TODO Auto-generated method stub
+        // TODO Use http://developer.mimer.com/validator/sql-reserved-words.tml
+        // as a reference to implement this
         return null;
     }
 
@@ -364,8 +383,7 @@ public abstract class JenaJdbcMetadata i
     }
 
     public String getSchemaTerm() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        return SCHEMA_TERM;
     }
 
     public ResultSet getSchemas() throws SQLException {
@@ -379,8 +397,8 @@ public abstract class JenaJdbcMetadata i
     }
 
     public String getSearchStringEscape() throws SQLException {
-        // TODO Auto-generated method stub
-        return null;
+        // Does not apply to SPARQL
+        return "";
     }
 
     public String getStringFunctions() throws SQLException {
@@ -446,7 +464,7 @@ public abstract class JenaJdbcMetadata i
     }
 
     public boolean insertsAreDetected(int arg0) throws SQLException {
-        // TODO Auto-generated method stub
+        // We can't detect inserts that happen while streaming results
         return false;
     }
 
@@ -522,38 +540,43 @@ public abstract class JenaJdbcMetadata i
 
     public boolean ownUpdatesAreVisible(int arg0) throws SQLException {
         // Since results are streamed it may be possible to see deletes from
-        // others
-        // depending on the underlying implementation
+        // others depending on the underlying implementation
         return true;
     }
 
     public boolean storesLowerCaseIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
     public boolean storesLowerCaseQuotedIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
     public boolean storesMixedCaseIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
     public boolean storesMixedCaseQuotedIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
     public boolean storesUpperCaseIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
     public boolean storesUpperCaseQuotedIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support identifiers in the way that JDBC means so we say
+        // false
         return false;
     }
 
@@ -594,37 +617,37 @@ public abstract class JenaJdbcMetadata i
     }
 
     public boolean supportsCatalogsInIndexDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // Custom indexes are not supported
         return false;
     }
 
     public boolean supportsCatalogsInPrivilegeDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // SPARQL has no privilege definition statements
         return false;
     }
 
     public boolean supportsCatalogsInProcedureCalls() throws SQLException {
-        // TODO Auto-generated method stub
+        // SPARQL has no procedure calls
         return false;
     }
 
     public boolean supportsCatalogsInTableDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // SPARQL has no table definition statements
         return false;
     }
 
     public boolean supportsColumnAliasing() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL requires aliasing for computed columns
+        return true;
     }
 
     public boolean supportsConvert() throws SQLException {
-        // TODO Auto-generated method stub
+        // JDBC convert is not supported
         return false;
     }
 
     public boolean supportsConvert(int arg0, int arg1) throws SQLException {
-        // TODO Auto-generated method stub
+        // JDBC convert is not supported
         return false;
     }
 
@@ -634,152 +657,155 @@ public abstract class JenaJdbcMetadata i
     }
 
     public boolean supportsCorrelatedSubqueries() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports sub-queries
+        return true;
     }
 
     public boolean supportsDataDefinitionAndDataManipulationTransactions() throws SQLException
{
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL update may be used within a transaction
+        return true;
     }
 
     public boolean supportsDataManipulationTransactionsOnly() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Transactions may consist only of SPARQL updates
+        return true;
     }
 
     public boolean supportsDifferentTableCorrelationNames() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support tables as such so no
         return false;
     }
 
     public boolean supportsExpressionsInOrderBy() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL allows expressions in ORDER BY
+        return true;
     }
 
     public boolean supportsExtendedSQLGrammar() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support SQL
         return false;
     }
 
     public boolean supportsFullOuterJoins() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports all sorts of joins
+        return true;
     }
 
     public boolean supportsGetGeneratedKeys() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL has no notion of auto-generated keys (you can argue that
+        // UUID() counts) but we certainly can't return them
+        return true;
     }
 
     public boolean supportsGroupBy() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports GROUP BY
+        return true;
     }
 
     public boolean supportsGroupByBeyondSelect() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // You can GROUP BY a column that you don't select in SPARQL
+        return true;
     }
 
     public boolean supportsGroupByUnrelated() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // You can GROUP BY a column that you don't select in SPARQL
+        return true;
     }
 
     public boolean supportsIntegrityEnhancementFacility() throws SQLException {
-        // TODO Auto-generated method stub
+        // Integrity Enhancement SQL is not supported
         return false;
     }
 
     public boolean supportsLikeEscapeClause() throws SQLException {
-        // TODO Auto-generated method stub
+        // No LIKE in SPARQL
         return false;
     }
 
     public boolean supportsLimitedOuterJoins() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports all kinds of joins
+        return true;
     }
 
     public boolean supportsMinimumSQLGrammar() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support SQL
         return false;
     }
 
     public boolean supportsMixedCaseIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We have no direct equivalent to SQL identifiers
         return false;
     }
 
     public boolean supportsMixedCaseQuotedIdentifiers() throws SQLException {
-        // TODO Auto-generated method stub
+        // We have no direct equivalent to SQL identifiers
         return false;
     }
 
     public boolean supportsMultipleOpenResults() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // We support multiple open results
+        return true;
     }
 
     public boolean supportsMultipleResultSets() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support multiple result sets from a single execute() call,
+        // we do support this from executeBatch()
         return false;
     }
 
     public boolean supportsMultipleTransactions() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // In principle yes this is possible though exact behaviour may vary by
+        // underlying implementation
+        return true;
     }
 
     public boolean supportsNamedParameters() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support callable statements
         return false;
     }
 
     public boolean supportsNonNullableColumns() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // All columns in a RDF store are non-nullable
+        return true;
     }
 
     public boolean supportsOpenCursorsAcrossCommit() throws SQLException {
-        // TODO Auto-generated method stub
+        // Cursors may be closed depending on the type of commit
         return false;
     }
 
     public boolean supportsOpenCursorsAcrossRollback() throws SQLException {
-        // TODO Auto-generated method stub
+        // Cursors may be closed depending on the type of commit
         return false;
     }
 
     public boolean supportsOpenStatementsAcrossCommit() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Statements remain open across commits
+        return true;
     }
 
     public boolean supportsOpenStatementsAcrossRollback() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Statements remain open across rollbacks
+        return true;
     }
 
     public boolean supportsOrderByUnrelated() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL allows ORDER BY on a column that you don't SELECT
+        return true;
     }
 
     public boolean supportsOuterJoins() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports all kinds of joins
+        return true;
     }
 
     public boolean supportsPositionedDelete() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support deleting from result set
         return false;
     }
 
     public boolean supportsPositionedUpdate() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't support updating from result set
         return false;
     }
 
@@ -789,112 +815,124 @@ public abstract class JenaJdbcMetadata i
     }
 
     public boolean supportsResultSetHoldability(int arg0) throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Both kinds of holdability are supported
+        return true;
     }
 
     public boolean supportsResultSetType(int arg0) throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Currently only FORWARD_ONLY is supported
+        switch (arg0) {
+        case ResultSet.TYPE_FORWARD_ONLY:
+            return true;
+        default:
+            return false;
+        }
     }
 
     public boolean supportsSavepoints() throws SQLException {
-        // TODO Auto-generated method stub
+        // No notion of savepoints
         return false;
     }
 
     public boolean supportsSchemasInDataManipulation() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't really support schemas
         return false;
     }
 
     public boolean supportsSchemasInIndexDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // RDF stores don't allow custom indices
         return false;
     }
 
     public boolean supportsSchemasInPrivilegeDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // SPARQL has no privilege definition statements
         return false;
     }
 
     public boolean supportsSchemasInProcedureCalls() throws SQLException {
-        // TODO Auto-generated method stub
+        // SPARQL has no procedure calls
         return false;
     }
 
     public boolean supportsSchemasInTableDefinitions() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't really support schemas
         return false;
     }
 
     public boolean supportsSelectForUpdate() throws SQLException {
-        // TODO Auto-generated method stub
+        // No SPARQL equivalent
         return false;
     }
 
     public boolean supportsStatementPooling() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't do pooling
         return false;
     }
 
     public boolean supportsStoredFunctionsUsingCallSyntax() throws SQLException {
-        // TODO Auto-generated method stub
+        // Stored procedures are not supported in SPARQL
         return false;
     }
 
     public boolean supportsStoredProcedures() throws SQLException {
-        // TODO Auto-generated method stub
+        // Stored procedures are not supported in SPARQL
         return false;
     }
 
     public boolean supportsSubqueriesInComparisons() throws SQLException {
-        // TODO Auto-generated method stub
+        // Can't use subqueries in this way in SPARQL
         return false;
     }
 
     public boolean supportsSubqueriesInExists() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL does allow sub-queries in EXISTS though strictly speaking our
+        // EXISTS has no relation to the SQL equivalent
+        return true;
     }
 
     public boolean supportsSubqueriesInIns() throws SQLException {
-        // TODO Auto-generated method stub
+        // Can't use subqueries in this way in SPARQL
         return false;
     }
 
     public boolean supportsSubqueriesInQuantifieds() throws SQLException {
-        // TODO Auto-generated method stub
+        // I have no idea what this mean so assume we can't use sub-queries this
+        // way in SPARQL
         return false;
     }
 
     public boolean supportsTableCorrelationNames() throws SQLException {
-        // TODO Auto-generated method stub
+        // We don't really support tables
         return false;
     }
 
     public boolean supportsTransactionIsolationLevel(int arg0) throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // Currently only NONE is supported
+        switch (arg0) {
+        case Connection.TRANSACTION_NONE:
+            return true;
+        default:
+            return false;
+        }
     }
 
     public boolean supportsTransactions() throws SQLException {
-        // TODO Auto-generated method stub
+        // Currently transactions are not supported
         return false;
     }
 
     public boolean supportsUnion() throws SQLException {
-        // TODO Auto-generated method stub
-        return false;
+        // SPARQL supports UNION
+        return true;
     }
 
     public boolean supportsUnionAll() throws SQLException {
-        // TODO Auto-generated method stub
+        // No SPARQL equivalent of UNION ALL
         return false;
     }
 
     public boolean updatesAreDetected(int arg0) throws SQLException {
-        // TODO Auto-generated method stub
+        // Updates are never detectable
         return false;
     }
 



Mime
View raw message