Return-Path: Delivered-To: apmail-db-ojb-dev-archive@www.apache.org Received: (qmail 72801 invoked from network); 15 Mar 2007 00:53:16 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Mar 2007 00:53:16 -0000 Received: (qmail 27527 invoked by uid 500); 15 Mar 2007 00:53:24 -0000 Delivered-To: apmail-db-ojb-dev-archive@db.apache.org Received: (qmail 27496 invoked by uid 500); 15 Mar 2007 00:53:24 -0000 Mailing-List: contact ojb-dev-help@db.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "OJB Developers List" Reply-To: "OJB Developers List" Delivered-To: mailing list ojb-dev@db.apache.org Received: (qmail 27485 invoked by uid 500); 15 Mar 2007 00:53:24 -0000 Received: (qmail 27482 invoked by uid 99); 15 Mar 2007 00:53:24 -0000 Received: from herse.apache.org (HELO herse.apache.org) (140.211.11.133) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2007 17:53:24 -0700 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 14 Mar 2007 17:53:15 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id E29A61A9838; Wed, 14 Mar 2007 17:52:54 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r518398 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Date: Thu, 15 Mar 2007 00:52:54 -0000 To: ojb-commits@db.apache.org From: arminw@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070315005254.E29A61A9838@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: arminw Date: Wed Mar 14 17:52:54 2007 New Revision: 518398 URL: http://svn.apache.org/viewvc?view=rev&rev=518398 Log: add convenience methods to check for 'null' fields Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java?view=diff&rev=518398&r1=518397&r2=518398 ============================================================================== --- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java (original) +++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldDescriptor.java Wed Mar 14 17:52:54 2007 @@ -331,7 +331,8 @@ } /** - * Returns the NullCheck instance used for this field. + * Returns the {@link NullCheck} instance used for this field. + * * @return NullCheck instance for this field */ public NullCheck getNullCheck() @@ -343,10 +344,55 @@ } return nullCheck; } + + /** + * Returns wether the given object value represents 'null' + * for the specified field. Convenient method for: + *
+ * + * fieldDescriptor.getNullCheck().representsNull(fieldDescriptor, aValue); + * + * + * @param aValue the value to check if it represents 'null' + * @return true if and only if aValue represents null + */ + public boolean representsNull(Object aValue) + { + // if no explicit class is specified use the default implementation + if (nullCheck == null) + { + nullCheck = new NullCheckDefaultImpl(); + } + return nullCheck.representsNull(this, aValue); + } + + /** + * Returns wether the associated object value for this field of + * the specified persistence capable object represents 'null'. + * Convenient method for: + *
+ * + *
+     * Object aValue = fieldDescriptor.getPersistentField().get(obj);
+     * boolean result = fieldDescriptor.getNullCheck().representsNull(fieldDescriptor, aValue);
+     * 
+ *
+ * + * @param obj the persistence capable object to check if the value + * associated with this field represents 'null' + * @return true if and only if the value represents null + */ + public boolean representsNullAssociatedValue(Object obj) + { + return representsNull(getPersistentField().get(obj)); + } /** - * Creates the NullCheck implementation to use for this field. + * Creates the {@link NullCheck} implementation to use for this field. + * * @param nullCheckClassName FQCN of the NullCheck implementation to instantiate + * @see #representsNull(Object) + * @see #getNullCheck() */ public void setNullCheckClassName(String nullCheckClassName) { @@ -354,10 +400,15 @@ { this.nullCheck = (NullCheck) ClassHelper.newInstance(nullCheckClassName); } + catch(ClassNotFoundException e) + { + throw new MetadataException( + "Could not find NullCheck class '" + nullCheckClassName + "'", e); + } catch (Exception e) { throw new MetadataException( - "Could not instantiate NullCheck class using default constructor", e); + "Could not instantiate NullCheck class '" + nullCheckClassName + "' using default constructor", e); } } --------------------------------------------------------------------- To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org For additional commands, e-mail: ojb-dev-help@db.apache.org