db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arm...@apache.org
Subject svn commit: r492856 - /db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java
Date Fri, 05 Jan 2007 02:23:03 GMT
Author: arminw
Date: Thu Jan  4 18:23:03 2007
New Revision: 492856

URL: http://svn.apache.org/viewvc?view=rev&rev=492856
Log:
minor improvements

Modified:
    db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java

Modified: db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java
URL: http://svn.apache.org/viewvc/db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java?view=diff&rev=492856&r1=492855&r2=492856
==============================================================================
--- db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java
(original)
+++ db/ojb/branches/OJB_1_0_RELEASE/src/java/org/apache/ojb/broker/metadata/FieldTypes.java
Thu Jan  4 18:23:03 2007
@@ -47,12 +47,29 @@
     abstract static class BaseFieldType implements FieldType
     {
         /**
+         * The hash code is the hash code of the class.
+         */
+        public int hashCode()
+        {
+            return getClass().hashCode();
+        }
+
+        /**
+         * Returns <em>true</em> if both classes are equals.
+         */
+        public boolean equals(Object obj)
+        {
+            if(this == obj) return true;
+            return obj != null && getClass().equals(obj.getClass());
+        }
+
+        /**
          * Helper method to copy an object if possible.
          *
          * @param toCopy The object to copy.
          * @return The copy of the object or <em>null</em> clone is not supported.
          */
-        private Object copyIfCloneable(Object toCopy)
+        private Object copyIfCloneable(final Object toCopy)
         {
             Object result = null;
             if(toCopy instanceof Cloneable)
@@ -83,7 +100,7 @@
          * @param toCopy The object to copy.
          * @return The copy of the object or <em>null</em> if serialization is
not supported.
          */
-        private Object copyIfSerializeable(Object toCopy)
+        private Object copyIfSerializeable(final Object toCopy)
         {
             Object result = null;
             if(toCopy instanceof Serializable)
@@ -101,7 +118,7 @@
          * @param toCopy The object to copy.
          * @return The copy result.
          */
-        Object copyIfPossible(Object toCopy)
+        Object copyIfPossible(final Object toCopy)
         {
             Object copy = copyIfCloneable(toCopy);
             if(copy == null)
@@ -131,12 +148,12 @@
             return false;
         }
 
-        public Object copy(Object source)
+        public Object copy(final Object source)
         {
             return source;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return ObjectUtils.equals(firstValue, secondValue);
         }
@@ -150,7 +167,7 @@
             return true;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return ObjectUtils.equals(firstValue, secondValue);
         }
@@ -173,7 +190,7 @@
          * @param fieldValue The value to copy.
          * @return A decoupled locator instance.
          */
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue != null)
             {
@@ -195,7 +212,7 @@
          * @param secondValue Second value to compare.
          * @return The comparision state of both fields.
          */
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             LobHandle first = (LobHandle) firstValue;
             LobHandle second = (LobHandle) secondValue;
@@ -279,7 +296,7 @@
     public static class StructFieldType extends MutableFieldType
     {
         // TODO: does this make sense?? or Struct instances always Locator objects?
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue == null) return null;
 
@@ -295,7 +312,7 @@
      */
     public static class JavaObjectFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             if(fieldValue == null) return null;
 
@@ -306,20 +323,20 @@
 
     public static class ByteArrayFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             byte[] result = null;
             if(fieldValue != null)
             {
-                byte[] source = (byte[]) fieldValue;
+                final byte[] source = (byte[]) fieldValue;
                 int length = source.length;
                 result = new byte[length];
-                System.arraycopy(fieldValue, 0, result, 0, length);
+                System.arraycopy(source, 0, result, 0, length);
             }
             return result;
         }
 
-        public boolean equals(Object firstValue, Object secondValue)
+        public boolean equals(final Object firstValue, final Object secondValue)
         {
             return Arrays.equals((byte[]) firstValue, (byte[]) secondValue);
         }
@@ -327,7 +344,7 @@
 
     public static class DateFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Date source = (Date) fieldValue;
             return source != null ? new Date(source.getTime()) : null;
@@ -336,7 +353,7 @@
 
     public static class TimeFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Time source = (Time) fieldValue;
             return source != null ? new Time(source.getTime()) : null;
@@ -345,7 +362,7 @@
 
     public static class TimestampFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             Timestamp result = null;
             if(fieldValue != null)
@@ -359,7 +376,7 @@
 
     public static class URLFieldType extends MutableFieldType
     {
-        public Object copy(Object fieldValue)
+        public Object copy(final Object fieldValue)
         {
             URL url = (URL) fieldValue;
             try



---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org


Mime
View raw message