javax.jcr.Node.isSame()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中javax.jcr.Node.isSame()方法的一些代码示例,展示了Node.isSame()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.isSame()方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:isSame

Node.isSame介绍

暂无

代码示例

代码示例来源:origin: apache/jackrabbit

  1. protected void entering(Node n, int level)
  2. throws RepositoryException {
  3. if (!node.isSame(n)) {
  4. descendants.add(n);
  5. }
  6. }
  7. });

代码示例来源:origin: apache/jackrabbit

  1. protected void entering(Node node, int level) throws RepositoryException {
  2. if (node.getName().equals(name) && !testRootNode.isSame(node)) {
  3. nodes.add(node);
  4. }
  5. }
  6. });

代码示例来源:origin: info.magnolia/magnolia-core

  1. /**
  2. * Orders the node first among its siblings.
  3. */
  4. public static void orderFirst(Node node) throws RepositoryException {
  5. Node parent = node.getParent();
  6. NodeIterator siblings = parent.getNodes();
  7. Node firstSibling = siblings.nextNode();
  8. if (!firstSibling.isSame(node)) {
  9. parent.orderBefore(node.getName(), firstSibling.getName());
  10. }
  11. }

代码示例来源:origin: info.magnolia/magnolia-core

  1. /**
  2. * Returns true if both arguments represents the same node. In case the nodes are wrapped the comparison is done one
  3. * the actual nodes behind the wrappers.
  4. */
  5. public static boolean isSame(Node lhs, Node rhs) throws RepositoryException {
  6. return unwrap(lhs).isSame(unwrap(rhs));
  7. }

代码示例来源:origin: org.onehippo.cms7/hippo-repository-builtin

  1. public Node getContainingFolder() throws RepositoryException {
  2. Node jcrRoot = node.getSession().getRootNode();
  3. Node parent = node.getParent();
  4. while (!parent.isSame(jcrRoot)) {
  5. if (parent.isNodeType(HippoNodeType.NT_DOCUMENT)) {
  6. return parent;
  7. }
  8. parent = parent.getParent();
  9. }
  10. return null;
  11. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Tests if getParent() returns parent node
  3. */
  4. public void testGetParent() throws RepositoryException {
  5. assertTrue("getParent() of a property must return the parent node.",
  6. testRootNode.isSame(property.getParent()));
  7. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Test the persistence of a property modified with an Node parameter and
  3. * saved from the Session Requires a Node value (node)
  4. */
  5. public void testNodeSession() throws RepositoryException, NotExecutableException {
  6. property1.setValue(node);
  7. superuser.save();
  8. assertTrue("Reference property not saved", node.isSame(property1.getNode()));
  9. }

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * <code>Node.getNode(".") </code> applied to the root node must return
  3. * the same <code>Node</code> again.
  4. *
  5. * @throws RepositoryException
  6. */
  7. public void testRootGetNodeDot() throws RepositoryException {
  8. Node root = superuser.getRootNode();
  9. assertTrue("Node.getNode(\".\") must return the same node", root.getNode(DOT).isSame(root));
  10. }

代码示例来源:origin: pentaho/pentaho-platform

  1. public Object doInJcr( final Session session ) throws RepositoryException, IOException {
  2. PentahoJcrConstants pentahoJcrConstants = new PentahoJcrConstants( session );
  3. Node node = session.getNodeByIdentifier( id.toString() );
  4. if ( !node.getParent().isSame( session.getRootNode() ) ) {
  5. return toAcl( session, pentahoJcrConstants, node.getParent().getIdentifier() );
  6. } else {
  7. return null;
  8. }
  9. }
  10. } );

代码示例来源:origin: apache/jackrabbit

  1. /**
  2. * Tests if getParent() returns parent node
  3. */
  4. public void testGetParent()
  5. throws NotExecutableException, RepositoryException {
  6. if (childNode == null) {
  7. throw new NotExecutableException("Workspace does not have sufficient content to run this test.");
  8. }
  9. assertTrue("getParent() of a child node return the parent node.",
  10. testRootNode.isSame(childNode.getParent()));
  11. }

