ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From voze...@apache.org
Subject [4/4] ignite git commit: IGNITE-1917: Refactoring: date, timestamp.
Date Wed, 18 Nov 2015 14:25:14 GMT
IGNITE-1917: Refactoring: date, timestamp.


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e137f8fb
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e137f8fb
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e137f8fb

Branch: refs/heads/ignite-1917
Commit: e137f8fb34a2b8b0295bc7311166265ce0f33c62
Parents: e9bf534
Author: vozerov-gridgain <vozerov@gridgain.com>
Authored: Wed Nov 18 17:25:54 2015 +0300
Committer: vozerov-gridgain <vozerov@gridgain.com>
Committed: Wed Nov 18 17:25:54 2015 +0300

----------------------------------------------------------------------
 .../internal/portable/BinaryReaderExImpl.java   | 178 ++++++++-----------
 1 file changed, 76 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e137f8fb/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
index c4014eb..018ef74 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/portable/BinaryReaderExImpl.java
@@ -308,38 +308,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable Date readDate(int fieldId) throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            if (checkFlag(DATE) == Flag.NULL)
-                return null;
-
-            return doReadDate();
-        }
-        else
-            return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
-    @Nullable Timestamp readTimestamp(int fieldId) throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            if (checkFlag(TIMESTAMP) == Flag.NULL)
-                return null;
-
-            return doReadTimestamp();
-        }
-        else
-            return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
     @Nullable Object readObject(int fieldId) throws BinaryObjectException {
         return findFieldById(fieldId) ? doReadObject() : null;
     }
@@ -349,42 +317,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
      * @return Value.
      * @throws BinaryObjectException In case of error.
      */
