本文整理了Java中javax.jcr.Node.getDepth()
方法的一些代码示例,展示了Node.getDepth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getDepth()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:getDepth
暂无
代码示例来源:origin: org.apache.sling/org.apache.sling.scripting.javascript
public int jsFunction_getDepth() {
try {
return node.getDepth();
} catch (RepositoryException re) {
return -1;
}
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-workflow
public RepositoryWorkflowImpl(Session userSession, Session rootSession, Node subject) throws RemoteException, RepositoryException {
this.session = rootSession;
if(subject.getDepth() == 0)
this.subject = rootSession.getRootNode();
else
this.subject = rootSession.getRootNode().getNode(subject.getPath().substring(1));
}
代码示例来源:origin: info.magnolia/magnolia-rendering
@Override
public int compare(Node lhs, Node rhs) {
try {
if (lhs.getDepth() != rhs.getDepth())
return lhs.getDepth() - rhs.getDepth();
return getSiblingIndex(lhs) - getSiblingIndex(rhs);
} catch (RepositoryException e) {
throw new RuntimeRepositoryException(e);
}
}
代码示例来源:origin: org.overlord.sramp/s-ramp-repository-jcr
/**
* Print this node and its properties to System.out if printing is enabled.
*
* @param node the node to be printed
* @throws RepositoryException
*/
public void printNode( Node node ) throws RepositoryException {
printSubgraph(node, " ", node.getDepth(), 1); //$NON-NLS-1$
}
代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit
public List<Node> ancestorsInSite(Node content, String nodeTypeName) throws RepositoryException {
List<Node> allAncestors = templatingFunctions.ancestors(content, nodeTypeName);
Node siteRoot = siteRoot(content);
List<Node> ancestoresInSite = new ArrayList<Node>();
for (Node current : allAncestors) {
if (current.getDepth() >= siteRoot.getDepth()) {
ancestoresInSite.add(current);
}
}
return ancestoresInSite;
}
代码示例来源:origin: info.magnolia/magnolia-core
private boolean isChildOf(Node child, Node parent) {
try {
return parent.getDepth() == 0 || child.getPath().startsWith(parent.getPath() + "/");
} catch (RepositoryException e) {
throw new RuntimeRepositoryException(e);
}
}
}
代码示例来源:origin: org.wisdom-framework.jcr/wisdom-jcr-core
/**
* Print this node and its properties to System.out if printing is enabled.
*
* @param node the node to be printed
* @throws RepositoryException
*/
public void printNode( Node node ) throws RepositoryException {
printSubgraph(node, " ", node.getDepth(), 1);
}
代码示例来源:origin: apache/jackrabbit
/**
* Test if depth of root node is 0.
*/
public void testGetDepth() throws RepositoryException {
assertEquals("The depth of the root node must be equal to 0.", 0, rootNode.getDepth());
}
代码示例来源:origin: org.onehippo.cms7/hippo-repository-engine
@Override
protected void entering(Node node, int level) throws RepositoryException, SAXException {
final AttributesImpl attrs = new AttributesImpl();
String nodeName;
if (node.getDepth() == 0) {
nodeName = jcrRoot;
} else {
nodeName = node.getName();
}
addAttribute(attrs, SV_NAME, CDATA_TYPE, nodeName);
startElement(NameConstants.SV_NODE, attrs);
}
代码示例来源:origin: org.apache.jackrabbit.vault/org.apache.jackrabbit.vault
/**
* {@inheritDoc}
*/
public boolean includes(Node root, Node node, String path) throws RepositoryException {
if (path == null) {
path = node.getPath();
}
return contentFilter.contains(node, path, PathUtil.getDepth(path) - root.getDepth());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected void exportNode(String uri, String local, Node node) throws RepositoryException, SAXException {
if (node.getDepth() == 0) { //don't include root node
final NodeIterator iterator = node.getNodes();
while (iterator.hasNext()) {
final Node child = iterator.nextNode();
super.exportNode(StringUtils.EMPTY, serializeKey(uri, child.getName()), child); //omit jcr: prefix for all child nodes
}
} else {
super.exportNode(uri, serializeKey(uri, local), node);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Item getAncestor(int depth) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
// at some point we will enter the real hierarchy, so its easiest to loop
Node parent = getParent();
while (parent.getDepth() > depth) {
parent = parent.getParent();
}
return parent;
}
代码示例来源:origin: apache/jackrabbit
/**
* Tests if depth of a property of depth of node + 1
*/
public void testGetDepth() throws RepositoryException {
assertEquals("getDepth() of a property of root must be 1", testRootNode.getDepth() + 1,
property.getDepth());
}
代码示例来源:origin: apache/jackrabbit
/**
* Test if the ancestor at depth = n, where n is the depth of this
* <code>Item</code>, returns this <code>Node</code> itself.
*/
public void testGetAncestorOfNodeDepth() throws RepositoryException {
Node nodeAtDepth = (Node) testRootNode.getAncestor(testRootNode.getDepth());
assertTrue("The ancestor of depth = n, where n is the depth of this " +
"Node must be the item itself.", testRootNode.isSame(nodeAtDepth));
}
代码示例来源:origin: ModeShape/modeshape
protected long countNodes( Node node ) throws RepositoryException {
long count = 1;
NodeIterator iter = node.getNodes();
while (iter.hasNext()) {
Node child = iter.nextNode();
if (child.getDepth() == 1 && child.getName().equals("jcr:system")) continue;
count += countNodes(child);
}
return count;
}
}
代码示例来源:origin: info.magnolia/magnolia-rendering
@Test
public void assertThatRootNodeIsNotCheckedForTemplate() throws Exception {
// GIVEN
final Node root = mock(Node.class);
when(root.getDepth()).thenReturn(0);
// WHEN
templateTypeHelper.findParentWithTemplateType(root, DefaultTemplateTypes.HOME);
// THEN
verify(root, times(1)).getDepth();
verifyNoMoreInteractions(root);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Item getAncestor(int depth) throws RepositoryException {
if (this.getDepth() == depth) {
return this;
}
Node parentNode = this.getParent();
while (parentNode.getDepth() != depth) {
parentNode = parentNode.getParent();
}
return parentNode;
}
代码示例来源:origin: info.magnolia/magnolia-module-standard-templating-kit
private NavigationModel createVerticalNavigation() throws RepositoryException {
int startLevel = siteRoot.getDepth();
boolean rootIsHome = true;
if (isShowHorizontalNavigation()) {
startLevel = getStartLevel();
rootIsHome = false;
}
Node root = (Node) currentNode.getAncestor(startLevel);
boolean allOpen = siteNavigation.getVertical().getAllOpen();
return new NavigationModel(root, currentNode, getVerticalLevel(), allOpen, rootIsHome);
}
代码示例来源:origin: apache/jackrabbit
public void testAncestorAfterRevert() throws RepositoryException {
superuser.refresh(false);
Item ancestor = grandChildNode.getAncestor(srcParentNode.getDepth());
assertTrue("Reverting a move-operation must move the tree back.", ancestor.isSame(srcParentNode));
}
代码示例来源:origin: apache/jackrabbit
public void testTreeAncestors() throws RepositoryException {
int degree = destParentNode.getDepth();
Item ancestor = childNode.getAncestor(degree);
assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
ancestor = childProperty.getAncestor(degree);
assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
ancestor = grandChildNode.getAncestor(degree);
assertTrue("Moving a node must move all child items as well.", ancestor.isSame(destParentNode));
}
内容来源于网络,如有侵权,请联系作者删除!