代码示例来源:origin: org.onehippo.cms7.hst/hst-client

  1. private static Node getHandleNodeIfIsAncestor(final Node currentNode, final Node rootNode) throws RepositoryException {
  2. if (currentNode.isNodeType(HippoNodeType.NT_HANDLE)) {
  3. return currentNode;
  4. }
  5. if (currentNode.isSame(rootNode)) {
  6. return null;
  7. }
  8. return getHandleNodeIfIsAncestor(currentNode.getParent(), rootNode);
  9. }

代码示例来源:origin: apache/jackrabbit

  1. public void testShadowingItems() throws RepositoryException {
  2. Node n = testRootNode.addNode(nodeName1, testNodeType);
  3. Node n2 = testRootNode.addNode(nodeName2, testNodeType);
  4. Property p = n.setProperty(propertyName1, "anyValue");
  5. testRootNode.save();
  6. testRootNode.getSession().move(n.getPath(), n2.getPath() + "/destination");
  7. Node replaceNode = testRootNode.addNode(nodeName1, testNodeType);
  8. Property replaceProp = replaceNode.setProperty(propertyName1, "anyValue");
  9. assertFalse(replaceNode.isSame(n));
  10. assertFalse(replaceProp.isSame(p));
  11. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Test
  2. public void testSessionGetNode() throws Exception {
  3. Node nn = superuser.getNode(n.getPath());
  4. assertTrue(n.isSame(nn));
  5. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Test
  2. public void getNodeDot() throws RepositoryException {
  3. Node node = getNode("/foo");
  4. Node same = node.getNode(".");
  5. assertNotNull(same);
  6. assertEquals("foo", same.getName());
  7. assertTrue(same.isSame(node));
  8. }

代码示例来源:origin: ModeShape/modeshape

  1. protected void verifyShare( Node original,
  2. Node sharedNode ) throws RepositoryException {
  3. // The identity, properties and children match the original node ...
  4. assertThat(sharedNode.getIdentifier(), is(original.getIdentifier()));
  5. assertThat(sharedNode.isSame(original), is(true));
  6. assertSameProperties(sharedNode, original);
  7. assertSameChildren(sharedNode, original);
  8. // Verify the shared attributes ...
  9. assertThat(sharedNode.isNodeType(MIX_SHAREABLE), is(true));
  10. assertSharedSetIncludes(original, original.getPath(), sharedNode.getPath());
  11. assertSharedSetIncludes(sharedNode, original.getPath(), sharedNode.getPath());
  12. }

代码示例来源:origin: apache/jackrabbit

  1. public void testTreeEntries() throws RepositoryException {
  2. Item item = superuser.getItem(destinationPath + "/" + nodeName2);
  3. assertTrue("Moving a node must move all child items as well.", childNode.isSame(item));
  4. item = superuser.getItem(destinationPath + "/" + propertyName2);
  5. assertTrue("Moving a node must move all child items as well.", childProperty.isSame(item));
  6. item = superuser.getItem(destinationPath + "/" + nodeName2 + "/" + nodeName3);
  7. assertTrue("Moving a node must move all child items as well.", grandChildNode.isSame(item));
  8. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Test
  2. public void getNodeDotDot() throws RepositoryException {
  3. Node node = getNode("/foo");
  4. Node root = node.getNode("..");
  5. assertNotNull(root);
  6. assertEquals("", root.getName());
  7. assertTrue(root.isSame(node.getParent()));
  8. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Test
  2. public void testIsSame() throws Exception {
  3. assertFalse(n.isSame(p));
  4. assertFalse(p.isSame(n));
  5. }

代码示例来源:origin: apache/jackrabbit-oak

  1. @Test
  2. public void getNodeByIdentifier() throws RepositoryException {
  3. Node node = getNode("/foo");
  4. String id = node.getIdentifier();
  5. Node node2 = getAdminSession().getNodeByIdentifier(id);
  6. assertTrue(node.isSame(node2));
  7. }

代码示例来源:origin: apache/jackrabbit

  1. public void testParentChildLock2() throws Exception {
  2. childNode.addMixin(mixLockable);
  3. testRootNode.save();
  4. try {
  5. Lock l = childNode.lock(false, isSessionScoped());
  6. assertTrue("child node must still hold lock", l.getNode().isSame(childNode));
  7. } finally {
  8. childNode.unlock();
  9. }
  10. }

相关文章