/** {@inheritDoc} */ @Override public Short fromString(String v) { try { return new Short(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Short.class, nbe); } }
/** * Close resultset. * * @param rs * target resultset */ public static void closeResultSet(ResultSet rs) { try { if (rs != null) { rs.close(); } } catch (SQLException e) { throw new FeatureAccessException("An error occur when closing resultset", e); } }
/** * Validate property name and existence * * @param uid * target uid */ protected void assertPropertyExist(String name) { Util.assertHasLength(name); if (!existProperty(name)) { throw new PropertyNotFoundException(name); } }
/** {@inheritDoc} */ @Override public void delete(String fpId) { if (!exist(fpId)) { throw new FeatureNotFoundException(fpId); } getCacheManager().evictFeature(fpId); }
/** {@inheritDoc} */ @Override @Transactional public void delete(String uid) { if (!exist(uid)) throw new FeatureNotFoundException(uid); deletePermissions(uid); deleteProperties(uid); deleteCoreFeature(uid); }
/** * Utility method to close statement properly. * * @param ps * */ public static void closeStatement(PreparedStatement ps) { try { if (ps != null) { ps.close(); } } catch (SQLException e) { throw new FeatureAccessException("An error occur when closing statement", e); } }
/** {@inheritDoc} */ @Override public void deleteProperty(String name) { if (!existProperty(name)) { throw new PropertyNotFoundException(name); } getCacheManager().evictProperty(name); }
/** {@inheritDoc} */ @Override public Integer fromString(String v) { try { return new Integer(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Integer.class, nbe); } }
/** {@inheritDoc} */ @Override public void delete(String uid) { if (!exist(uid)) { throw new FeatureNotFoundException(uid); } // Delete feature key getDriver().deleteKey(getDriver().getFeatureKey(uid)); // Register in the dictionnary getDriver().unregisterFeature(uid); }
/** * Utility method to close statement properly. * * @param ps * */ public static void closeStatement(Statement ps) { try { if (ps != null) { ps.close(); } } catch (SQLException e) { throw new FeatureAccessException("An error occur when closing statement", e); } }
/** {@inheritDoc} */ @Override public Double fromString(String v) { try { return new Double(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Double.class, nbe); } }
/** * Utility method to perform rollback in correct way. * * @param sqlConn * current sql connection */ public static void rollback(Connection sqlConn) { try { if (sqlConn != null && !sqlConn.isClosed()) { sqlConn.rollback(); } } catch (SQLException e) { throw new FeatureAccessException("Cannot rollback database, SQL ERROR", e); } } }
/** {@inheritDoc} */ @Override public BigDecimal fromString(String v) { try { return new BigDecimal(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + BigDecimal.class, nbe); } }
/** {@inheritDoc} */ @Override public Long fromString(String v) { try { return new Long(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Long.class, nbe); } }
/** {@inheritDoc} */ @Override public Float fromString(String v) { try { return new Float(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Float.class, nbe); } }
/** {@inheritDoc} */ @Override public BigInteger fromString(String v) { try { return new BigInteger(v); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + BigInteger.class, nbe); } }
/** {@inheritDoc} */ @Override public Byte fromString(String v) { if (v == null) return null; if (v.length() == 0 || v.length() > 3) { throw new InvalidPropertyTypeException("A byte is a single byte, a single character"); } return v.getBytes()[0]; }
/** {@inheritDoc} */ @Override public Boolean fromString(String v) { if (!Boolean.TRUE.toString().equals(v.toLowerCase()) && !Boolean.FALSE.toString().equals(v) ) { throw new InvalidPropertyTypeException("Cannot cast " + v + "to expected " + Boolean.class); } return new Boolean(v); }
/** {@inheritDoc} */ @Override public float getFloat(String key) { try { return new Float((String) getValue(key)).floatValue(); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot create Float from " + getValue(key), nbe); } }
/** {@inheritDoc} */ @Override public BigDecimal getBigDecimal(String key) { try { return new BigDecimal((String) getValue(key)); } catch(NumberFormatException nbe) { throw new InvalidPropertyTypeException("Cannot create BigDecimal from " + getValue(key), nbe); } }