本文整理了Java中javax.jcr.Node.getParent()
方法的一些代码示例,展示了Node.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.getParent()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:getParent
暂无
代码示例来源:origin: stackoverflow.com
for (Node parent = anyChildNode; parent.getParent() != null; parent = parent.getParent())
; // this for loop has no body, so an empty statement takes its place
代码示例来源:origin: stackoverflow.com
table.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
Node node = ((Node) event.getTarget()).getParent();
TableRow row;
if (node instanceof TableRow) {
row = (TableRow) node;
} else {
// clicking on text part
row = (TableRow) node.getParent();
}
System.out.println(row.getItem());
}
}
});
代码示例来源:origin: stackoverflow.com
String getXPath(Node node)
{
Node parent = node.getParent();
if (parent == null) {
return "/" + node.getTagName();
}
return getXPath(parent) + "/" + "[@id='" + node.getAttribute("id") + "']";
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Node getParent() throws ItemNotFoundException,
AccessDeniedException, RepositoryException {
return baseNode.getParent();
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
protected boolean nodeMatches(Node node) {
// Only get children (child level 1) below parent path
try {
return StringUtils.equals(parentPath, node.getParent().getPath());
} catch (RepositoryException e) {
return false;
}
}
}
代码示例来源:origin: stackoverflow.com
void rename(Node node, String newName) throws RepositoryException
{
node.getSession().move(node.getPath(), node.getParent().getPath() + "/" + newName);
// Don't forget - not necessarily here at this place:
// node.getSession().save();
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Check if node1 and node2 are siblings.
*/
public static boolean isSameNameSiblings(Node node1, Node node2) throws RepositoryException {
Node parent1 = node1.getParent();
Node parent2 = node2.getParent();
return isSame(parent1, parent2) && node1.getName().equals(node2.getName());
}
代码示例来源:origin: stackoverflow.com
for (Node n: chartBackground.getParent().getChildrenUnmodifiable()) {
if (n != chartBackground && n != xAxis && n != yAxis) {
n.setMouseTransparent(true);
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Convenience - delegate to {@link Node#orderBefore(String, String)}.
*/
public static void orderBefore(Node node, String siblingName) throws RepositoryException {
node.getParent().orderBefore(node.getName(), siblingName);
}
代码示例来源:origin: info.magnolia/magnolia-core
public static boolean isFirstSibling(Node node) throws RepositoryException {
Node parent = node.getParent();
NodeIterator nodes = parent.getNodes();
return isSame(nodes.nextNode(), node);
}
代码示例来源:origin: info.magnolia/magnolia-core
public static void moveNode(Node nodeToMove, Node newParent) throws RepositoryException {
// ignore move request silently if moving within same folder. Such op, although in theory should be void, will fail in JR
// with exception when same name siblings are restricted in NT definition.
if (!newParent.getPath().equals(nodeToMove.getParent().getPath())) {
String newPath = combinePathAndName(newParent.getPath(), nodeToMove.getName());
nodeToMove.getSession().move(nodeToMove.getPath(), newPath);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Orders the node up one step among its siblings. If the node is the only sibling or the first sibling this method
* has no effect.
*/
public static void orderNodeUp(Node node) throws RepositoryException {
Node siblingBefore = getSiblingBefore(node);
if (siblingBefore != null) {
node.getParent().orderBefore(node.getName(), siblingBefore.getName());
}
}
代码示例来源:origin: info.magnolia/magnolia-core
public static void moveNodeBefore(Node nodeToMove, Node target) throws RepositoryException {
Node targetParent = target.getParent();
moveNode(nodeToMove, targetParent);
targetParent.orderBefore(nodeToMove.getName(), target.getName());
}
代码示例来源:origin: info.magnolia/magnolia-core
public static void renameNode(Node node, String newName) throws RepositoryException {
if (node.getName().equals(newName)) {
return;
}
final Node parent = node.getParent();
final String newPath = combinePathAndName(parent.getPath(), newName);
final Node siblingAfter = NodeUtil.getSiblingAfter(node);
node.getSession().move(node.getPath(), newPath);
if (siblingAfter != null) {
parent.orderBefore(newName, siblingAfter.getName());
}
}
代码示例来源: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: info.magnolia/magnolia-core
@Override
protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException {
final Node node = installContext.getJCRSession(repository).getNode(path);
node.getParent().orderBefore(node.getName(), orderBeforeNodeName);
}
代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons
private Node getOrCreateParent(String key) throws RepositoryException {
Node p = getParent(key);
if (treeManager.isRoot(p)) {
Node min = getMinimal();
if (min != null) {
p = min.getParent();
renamePath(p, key);
}
}
return p;
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testNavigatingWithNodeParentStillHidesExcludedNode() throws Exception {
Node unspecified = sessionWrapper.getRootNode().getNode("unspecified");
Node root = unspecified.getParent();
assertFalse(root.hasNode("excluded"));
try {
root.getNode("excluded");
fail();
} catch (PathNotFoundException expected) {
}
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public Content getParent() throws PathNotFoundException, RepositoryException, AccessDeniedException {
Node parentNode = getJCRNode().getParent();
return parentNode == null ? null : new MockContent((MockNode) parentNode);
}
代码示例来源: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;
}
内容来源于网络,如有侵权,请联系作者删除!