Changes made:
Remove all notions of tags out of the object pointable and builder
Changed SLOT_SIZE constant
The getValue method of pointable returns boolean
Define JS_NULL_CONSTANT


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

Branch: refs/heads/master
Commit: 5ec28cba8a7eb83dcfac12c0d455c0c1574d03e7
Parents: a0f01bd
Author: riyafa <[email protected]>
Authored: Thu May 19 05:51:05 2016 +0530
Committer: riyafa <[email protected]>
Committed: Thu May 19 05:51:05 2016 +0530

----------------------------------------------------------------------
 .../datamodel/accessors/SequencePointable.java  | 36 ++++----
 .../accessors/jsonItem/ObjectPointable.java     | 73 +++++-----------
 .../builders/jsonItem/ObjectBuilder.java        |  5 +-
 .../vxquery/datamodel/values/ValueTag.java      |  2 +-
 .../vxquery/datamodel/values/XDMConstants.java  | 20 +++--
 .../vxquery/types/BuiltinTypeConstants.java     |  2 +-
 .../datamodel/AbstractPointableTest.java        | 22 ++++-
 .../vxquery/datamodel/ObjectByteTest.java       | 89 +++++++++-----------
 8 files changed, 115 insertions(+), 134 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
index 0aa66f7..d1b7dd8 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/SequencePointable.java
@@ -24,8 +24,6 @@ import org.apache.hyracks.data.std.primitive.IntegerPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 
 public class SequencePointable extends AbstractPointable {
-    private static final int ENTRY_COUNT_SIZE = 4;
-    private static final int SLOT_SIZE = 4;
     public static final IPointableFactory FACTORY = new IPointableFactory() {
         private static final long serialVersionUID = 1L;
 
@@ -39,29 +37,39 @@ public class SequencePointable extends AbstractPointable {
             return new SequencePointable();
         }
     };
+    private static final int ENTRY_COUNT_SIZE = 
IntegerPointable.TYPE_TRAITS.getFixedLength();
+    private static final int SLOT_SIZE = 
IntegerPointable.TYPE_TRAITS.getFixedLength();
 
     public static int getSequenceLength(byte[] bytes, int start) {
         int entryCount = getEntryCount(bytes, start);
         return getSlotValue(bytes, start, entryCount - 1) + 
(getDataAreaOffset(bytes, start) - start);
     }
 
-    public int getEntryCount() {
-        return getEntryCount(bytes, start);
-    }
-
     private static int getEntryCount(byte[] bytes, int start) {
         return IntegerPointable.getInteger(bytes, start);
     }
 
+    private static int getSlotValue(byte[] bytes, int start, int idx) {
+        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + 
idx * SLOT_SIZE);
+    }
+
+    private static int getSlotArrayOffset(int start) {
+        return start + ENTRY_COUNT_SIZE;
+    }
+
+    private static int getDataAreaOffset(byte[] bytes, int start) {
+        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * 
SLOT_SIZE;
+    }
+
+    public int getEntryCount() {
+        return getEntryCount(bytes, start);
+    }
+
     public void getEntry(int idx, IPointable pointer) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         pointer.set(bytes, dataAreaOffset + getRelativeEntryStartOffset(idx), 
getEntryLength(idx));
     }
 
-    private static int getSlotValue(byte[] bytes, int start, int idx) {
-        return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + 
idx * SLOT_SIZE);
-    }
-
     private int getRelativeEntryStartOffset(int idx) {
         return idx == 0 ? 0 : getSlotValue(bytes, start, idx - 1);
     }
