You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by vo...@apache.org on 2015/11/18 15:25:13 UTC
[3/4] ignite git commit: IGNITE-1917: Refactoring: strings and UUIDs.
IGNITE-1917: Refactoring: strings and UUIDs.
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/e9bf534b
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/e9bf534b
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/e9bf534b
Branch: refs/heads/ignite-1917
Commit: e9bf534bcb18a28da1760321561ee1404cd04a1f
Parents: 7078303
Author: vozerov-gridgain <vo...@gridgain.com>
Authored: Wed Nov 18 17:21:16 2015 +0300
Committer: vozerov-gridgain <vo...@gridgain.com>
Committed: Wed Nov 18 17:21:16 2015 +0300
----------------------------------------------------------------------
.../internal/portable/BinaryReaderExImpl.java | 189 ++++++++-----------
1 file changed, 78 insertions(+), 111 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/e9bf534b/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 1a6b883..c4014eb 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 String readString(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(STRING) == Flag.NULL)
- return null;
-
- return doReadString();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable UUID readUuid(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- if (checkFlag(UUID) == Flag.NULL)
- return null;
-
- return doReadUuid();
- }
- else
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
@Nullable Date readDate(int fieldId) throws BinaryObjectException {
if (findFieldById(fieldId)) {
if (checkFlag(DATE) == Flag.NULL)
@@ -381,42 +349,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
* @return Value.
* @throws BinaryObjectException In case of error.
*/
- @Nullable String[] readStringArray(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- Flag flag = checkFlag(STRING_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadStringArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
- @Nullable UUID[] readUuidArray(int fieldId) throws BinaryObjectException {
- if (findFieldById(fieldId)) {
- Flag flag = checkFlag(UUID_ARR);
-
- if (flag == Flag.NORMAL)
- return doReadUuidArray();
- else if (flag == Flag.HANDLE)
- return readHandleField();
- }
-
- return null;
- }
-
- /**
- * @param fieldId Field ID.
- * @return Value.
- * @throws BinaryObjectException In case of error.
- */
@Nullable Date[] readDateArray(int fieldId) throws BinaryObjectException {
if (findFieldById(fieldId)) {
Flag flag = checkFlag(DATE_ARR);
@@ -1136,36 +1068,97 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/** {@inheritDoc} */
- @Nullable @Override public String readString(String fieldName) throws BinaryObjectException {
- if (findFieldByName(fieldName)) {
- if (checkFlag(STRING) == Flag.NULL)
- return null;
+ @Override @Nullable public String readString(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readString() : null;
+ }
- return doReadString();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable String readString(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readString() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public String readString() throws BinaryObjectException {
+ return checkFlagNoHandles(STRING) == Flag.NORMAL ? doReadString() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public String[] readStringArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readStringArray() : null;
+ }
+
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable String[] readStringArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readStringArray() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public String[] readStringArray() throws BinaryObjectException {
+ switch (checkFlag(STRING_ARR)) {
+ case NORMAL:
+ return doReadStringArray();
+
+ case HANDLE:
+ return readHandleField();
+
+ default:
+ return null;
}
- else
- return null;
}
/** {@inheritDoc} */
- @Nullable @Override public String readString() throws BinaryObjectException {
- if (checkFlag(STRING) == Flag.NULL)
- return null;
+ @Override @Nullable public UUID readUuid(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readUuid() : null;
+ }
- return doReadString();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable UUID readUuid(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readUuid() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public UUID readUuid(String fieldName) throws BinaryObjectException {
- return readUuid(fieldId(fieldName));
+ @Override @Nullable public UUID readUuid() throws BinaryObjectException {
+ return checkFlagNoHandles(UUID) == Flag.NORMAL ? doReadUuid() : null;
}
/** {@inheritDoc} */
- @Nullable @Override public UUID readUuid() throws BinaryObjectException {
- if (checkFlag(UUID) == Flag.NULL)
- return null;
+ @Override @Nullable public UUID[] readUuidArray(String fieldName) throws BinaryObjectException {
+ return findFieldByName(fieldName) ? this.readUuidArray() : null;
+ }
- return doReadUuid();
+ /**
+ * @param fieldId Field ID.
+ * @return Value.
+ * @throws BinaryObjectException In case of error.
+ */
+ @Nullable UUID[] readUuidArray(int fieldId) throws BinaryObjectException {
+ return findFieldById(fieldId) ? this.readUuidArray() : null;
+ }
+
+ /** {@inheritDoc} */
+ @Override @Nullable public UUID[] readUuidArray() throws BinaryObjectException {
+ switch (checkFlag(UUID_ARR)) {
+ case NORMAL:
+ return doReadUuidArray();
+
+ case HANDLE:
+ return readHandleField();
+
+ default:
+ return null;
+ }
}
/** {@inheritDoc} */
@@ -1211,32 +1204,6 @@ public class BinaryReaderExImpl implements BinaryReader, BinaryRawReaderEx, Obje
}
/** {@inheritDoc} */
- @Nullable @Override public String[] readStringArray(String fieldName) throws BinaryObjectException {
- return readStringArray(fieldId(fieldName));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public String[] readStringArray() throws BinaryObjectException {
- if (checkFlag(STRING_ARR) == Flag.NULL)
- return null;
-
- return doReadStringArray();
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public UUID[] readUuidArray(String fieldName) throws BinaryObjectException {
- return readUuidArray(fieldId(fieldName));
- }
-
- /** {@inheritDoc} */
- @Nullable @Override public UUID[] readUuidArray() throws BinaryObjectException {
- if (checkFlag(UUID_ARR) == Flag.NULL)
- return null;
-
- return doReadUuidArray();
- }
-
- /** {@inheritDoc} */
@Nullable @Override public Date[] readDateArray(String fieldName) throws BinaryObjectException {
return readDateArray(fieldId(fieldName));
}