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

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

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

Node.getDepth介绍

暂无

代码示例

代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.javascript

  1. public int jsFunction_getDepth() {
  2. try {
  3. return node.getDepth();
  4. } catch (RepositoryException re) {
  5. return -1;
  6. }
  7. }

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

  1. public RepositoryWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException {
  2. this.session = rootSession;
  3. if(subject.getDepth() == 0)
  4. this.subject = rootSession.getRootNode();
  5. else
  6. this.subject = rootSession.getRootNode().getNode(subject.getPath().substring(1));
  7. }

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

  1. @Override
  2. public int compare(Node lhs, Node rhs) {
  3. try {
  4. if (lhs.getDepth() != rhs.getDepth())
  5. return lhs.getDepth() - rhs.getDepth();
  6. return getSiblingIndex(lhs) - getSiblingIndex(rhs);
  7. } catch (RepositoryException e) {
  8. throw new RuntimeRepositoryException(e);
  9. }
  10. }

代码示例来源:origin: org.overlord.sramp/s-ramp-repository-jcr

  1. /**
  2. * Print this node and its properties to System.out if printing is enabled.
  3. *
  4. * @param node the node to be printed
  5. * @throws RepositoryException
  6. */
  7. public void printNode( Node node ) throws RepositoryException {
  8. printSubgraph(node, " ", node.getDepth(), 1); //$NON-NLS-1$
  9. }

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

  1. public List<Node> ancestorsInSite(Node content, String nodeTypeName) throws RepositoryException {
  2. List<Node> allAncestors = templatingFunctions.ancestors(content, nodeTypeName);
  3. Node siteRoot = siteRoot(content);
  4. List<Node> ancestoresInSite = new ArrayList<Node>();
  5. for (Node current : allAncestors) {
  6. if (current.getDepth() >= siteRoot.getDepth()) {
  7. ancestoresInSite.add(current);
  8. }
  9. }
  10. return ancestoresInSite;
  11. }

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

  1. private boolean isChildOf(Node child, Node parent) {
  2. try {
  3. return parent.getDepth() == 0 || child.getPath().startsWith(parent.getPath() + "/");
  4. } catch (RepositoryException e) {
  5. throw new RuntimeRepositoryException(e);
  6. }
  7. }
  8. }

代码示例来源:origin: org.wisdom-framework.jcr/wisdom-jcr-core

  1. /**
  2. * Print this node and its properties to System.out if printing is enabled.
  3. *
  4. * @param node the node to be printed
  5. * @throws RepositoryException
  6. */
  7. public void printNode( Node node ) throws RepositoryException {
  8. printSubgraph(node, " ", node.getDepth(), 1);
  9. }

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

  1. /**
  2. * Test if depth of root node is 0.
  3. */
  4. public void testGetDepth() throws RepositoryException {
  5. assertEquals("The depth of the root node must be equal to 0.", 0, rootNode.getDepth());
  6. }

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

  1. @Override
  2. protected void entering(Node node, int level) throws RepositoryException, SAXException {
  3. final AttributesImpl attrs = new AttributesImpl();
  4. String nodeName;
  5. if (node.getDepth() == 0) {
  6. nodeName = jcrRoot;
  7. } else {
  8. nodeName = node.getName();
  9. }
  10. addAttribute(attrs, SV_NAME, CDATA_TYPE, nodeName);
  11. startElement(NameConstants.SV_NODE, attrs);
  12. }

