INTERNAL: add equals function of UnsignedInt 76/28276/1
authorgreatim <jaewon81.lim@samsung.com>
Wed, 1 Oct 2014 09:08:12 +0000 (18:08 +0900)
committergreatim <jaewon81.lim@samsung.com>
Wed, 1 Oct 2014 09:08:12 +0000 (18:08 +0900)
add equals function of UnsignedInt

Change-Id: Ia2859d1a88fd31f79a2679fb3834c95543a3e965
Signed-off-by: greatim <jaewon81.lim@samsung.com>
org.tizen.dynamicanalyzer.common/src/org/tizen/dynamicanalyzer/util/UnsignedInt.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java

index fc9a37a..12f6bab 100644 (file)
 
 package org.tizen.dynamicanalyzer.util;
 
-
 public class UnsignedInt {
-       private static final long MAX_VALUE = (long)Integer.MAX_VALUE * 2 + 1;
+       private static final long MAX_VALUE = (long) Integer.MAX_VALUE * 2 + 1;
        private static final long MIN_VALUE = 0;
-       
-       private long value;     // real data, use only 4byte.
-       
+
+       private long value; // real data, use only 4byte.
+
        public UnsignedInt() {
                this.value = 0;
        }
-       
+
        public UnsignedInt(int value) {
                this.value = value & 0xFFFFFFFFL;
        }
-       
+
        public UnsignedInt(long value) {
                if (value > MAX_VALUE || value < MIN_VALUE) {
                        Logger.error("Invalid input : " + value + ". 0 will be set.");
@@ -49,27 +48,47 @@ public class UnsignedInt {
                        this.value = value;
                }
        }
-       
+
+       public boolean equals(Object o) {
+               if (o instanceof Long) {
+                       Long l = (Long) o;
+                       if (l.longValue() == value) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               } else if (o instanceof Integer) {
+                       Integer i = (Integer) o;
+                       if (i.longValue() == value) {
+                               return true;
+                       } else {
+                               return false;
+                       }
+               } else {
+                       return false;
+               }
+       }
+
        public long getValue() {
                return value;
        }
-       
+
        public void add(UnsignedInt operand) {
                add(operand.getValue());
        }
-       
+
        public void minus(UnsignedInt operand) {
                minus(operand.getValue());
        }
-       
+
        public void multiply(UnsignedInt operand) {
                multiply(operand.getValue());
        }
-       
+
        public void divide(UnsignedInt operand) {
                divide(operand.getValue());
        }
-       
+
        private void add(long operand) {
                long temp = this.value + operand;
                if (temp > MAX_VALUE) {
@@ -78,7 +97,7 @@ public class UnsignedInt {
                }
                this.value = temp;
        }
-       
+
        private void minus(long operand) {
                long temp = this.value - operand;
                if (temp < MIN_VALUE) {
@@ -87,7 +106,7 @@ public class UnsignedInt {
                }
                this.value = temp;
        }
-       
+
        private void multiply(long operand) {
                long temp = this.value * operand;
                if (temp > MAX_VALUE) {
@@ -96,7 +115,7 @@ public class UnsignedInt {
                }
                this.value = temp;
        }
-       
+
        private void divide(long operand) {
                this.value /= operand;
        }
index b97b419..0f2785a 100755 (executable)
@@ -343,7 +343,7 @@ public class MessageParser {
 
                                int id = ByteUtil.toInt(header, 0);
                                UnsignedInt seq = ByteUtil.toUnsignedInt(header, INT_SIZE);
-                               if(seq.equals(Integer.valueOf(0))) {
+                               if(seq.equals(Long.valueOf(0))) {
                                        Global.getProject().incSeqRotation();
                                }