@Test public void testMultipleAttributes() throws TTException { final INodeWriteTrx wtx = holder.getNWtx(); wtx.moveTo(ROOT_NODE); final long nodeKey = wtx.insertElementAsFirstChild(new QName("foo")); wtx.insertAttribute(new QName("foo0"), "0"); wtx.moveTo(nodeKey); wtx.insertAttribute(new QName("foo1"), "1"); wtx.moveTo(nodeKey); wtx.insertAttribute(new QName("foo2"), "2"); AssertJUnit.assertEquals(true, wtx.moveTo(nodeKey)); AssertJUnit.assertEquals(true, wtx.moveToAttribute(0)); AssertJUnit.assertEquals("0", wtx.getValueOfCurrentNode()); AssertJUnit.assertEquals(new QName("foo0"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals(true, wtx.moveTo(wtx.getNode().getParentKey())); AssertJUnit.assertEquals(true, wtx.moveToAttribute(1)); AssertJUnit.assertEquals("1", wtx.getValueOfCurrentNode()); AssertJUnit.assertEquals(new QName("foo1"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals(true, wtx.moveTo(wtx.getNode().getParentKey())); AssertJUnit.assertEquals(true, wtx.moveToAttribute(2)); AssertJUnit.assertEquals("2", wtx.getValueOfCurrentNode()); AssertJUnit.assertEquals(new QName("foo2"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals(true, wtx.moveTo(nodeKey)); final AbsAxis axis = new AttributeAxis(wtx); AssertJUnit.assertEquals(true, axis.hasNext()); axis.next(); AssertJUnit.assertEquals(nodeKey + 1, wtx.getNode().getDataKey()); AssertJUnit.assertEquals(new QName("foo0"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals("0", wtx.getValueOfCurrentNode()); AssertJUnit.assertEquals(true, axis.hasNext()); axis.next(); AssertJUnit.assertEquals(nodeKey + 2, wtx.getNode().getDataKey()); AssertJUnit.assertEquals(new QName("foo1"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals("1", wtx.getValueOfCurrentNode()); AssertJUnit.assertEquals(true, axis.hasNext()); axis.next(); AssertJUnit.assertEquals(nodeKey + 3, wtx.getNode().getDataKey()); AssertJUnit.assertEquals(new QName("foo2"), wtx.getQNameOfCurrentNode()); AssertJUnit.assertEquals("2", wtx.getValueOfCurrentNode()); wtx.abort(); wtx.close(); }
@Override public final boolean hasNext() { resetToLastKey(); if (mNextIndex > 0) { moveTo(getNode().getParentKey()); } if (getNode().getKind() == IConstants.ELEMENT && mNextIndex < ((ElementNode)getNode()).getAttributeCount()) { moveTo(((ElementNode)getNode()).getAttributeKey(mNextIndex)); mNextIndex += 1; return true; } resetToStartKey(); return false; }
AttributeAxis extends AbsAxis { @Override public final boolean hasNext() { resetToLastKey(); if (mNextIndex > 0) { moveTo(getNode().getParentKey()); } if (getNode().getKind() == IConstants.ELEMENT && mNextIndex < ((ElementNode)getNode()).getAttributeCount()) { moveTo(((ElementNode)getNode()).getAttributeKey(mNextIndex)); mNextIndex += 1; return true; } resetToStartKey(); return false; } }
AttributeAxis extends AbsAxis { @Override public final boolean hasNext() { resetToLastKey(); if (mNextIndex > 0) { moveTo(getNode().getParentKey()); } if (getNode().getKind() == IConstants.ELEMENT && mNextIndex < ((ElementNode)getNode()).getAttributeCount()) { moveTo(((ElementNode)getNode()).getAttributeKey(mNextIndex)); mNextIndex += 1; return true; } resetToStartKey(); return false; } AttributeAxis(final INodeReadTrx rtx); }
AttributeAxis extends AbsAxis { @Override public final boolean hasNext() { resetToLastKey(); if (mNextIndex > 0) { moveTo(getNode().getParentKey()); } if (getNode().getKind() == IConstants.ELEMENT && mNextIndex < ((ElementNode)getNode()).getAttributeCount()) { moveTo(((ElementNode)getNode()).getAttributeKey(mNextIndex)); mNextIndex += 1; return true; } resetToStartKey(); return false; } AttributeAxis(final INodeReadTrx rtx); @Override final void reset(final long mNodeKey); @Override final boolean hasNext(); }
AttributeAxis extends AbsAxis { @Override public final boolean hasNext() { resetToLastKey(); if (mNextIndex > 0) { moveTo(getNode().getParentKey()); } if (getNode().getKind() == IConstants.ELEMENT && mNextIndex < ((ElementNode)getNode()).getAttributeCount()) { moveTo(((ElementNode)getNode()).getAttributeKey(mNextIndex)); mNextIndex += 1; return true; } resetToStartKey(); return false; } AttributeAxis(final INodeReadTrx rtx); @Override final void reset(final long mNodeKey); @Override final boolean hasNext();  }