private static int slotIndex(ItemId id) { NodeId nodeId; if (id.denotesNode()) { nodeId = (NodeId) id; } else { nodeId = ((PropertyId) id).getParentId(); } return ((int) nodeId.getLeastSignificantBits()) & 0xf; } }
/** * {@inheritDoc} */ public String toString() { return id.toString(); } }
public void testOffset() throws RepositoryException { System.setProperty(NodeIdFactory.SEQUENTIAL_NODE_ID, "ab/0"); NodeIdFactory f = new NodeIdFactory(factoryDir); f.open(); assertEquals("00000000-0000-00ab-0000-000000000000", f.newNodeId().toString()); f.close(); f = new NodeIdFactory(factoryDir); f.open(); assertEquals("00000000-0000-00ab-0000-000000000001", f.newNodeId().toString()); f.close(); }
public void testGetMostAndLeastSignificantBits() { for (NodeId id : ids) { long msb = id.getMostSignificantBits(); long lsb = id.getLeastSignificantBits(); assertEquals(id, new NodeId(msb, lsb)); } }
public void testToString() { for (NodeId id : ids) { assertEquals(id, new NodeId(id.toString())); } }
public void testGetRawBytes() { for (NodeId id : ids) { assertEquals(id, new NodeId(id.getRawBytes())); } }
/** * Returns {@code true} if the specified {@code nodeId} is the ID of the root node; false otherwise. * * @param nodeId The identifier of the node to be tested. * @return {@code true} if the given id is the identifier of the root node. */ private boolean isRootId( NodeId nodeId ) { return rootID.equals( nodeId ); }
private void assertUuidFormat(NodeId id) { long high = id.getMostSignificantBits(); long low = id.getLeastSignificantBits(); long high2 = (high & (~0xf000L)) | 0x4000L; // version 4 (random) assertEquals(high, high2); long low2 = (low & 0x3fffffffffffffffL) | 0x8000000000000000L; // variant (Leach-Salz) assertEquals(low, low2); }
/** * {@inheritDoc} */ public NodeId getParentId() { return id.getParentId(); }
/** * Return the next available node id. Simply increments the last UUID * returned by <code>1</code>. * * @return next UUID */ private NodeId nextNodeId() { return new NodeId(0, lsbGenerator++); }
/** * Seeds this random number generator with 32 bytes of random data. * Run in an initializer thread as this may be slow on some systems, see * http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6202721. */ public void run() { setSeed(generateSeed(32)); seeded = true; }
/** * Returns the property name * @return the property name */ public Name getName() { return id.getName(); }
public void testDenotesNode() { for (NodeId id : ids) { assertTrue(id.denotesNode()); } }
/** * {@inheritDoc} */ public int hashCode() { return nodeId.hashCode(); }
public void close() throws RepositoryException { if (!createRandom) { store(nextLsb); } }
private static int slotIndex(ItemId id) { NodeId nodeId; if (id.denotesNode()) { nodeId = (NodeId) id; } else { nodeId = ((PropertyId) id).getParentId(); } return ((int) nodeId.getLeastSignificantBits()) & 0xf; } }
/** * @param nodeId * @return <code>true</code> if this entry is defined on the node * at <code>nodeId</code> */ boolean isLocal(NodeId nodeId) { return id != null && id.equals(nodeId); }
/** * Returns {@code true} if the specified {@code nodeId} is the ID of the * root node; false otherwise. * * @param nodeId The identifier of the node to be tested. * @return {@code true} if the given id is the identifier of the root node. */ private boolean isRootId(NodeId nodeId) { return rootID.equals(nodeId); }