-    @Nullable Date[] readDateArray(int fieldId) throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            Flag flag = checkFlag(DATE_ARR);
-
-            if (flag == Flag.NORMAL)
-                return doReadDateArray();
-            else if (flag == Flag.HANDLE)
-                return readHandleField();
-        }
-
-        return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
-    @Nullable Timestamp[] readTimestampArray(int fieldId) throws BinaryObjectException {
-        if (findFieldById(fieldId)) {
-            Flag flag = checkFlag(TIMESTAMP_ARR);
-
-            if (flag == Flag.NORMAL)
-                return doReadTimestampArray();
-            else if (flag == Flag.HANDLE)
-                return readHandleField();
-        }
-
-        return null;
-    }
-
-    /**
-     * @param fieldId Field ID.
-     * @return Value.
-     * @throws BinaryObjectException In case of error.
-     */
     @Nullable Object[] readObjectArray(int fieldId) throws BinaryObjectException {
         if (findFieldById(fieldId)) {
             Flag flag = checkFlag(OBJ_ARR);
@@ -1162,71 +1094,113 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx,
Obje
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Date readDate(String fieldName) throws BinaryObjectException
{
-        return readDate(fieldId(fieldName));
+    @Override @Nullable public Date readDate(String fieldName) throws BinaryObjectException
{
+        return findFieldByName(fieldName) ? this.readDate() : null;
     }
 
-    /** {@inheritDoc} */
-    @Nullable @Override public Date readDate() throws BinaryObjectException {
-        if (checkFlag(DATE) == Flag.NULL)
-            return null;
-
-        return doReadDate();
+    /**
+     * @param fieldId Field ID.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable Date readDate(int fieldId) throws BinaryObjectException {
+        return findFieldById(fieldId) ? this.readDate() : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Timestamp readTimestamp(String fieldName) throws BinaryObjectException
{
-        return readTimestamp(fieldId(fieldName));
+    @Override @Nullable public Date readDate() throws BinaryObjectException {
+        return checkFlagNoHandles(DATE) == Flag.NORMAL ? doReadDate() : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Timestamp readTimestamp() throws BinaryObjectException {
-        if (checkFlag(TIMESTAMP) == Flag.NULL)
-            return null;
+    @Override @Nullable public Date[] readDateArray(String fieldName) throws BinaryObjectException
{
+        return findFieldByName(fieldName) ? this.readDateArray() : null;
+    }
 
-        return doReadTimestamp();
+    /**
+     * @param fieldId Field ID.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable Date[] readDateArray(int fieldId) throws BinaryObjectException {
+        return findFieldById(fieldId) ? this.readDateArray() : null;
     }
 
     /** {@inheritDoc} */
-    @SuppressWarnings("unchecked")
-    @Nullable @Override public <T> T readObject(String fieldName) throws BinaryObjectException
{
-        return (T)readObject(fieldId(fieldName));
+    @Override @Nullable public Date[] readDateArray() throws BinaryObjectException {
+        switch (checkFlag(DATE_ARR)) {
+            case NORMAL:
+                return doReadDateArray();
+
+            case HANDLE:
+                return readHandleField();
+
+            default:
+                return null;
+        }
     }
 
     /** {@inheritDoc} */
-    @Override public Object readObject() throws BinaryObjectException {
-        return doReadObject();
+    @Override @Nullable public Timestamp readTimestamp(String fieldName) throws BinaryObjectException
{
+        return findFieldByName(fieldName) ? this.readTimestamp() : null;
     }
 
-    /** {@inheritDoc} */
-    @Nullable @Override public Object readObjectDetached() throws BinaryObjectException {
-        return unmarshal(true);
+    /**
+     * @param fieldId Field ID.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable Timestamp readTimestamp(int fieldId) throws BinaryObjectException {
+        return findFieldById(fieldId) ? this.readTimestamp() : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Date[] readDateArray(String fieldName) throws BinaryObjectException
{
-        return readDateArray(fieldId(fieldName));
+    @Override @Nullable public Timestamp readTimestamp() throws BinaryObjectException {
+        return checkFlagNoHandles(TIMESTAMP) == Flag.NORMAL ? doReadTimestamp() : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Timestamp[] readTimestampArray(String fieldName) throws BinaryObjectException
{
-        return readTimestampArray(fieldId(fieldName));
+    @Override @Nullable public Timestamp[] readTimestampArray(String fieldName) throws BinaryObjectException
{
+        return findFieldByName(fieldName) ? this.readTimestampArray() : null;
+    }
+
+    /**
+     * @param fieldId Field ID.
+     * @return Value.
+     * @throws BinaryObjectException In case of error.
+     */
+    @Nullable Timestamp[] readTimestampArray(int fieldId) throws BinaryObjectException {
+        return findFieldById(fieldId) ? this.readTimestampArray() : null;
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Date[] readDateArray() throws BinaryObjectException {
-        if (checkFlag(DATE_ARR) == Flag.NULL)
-            return null;
+    @Override @Nullable public Timestamp[] readTimestampArray() throws BinaryObjectException
{
+        switch (checkFlag(TIMESTAMP_ARR)) {
+            case NORMAL:
+                return doReadTimestampArray();
+
+            case HANDLE:
+                return readHandleField();
 
-        return doReadDateArray();
+            default:
+                return null;
+        }
     }
 
     /** {@inheritDoc} */
-    @Nullable @Override public Timestamp[] readTimestampArray() throws BinaryObjectException
{
-        if (checkFlag(TIMESTAMP_ARR) == Flag.NULL)
-            return null;
+    @SuppressWarnings("unchecked")
+    @Nullable @Override public <T> T readObject(String fieldName) throws BinaryObjectException
{
+        return (T)readObject(fieldId(fieldName));
+    }
 
-        return doReadTimestampArray();
+    /** {@inheritDoc} */
+    @Override public Object readObject() throws BinaryObjectException {
+        return doReadObject();
+    }
+
+    /** {@inheritDoc} */
+    @Nullable @Override public Object readObjectDetached() throws BinaryObjectException {
+        return unmarshal(true);
     }
 
     /** {@inheritDoc} */


Mime
View raw message