@@ -69,12 +77,4 @@ public class SequencePointable extends AbstractPointable {
     private int getEntryLength(int idx) {
         return getSlotValue(bytes, start, idx) - 
getRelativeEntryStartOffset(idx);
     }
-
-    private static int getSlotArrayOffset(int start) {
-        return start + ENTRY_COUNT_SIZE;
-    }
-
-    private static int getDataAreaOffset(byte[] bytes, int start) {
-        return getSlotArrayOffset(start) + getEntryCount(bytes, start) * 
SLOT_SIZE;
-    }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
index 5b2e264..3aadee3 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/accessors/jsonItem/ObjectPointable.java
@@ -16,7 +16,6 @@
  */
 package org.apache.vxquery.datamodel.accessors.jsonItem;
 
-import java.io.DataOutput;
 import java.io.IOException;
 
 import org.apache.hyracks.api.dataflow.value.ITypeTraits;
@@ -27,13 +26,8 @@ import 
org.apache.hyracks.data.std.primitive.IntegerPointable;
 import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.primitive.VoidPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
-import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
-import org.apache.vxquery.exceptions.ErrorCode;
-import org.apache.vxquery.exceptions.SystemException;
+import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
-import org.apache.vxquery.util.GrowableIntArray;
 
 /**
  * The datamodel of the JSON object is represented in this class:
@@ -58,10 +52,10 @@ public class ObjectPointable extends AbstractPointable {
         }
     };
     private static final int ENTRY_COUNT_SIZE = 
IntegerPointable.TYPE_TRAITS.getFixedLength();
-    private static final int SLOT_SIZE = 4;
+    private static final int SLOT_SIZE = 
IntegerPointable.TYPE_TRAITS.getFixedLength();
     private final ArrayBackedValueStorage abvs = new ArrayBackedValueStorage();
-    private final GrowableIntArray slots = new GrowableIntArray();
-    private final ArrayBackedValueStorage dataArea = new 
ArrayBackedValueStorage();
+    private final SequenceBuilder sb = new SequenceBuilder();
+    private final UTF8StringPointable key1 = (UTF8StringPointable) 
UTF8StringPointable.FACTORY.createPointable();
 
     private static int getSlotValue(byte[] bytes, int start, int idx) {
         return IntegerPointable.getInteger(bytes, getSlotArrayOffset(start) + 
idx * SLOT_SIZE);
@@ -83,61 +77,34 @@ public class ObjectPointable extends AbstractPointable {
         return getSlotArrayOffset(start) + getEntryCount(bytes, start) * 
SLOT_SIZE;
     }
 
-    public void getKeys(IPointable result) throws SystemException {
-        try {
-            abvs.reset();
-            slots.clear();
-            dataArea.reset();
-            int dataAreaOffset = getDataAreaOffset(bytes, start);
-            int entryCount = getEntryCount();
-            int s;
-            for (int i = 0; i < entryCount; i++) {
-                s = dataAreaOffset + getRelativeEntryStartOffset(i);
-                dataArea.getDataOutput().write(ValueTag.XS_STRING_TAG);
-                dataArea.getDataOutput().write(bytes, s, getKeyLength(bytes, 
s));
-                slots.append(dataArea.getLength());
-            }
-            finishSequenceBuild();
-            result.set(abvs);
-        } catch (IOException e) {
-            throw new SystemException(ErrorCode.SYSE0001);
-        }
-    }
-
-    private void finishSequenceBuild() throws IOException {
-        DataOutput out = abvs.getDataOutput();
-        if (slots.getSize() != 1) {
-            out.write(ValueTag.SEQUENCE_TAG);
-            int size = slots.getSize();
-            out.writeInt(size);
-            if (size > 0) {
-                int[] slotArray = slots.getArray();
-                for (int i = 0; i < size; ++i) {
-                    out.writeInt(slotArray[i]);
-                }
-                out.write(dataArea.getByteArray(), dataArea.getStartOffset(), 
dataArea.getLength());
-            }
-        } else {
-            out.write(dataArea.getByteArray(), dataArea.getStartOffset(), 
dataArea.getLength());
+    public void getKeys(IPointable result) throws IOException {
+        abvs.reset();
+        sb.reset(abvs);
+        int dataAreaOffset = getDataAreaOffset(bytes, start);
+        int entryCount = getEntryCount();
+        int s;
+        for (int i = 0; i < entryCount; i++) {
+            s = dataAreaOffset + getRelativeEntryStartOffset(i);
+            key1.set(bytes, s, getKeyLength(bytes, s));
+            sb.addItem(key1);
         }
+        sb.finish();
+        result.set(abvs);
     }
 
-    public void getValue(TaggedValuePointable key, TaggedValuePointable 
result) throws SystemException {
+    public boolean getValue(UTF8StringPointable key, IPointable result) {
         int dataAreaOffset = getDataAreaOffset(bytes, start);
         int entryCount = getEntryCount();
         int s, l, i;
         for (i = 0; i < entryCount; i++) {
             s = dataAreaOffset + getRelativeEntryStartOffset(i);
             l = getKeyLength(bytes, s);
-            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), 
key.getStartOffset() + 1,
-                    key.getLength() - 1)) {
+            if (FunctionHelper.arraysEqual(bytes, s, l, key.getByteArray(), 
key.getStartOffset(), key.getLength())) {
                 result.set(bytes, s + l, getEntryLength(i) - l);
-                return;
+                return true;
             }
         }
-        if (entryCount == 0 || i == entryCount) {
-            XDMConstants.setFalse(result);
-        }
+        return false;
     }
 
     private int getRelativeEntryStartOffset(int idx) {

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
index 8f49198..f4b7649 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/builders/jsonItem/ObjectBuilder.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 
 import org.apache.hyracks.data.std.api.IMutableValueStorage;
 import org.apache.hyracks.data.std.api.IValueReference;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.builders.base.AbstractBuilder;
 import org.apache.vxquery.datamodel.builders.base.IBuilder;
@@ -43,8 +44,8 @@ public class ObjectBuilder extends AbstractBuilder implements 
IBuilder {
         return ValueTag.OBJECT_TAG;
     }
 
-    public void addItem(IValueReference key, IValueReference value) throws 
IOException {
-        dataArea.getDataOutput().write(key.getByteArray(), 
key.getStartOffset() + 1, key.getLength() - 1);
+    public void addItem(UTF8StringPointable key, IValueReference value) throws 
IOException {
+        dataArea.getDataOutput().write(key.getByteArray(), 
key.getStartOffset(), key.getLength());
         dataArea.getDataOutput().write(value.getByteArray(), 
value.getStartOffset(), value.getLength());
         slots.append(dataArea.getLength());
     }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
index 1f6ddc7..5600283 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/ValueTag.java
@@ -74,7 +74,7 @@ public class ValueTag {
     public static final int XS_NMTOKENS_TAG = 
BuiltinTypeConstants.XS_NMTOKENS_TYPE_ID;
     public static final int XS_ENTITIES_TAG = 
BuiltinTypeConstants.XS_ENTITIES_TYPE_ID;
 
-    public static final int JS_NULL_TAG = BuiltinTypeConstants.JS_NULL_ID;
+    public static final int JS_NULL_TAG = BuiltinTypeConstants.JS_NULL_TYPE_ID;
 
     public static final int SEQUENCE_TAG = 100;
     public static final int DOCUMENT_NODE_TAG = 101;

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
index bc058c7..3dc7e9e 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/datamodel/values/XDMConstants.java
@@ -19,11 +19,10 @@ package org.apache.vxquery.datamodel.values;
 import java.io.IOException;
 import java.util.Arrays;
 
-import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
-
 import org.apache.hyracks.data.std.api.IPointable;
 import org.apache.hyracks.data.std.primitive.BooleanPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.vxquery.datamodel.builders.sequence.SequenceBuilder;
 
 public class XDMConstants {
     private static final byte[] BOOLEAN_TRUE_CONSTANT;
@@ -34,6 +33,8 @@ public class XDMConstants {
 
     private static final byte[] EMPTY_STRING;
 
+    private static final byte[] JS_NULL_CONSTANT;
+
     static {
         BOOLEAN_TRUE_CONSTANT = new byte[2];
         BOOLEAN_TRUE_CONSTANT[0] = ValueTag.XS_BOOLEAN_TAG;
@@ -52,11 +53,17 @@ public class XDMConstants {
             throw new RuntimeException(e);
         }
         EMPTY_SEQUENCE = Arrays.copyOf(abvs.getByteArray(), abvs.getLength());
-        
+
         EMPTY_STRING = new byte[3];
         EMPTY_STRING[0] = ValueTag.XS_STRING_TAG;
         EMPTY_STRING[1] = 0;
         EMPTY_STRING[2] = 0;
+
+        JS_NULL_CONSTANT = new byte[1];
+        JS_NULL_CONSTANT[0] = ValueTag.JS_NULL_TAG;
+    }
+
+    private XDMConstants() {
     }
 
     public static void setTrue(IPointable p) {
@@ -75,10 +82,11 @@ public class XDMConstants {
         set(p, EMPTY_STRING);
     }
 
-    private static void set(IPointable p, byte[] array) {
-        p.set(array, 0, array.length);
+    public static void setJsNull(IPointable p) {
+        set(p, JS_NULL_CONSTANT);
     }
 
-    private XDMConstants() {
+    private static void set(IPointable p, byte[] array) {
+        p.set(array, 0, array.length);
     }
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java 
b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
index 79894a9..5ac51ec 100644
--- 
a/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
+++ 
b/vxquery-core/src/main/java/org/apache/vxquery/types/BuiltinTypeConstants.java
@@ -72,7 +72,7 @@ public class BuiltinTypeConstants {
     public static final int XS_NMTOKENS_TYPE_ID = 50;
     public static final int XS_ENTITIES_TYPE_ID = 51;
 
-    public static final int JS_NULL_ID = 52;
+    public static final int JS_NULL_TYPE_ID = 52;
 
     public static final int BUILTIN_TYPE_COUNT = 53;
 }

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
index 28ef372..7360703 100644
--- 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
+++ 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/AbstractPointableTest.java
@@ -25,6 +25,7 @@ import org.apache.vxquery.datamodel.values.ValueTag;
 public class AbstractPointableTest {
     private final ArrayBackedValueStorage abvsInput = new 
ArrayBackedValueStorage();
     private final StringValueBuilder svb = new StringValueBuilder();
+    private boolean includeTag = true;
 
     protected void getTaggedValuePointable(Object value, IPointable result) 
throws IOException {
         int start = abvsInput.getLength();
@@ -40,23 +41,36 @@ public class AbstractPointableTest {
         result.set(abvsInput.getByteArray(), start, abvsInput.getLength() - 
start);
     }
 
+    protected void getTaggedValuePointable(Object value, boolean includeTag, 
IPointable result) throws IOException {
+        this.includeTag = includeTag;
+        getTaggedValuePointable(value, result);
+    }
+
     protected void writeInteger(Integer value, DataOutput dOut) throws 
IOException {
-        dOut.write(ValueTag.XS_INT_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_INT_TAG);
+        }
         dOut.writeInt(value);
     }
 
     protected void writeLong(Long value, DataOutput dOut) throws IOException {
-        dOut.write(ValueTag.XS_LONG_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_LONG_TAG);
+        }
         dOut.writeLong(value);
     }
 
     protected void writeDouble(Double value, DataOutput dOut) throws 
IOException {
-        dOut.write(ValueTag.XS_DOUBLE_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_DOUBLE_TAG);
+        }
         dOut.writeDouble(value);
     }
 
     protected void writeString(String value, DataOutput dOut) throws 
IOException {
-        dOut.write(ValueTag.XS_STRING_TAG);
+        if (includeTag) {
+            dOut.write(ValueTag.XS_STRING_TAG);
+        }
         svb.write(value, dOut);
     }
 

http://git-wip-us.apache.org/repos/asf/vxquery/blob/5ec28cba/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
----------------------------------------------------------------------
diff --git 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
index fd9310f..ff05c24 100644
--- 
a/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
+++ 
b/vxquery-core/src/test/java/org/apache/vxquery/datamodel/ObjectByteTest.java
@@ -16,14 +16,13 @@ package org.apache.vxquery.datamodel;
 
 import java.io.IOException;
 
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
 import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
 import org.apache.vxquery.datamodel.accessors.SequencePointable;
 import org.apache.vxquery.datamodel.accessors.TaggedValuePointable;
 import org.apache.vxquery.datamodel.accessors.jsonItem.ObjectPointable;
 import org.apache.vxquery.datamodel.builders.jsonItem.ObjectBuilder;
 import org.apache.vxquery.datamodel.values.ValueTag;
-import org.apache.vxquery.datamodel.values.XDMConstants;
-import org.apache.vxquery.exceptions.SystemException;
 import org.apache.vxquery.runtime.functions.util.FunctionHelper;
 import org.junit.Test;
 
@@ -33,11 +32,11 @@ public class ObjectByteTest extends AbstractPointableTest {
     private ArrayBackedValueStorage abvsResult = new ArrayBackedValueStorage();
     private ObjectBuilder ob = new ObjectBuilder();
     private TaggedValuePointable tvp = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey1 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey1 = (UTF8StringPointable) 
UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue1 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey2 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey2 = (UTF8StringPointable) 
UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue2 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
-    private TaggedValuePointable tvpKey3 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
+    private UTF8StringPointable tvpKey3 = (UTF8StringPointable) 
UTF8StringPointable.FACTORY.createPointable();
     private TaggedValuePointable tvpValue3 = (TaggedValuePointable) 
TaggedValuePointable.FACTORY.createPointable();
     private SequencePointable sp = (SequencePointable) 
SequencePointable.FACTORY.createPointable();
     private ObjectPointable op = (ObjectPointable) 
ObjectPointable.FACTORY.createPointable();
@@ -70,7 +69,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         abvsResult.reset();
         try {
             ob.reset(abvsResult);
-            getTaggedValuePointable("id", tvpKey1);
+            getTaggedValuePointable("id", false, tvpKey1);
             getTaggedValuePointable(1, tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
             ob.finish();
@@ -90,23 +89,20 @@ public class ObjectByteTest extends AbstractPointableTest {
         }
         try {
             op.getKeys(tvp);
-        } catch (SystemException e) {
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
 
-        if (tvp.getTag() != ValueTag.XS_STRING_TAG) {
-            Assert.fail("Type tag is incorrect. Expected: " + 
ValueTag.XS_STRING_TAG + " Got: " + tvp.getTag());
-        }
         if (!FunctionHelper.arraysEqual(tvp, tvpKey1)) {
             Assert.fail("Key is incorrect. Expected: id");
         }
-        try {
-            op.getValue(tvpKey1, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey1, tvp)) {
+            Assert.fail("Value not found for the given key:id");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
-            Assert.fail("Value is incorrect for the given key.");
+            Assert.fail("Value is incorrect for the given key. Expected: 1 
with valuetag: " + ValueTag.XS_INT_TAG
+                    + " Got valuetag: " + tvp.getTag());
         }
     }
 
@@ -116,13 +112,13 @@ public class ObjectByteTest extends AbstractPointableTest 
{
         try {
             // Add three items
             ob.reset(abvsResult);
-            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("name", false, tvpKey1);
             getTaggedValuePointable("A green door", tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
-            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable("price", false, tvpKey2);
             getTaggedValuePointable(12.5, tvpValue2);
             ob.addItem(tvpKey2, tvpValue2);
-            getTaggedValuePointable("properties", tvpKey3);
+            getTaggedValuePointable("properties", false, tvpKey3);
             getTaggedValuePointable(100L, tvpValue3);
             ob.addItem(tvpKey3, tvpValue3);
             ob.finish();
@@ -143,7 +139,7 @@ public class ObjectByteTest extends AbstractPointableTest {
         //Test keys
         try {
             op.getKeys(tvp);
-        } catch (SystemException e) {
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
 
@@ -168,28 +164,24 @@ public class ObjectByteTest extends AbstractPointableTest 
{
         }
 
         //Test values
-        try {
-            op.getValue(tvpKey1, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+        if (!op.getValue(tvpKey1, tvp)) {
+            Assert.fail("Value not found for the given key: name");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
             Assert.fail("Value is incorrect for the given key. Expected: A 
green door with valuetag: "
                     + ValueTag.XS_STRING_TAG + " Got valuetag: " + 
tvp.getTag());
         }
-        try {
-            op.getValue(tvpKey2, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey2, tvp)) {
+            Assert.fail("Value not found for the given key: price");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue2)) {
             Assert.fail("Value is incorrect for the given key. Expected: 12.5 
with valuetag: " + ValueTag.XS_DOUBLE_TAG
                     + " Got valuetag: " + tvp.getTag());
         }
-        try {
-            op.getValue(tvpKey3, tvp);
-        } catch (SystemException e) {
-            Assert.fail("Test failed to write the object pointable.");
+
+        if (!op.getValue(tvpKey3, tvp)) {
+            Assert.fail("Value not found for the given key: properties");
         }
         if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
             Assert.fail("Value is incorrect for the given key. Expected: 100 
with valuetag: " + ValueTag.XS_LONG_TAG
@@ -210,25 +202,23 @@ public class ObjectByteTest extends AbstractPointableTest 
{
         tvp.set(abvsResult);
         tvp.getValue(op);
         try {
-            getTaggedValuePointable("key", tvpKey1);
-            op.getValue(tvpKey1, tvpValue1);
-        } catch (IOException | SystemException e) {
+            getTaggedValuePointable("key", false, tvpKey1);
+            if (op.getValue(tvpKey1, tvp)) {
+                Assert.fail("key not in object. Expected: false Got: true");
+            }
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
-        XDMConstants.setFalse(tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpValue1)) {
-            Assert.fail("Value is incorrect for the given key. Expected: false 
with valuetag: "
-                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + 
tvp.getTag());
-        }
 
         // Build test object
         try {
             // Add two items
+            abvsResult.reset();
             ob.reset(abvsResult);
-            getTaggedValuePointable("name", tvpKey1);
+            getTaggedValuePointable("name", false, tvpKey1);
             getTaggedValuePointable("A green door", tvpValue1);
             ob.addItem(tvpKey1, tvpValue1);
-            getTaggedValuePointable("price", tvpKey2);
+            getTaggedValuePointable("price", false, tvpKey2);
             getTaggedValuePointable(12.5, tvpValue2);
             ob.addItem(tvpKey2, tvpValue2);
             ob.finish();
@@ -239,15 +229,16 @@ public class ObjectByteTest extends AbstractPointableTest 
{
         tvp.set(abvsResult);
         tvp.getValue(op);
         try {
-            getTaggedValuePointable("key", tvpKey3);
-            op.getValue(tvpKey3, tvpValue3);
-        } catch (IOException | SystemException e) {
+            getTaggedValuePointable("key", false, tvpKey3);
+            if (op.getValue(tvpKey3, tvp)) {
+                Assert.fail("key not in object. Expected: false Got: true");
+            }
+
+            if (!op.getValue(tvpKey1, tvp)) {
+                Assert.fail("key in object. Expected: true Got: false");
+            }
+        } catch (IOException e) {
             Assert.fail("Test failed to write the object pointable.");
         }
-        XDMConstants.setFalse(tvp);
-        if (!FunctionHelper.arraysEqual(tvp, tvpValue3)) {
-            Assert.fail("Value is incorrect for the given key. Expected: false 
with valuetag: "
-                    + ValueTag.XS_BOOLEAN_TAG + " Got valuetag: " + 
tvp.getTag());
-        }
     }
 }

Reply via email to