代码示例来源:origin: org.apache.jackrabbit.vault/org.apache.jackrabbit.vault

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public boolean includes(Node root, Node node, String path) throws RepositoryException {
  5. if (path == null) {
  6. path = node.getPath();
  7. }
  8. return contentFilter.contains(node, path, PathUtil.getDepth(path) - root.getDepth());
  9. }

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

  1. @Override
  2. protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException {
  3. if (node.getDepth() == 0) { //don't include root node
  4. final NodeIterator iterator = node.getNodes();
  5. while (iterator.hasNext()) {
  6. final Node child = iterator.nextNode();
  7. super.exportNode(StringUtils.EMPTY, serializeKey(uri, child.getName()), child); //omit jcr: prefix for all child nodes
  8. }
  9. } else {
  10. super.exportNode(uri, serializeKey(uri, local), node);
  11. }
  12. }

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

  1. @Override
  2. public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
  3. // at some point we will enter the real hierarchy, so its easiest to loop
  4. Node parent = getParent();
  5. while (parent.getDepth() > depth) {
  6. parent = parent.getParent();
  7. }
  8. return parent;
  9. }

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

  1. /**
  2. * Tests if depth of a property of depth of node + 1
  3. */
  4. public void testGetDepth() throws RepositoryException {
  5. assertEquals("getDepth() of a property of root must be 1", testRootNode.getDepth() + 1,
  6. property.getDepth());
  7. }

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

  1. /**
  2. * Test if the ancestor at depth = n, where n is the depth of this
  3. * <code>Item</code>, returns this <code>Node</code> itself.
  4. */
  5. public void testGetAncestorOfNodeDepth() throws RepositoryException {
  6. Node nodeAtDepth = (Node) testRootNode.getAncestor(testRootNode.getDepth());
  7. assertTrue("The ancestor of depth = n, where n is the depth of this " +
  8. "Node must be the item itself.", testRootNode.isSame(nodeAtDepth));
  9. }

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

  1. protected long countNodes( Node node ) throws RepositoryException {
  2. long count = 1;
  3. NodeIterator iter = node.getNodes();
  4. while (iter.hasNext()) {
  5. Node child = iter.nextNode();
  6. if (child.getDepth() == 1 && child.getName().equals("jcr:system")) continue;
  7. count += countNodes(child);
  8. }
  9. return count;
  10. }
  11. }

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

  1. @Test
  2. public void assertThatRootNodeIsNotCheckedForTemplate() throws Exception {
  3. // GIVEN
  4. final Node root = mock(Node.class);
  5. when(root.getDepth()).thenReturn(0);
  6. // WHEN
  7. templateTypeHelper.findParentWithTemplateType(root, DefaultTemplateTypes.HOME);
  8. // THEN
  9. verify(root, times(1)).getDepth();
  10. verifyNoMoreInteractions(root);
  11. }

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

  1. @Override
  2. public Item getAncestor(int depth) throws RepositoryException {
  3. if (this.getDepth() == depth) {
  4. return this;
  5. }
  6. Node parentNode = this.getParent();
  7. while (parentNode.getDepth() != depth) {
  8. parentNode = parentNode.getParent();
  9. }
  10. return parentNode;
  11. }

代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit

  1. private NavigationModel createVerticalNavigation() throws RepositoryException {
  2. int startLevel = siteRoot.getDepth();
  3. boolean rootIsHome = true;
  4. if (isShowHorizontalNavigation()) {
  5. startLevel = getStartLevel();
  6. rootIsHome = false;
  7. }
  8. Node root = (Node) currentNode.getAncestor(startLevel);
  9. boolean allOpen = siteNavigation.getVertical().getAllOpen();
  10. return new NavigationModel(root, currentNode, getVerticalLevel(), allOpen, rootIsHome);
  11. }

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

  1. public void testAncestorAfterRevert() throws RepositoryException {
  2. superuser.refresh(false);
  3. Item ancestor = grandChildNode.getAncestor(srcParentNode.getDepth());
  4. assertTrue("Reverting a move-operation must move the tree back.", ancestor.isSame(srcParentNode));
  5. }

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

  1. public void testTreeAncestors() throws RepositoryException {
  2. int degree = destParentNode.getDepth();
  3. Item ancestor = childNode.getAncestor(degree);
  4. assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
  5. ancestor = childProperty.getAncestor(degree);
  6. assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
  7. ancestor = grandChildNode.getAncestor(degree);
  8. assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
  9. }

相关文章