/** * Returns whether a result set is expected to type returned columns as * strings * * @param level * Desired compatibility level * @return True if columns should be typed as string, false otherwise */ public static boolean shouldTypeColumnsAsString(int level) { level = normalizeLevel(level); return level >= MEDIUM && level < HIGH; }
/** * Returns whether a result set is expected to determine the column types * from the returned data * * @param level * Desired compatibility level * @return True if column types should be detected, false otherwise */ public static boolean shouldDetectColumnTypes(int level) { level = normalizeLevel(level); return level == HIGH; }
/** * Returns whether a result set is expected to type returned columns as * strings * * @param level * Desired compatibility level * @return True if columns should be typed as string, false otherwise */ public static boolean shouldTypeColumnsAsString(int level) { level = normalizeLevel(level); return level >= MEDIUM && level < HIGH; }
/** * Returns whether a result set is expected to determine the column types * from the returned data * * @param level * Desired compatibility level * @return True if column types should be detected, false otherwise */ public static boolean shouldDetectColumnTypes(int level) { level = normalizeLevel(level); return level == HIGH; }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * By default this is set at the connection level and inherited, however you * may call {@link #setJdbcCompatibilityLevel(int)} to set the compatibility * level for this statement. This allows you to change the compatibility * level on a per-query basis if so desired. * </p> * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { if (level == USE_CONNECTION_COMPATIBILITY) { this.compatibilityLevel = USE_CONNECTION_COMPATIBILITY; } else { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); } }
/** * Sets the JDBC compatibility level that is in use, see * {@link JdbcCompatibility} for explanations. * <p> * By default this is set at the connection level and inherited, however you * may call {@link #setJdbcCompatibilityLevel(int)} to set the compatibility * level for this statement. This allows you to change the compatibility * level on a per-query basis if so desired. * </p> * <p> * Changing the level may not effect existing open objects, behaviour in * this case will be implementation specific. * </p> * * @param level * Compatibility level */ public void setJdbcCompatibilityLevel(int level) { if (level == USE_CONNECTION_COMPATIBILITY) { this.compatibilityLevel = USE_CONNECTION_COMPATIBILITY; } else { this.compatibilityLevel = JdbcCompatibility.normalizeLevel(level); } }
/** * Parses the JDBC compatibility level from the given object and normalizes * it if necessary. If the given object is null or does not contain a valid * integer value (or can be parsed as such) then the returned compatibility * level will be {@link #DEFAULT} * * @param object * Object to parse * @return Normalized JDBC compatibility level */ public static int parseLevel(Object object) { if (object == null) { return DEFAULT; } else if (object instanceof Integer) { return normalizeLevel((Integer) object); } else { try { int level = Integer.parseInt(object.toString()); return normalizeLevel(level); } catch (NumberFormatException e) { return DEFAULT; } } } }
/** * Parses the JDBC compatibility level from the given object and normalizes * it if necessary. If the given object is null or does not contain a valid * integer value (or can be parsed as such) then the returned compatibility * level will be {@link #DEFAULT} * * @param object * Object to parse * @return Normalized JDBC compatibility level */ public static int parseLevel(Object object) { if (object == null) { return DEFAULT; } else if (object instanceof Integer) { return normalizeLevel((Integer) object); } else { try { int level = Integer.parseInt(object.toString()); return normalizeLevel(level); } catch (NumberFormatException e) { return DEFAULT; } } } }
/** * Creates a new result set * * @param statement * Statement that originated the result set * @throws SQLException * Thrown if the arguments are invalid */ public JenaResultSet(JenaStatement statement) throws SQLException { if (statement == null) throw new SQLException("Statement for a Result Set cannot be null"); this.statement = statement; this.compatibilityLevel = JdbcCompatibility .normalizeLevel(this.statement.getJdbcCompatibilityLevel()); }
/** * Creates a new result set * * @param statement * Statement that originated the result set * @throws SQLException * Thrown if the arguments are invalid */ public JenaResultSet(JenaStatement statement) throws SQLException { if (statement == null) throw new SQLException("Statement for a Result Set cannot be null"); this.statement = statement; this.compatibilityLevel = JdbcCompatibility .normalizeLevel(this.statement.getJdbcCompatibilityLevel()); }
/** * Tests constants are not normalized to different values */ @Test public void test_level_normalization_01() { Assert.assertEquals(JdbcCompatibility.LOW, JdbcCompatibility.normalizeLevel(JdbcCompatibility.LOW)); Assert.assertEquals(JdbcCompatibility.MEDIUM, JdbcCompatibility.normalizeLevel(JdbcCompatibility.MEDIUM)); Assert.assertEquals(JdbcCompatibility.HIGH, JdbcCompatibility.normalizeLevel(JdbcCompatibility.HIGH)); Assert.assertEquals(JdbcCompatibility.MEDIUM, JdbcCompatibility.normalizeLevel(JdbcCompatibility.DEFAULT)); }
/** * Creates a new connection * * @param holdability * Cursor holdability * @param autoCommit * Sets auto-commit behaviour for the connection * @param transactionLevel * Sets transaction isolation level for the connection * @param compatibilityLevel * Sets JDBC compatibility level for the connection, see * {@link JdbcCompatibility} * @throws SQLException * Thrown if the arguments are invalid */ public JenaConnection(int holdability, boolean autoCommit, int transactionLevel, int compatibilityLevel) throws SQLException { this.checkHoldability(holdability); this.holdability = holdability; this.setAutoCommit(autoCommit); this.setTransactionIsolation(transactionLevel); this.compatibilityLevel = JdbcCompatibility.normalizeLevel(compatibilityLevel); }
/** * Test values outside range are normalized to range ends */ @Test public void test_level_normalization_02() { Assert.assertEquals(JdbcCompatibility.LOW, JdbcCompatibility.normalizeLevel(Integer.MIN_VALUE)); Assert.assertEquals(JdbcCompatibility.HIGH, JdbcCompatibility.normalizeLevel(Integer.MAX_VALUE)); }
/** * Creates a new connection * * @param holdability * Cursor holdability * @param autoCommit * Sets auto-commit behaviour for the connection * @param transactionLevel * Sets transaction isolation level for the connection * @param compatibilityLevel * Sets JDBC compatibility level for the connection, see * {@link JdbcCompatibility} * @throws SQLException * Thrown if the arguments are invalid */ public JenaConnection(int holdability, boolean autoCommit, int transactionLevel, int compatibilityLevel) throws SQLException { this.checkHoldability(holdability); this.holdability = holdability; this.setAutoCommit(autoCommit); this.setTransactionIsolation(transactionLevel); this.compatibilityLevel = JdbcCompatibility.normalizeLevel(compatibilityLevel); }
/** * Test all values in acceptable range are left as is */ @Test public void test_level_normalization_03() { for (int i = 1; i <= 9; i++) { Assert.assertEquals(i, JdbcCompatibility.normalizeLevel(i)); } }
ColumnInfo[] columns = new ColumnInfo[vars.size()]; int level = JdbcCompatibility.normalizeLevel(results.getJdbcCompatibilityLevel()); boolean columnsAsStrings = JdbcCompatibility.shouldTypeColumnsAsString(level); boolean columnsDetected = JdbcCompatibility.shouldDetectColumnTypes(level);
ColumnInfo[] columns = new ColumnInfo[vars.size()]; int level = JdbcCompatibility.normalizeLevel(results.getJdbcCompatibilityLevel()); boolean columnsAsStrings = JdbcCompatibility.shouldTypeColumnsAsString(level); boolean columnsDetected = JdbcCompatibility.shouldDetectColumnTypes(level);
int level = JdbcCompatibility.normalizeLevel(results.getJdbcCompatibilityLevel()); boolean columnsAsStrings = JdbcCompatibility.shouldTypeColumnsAsString(level); boolean columnsDetected = JdbcCompatibility.shouldDetectColumnTypes(level);