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

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

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

Node.getParent介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

  1. for (Node parent = anyChildNode; parent.getParent() != null; parent = parent.getParent())
  2. ; // this for loop has no body, so an empty statement takes its place

代码示例来源:origin: stackoverflow.com

  1. table.setOnMousePressed(new EventHandler<MouseEvent>() {
  2. @Override
  3. public void handle(MouseEvent event) {
  4. if (event.isPrimaryButtonDown() && event.getClickCount() == 2) {
  5. Node node = ((Node) event.getTarget()).getParent();
  6. TableRow row;
  7. if (node instanceof TableRow) {
  8. row = (TableRow) node;
  9. } else {
  10. // clicking on text part
  11. row = (TableRow) node.getParent();
  12. }
  13. System.out.println(row.getItem());
  14. }
  15. }
  16. });

代码示例来源:origin: stackoverflow.com

  1. String getXPath(Node node)
  2. {
  3. Node parent = node.getParent();
  4. if (parent == null) {
  5. return "/" + node.getTagName();
  6. }
  7. return getXPath(parent) + "/" + "[@id='" + node.getAttribute("id") + "']";
  8. }

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

  1. @Override
  2. public Node getParent() throws ItemNotFoundException,
  3. AccessDeniedException, RepositoryException {
  4. return baseNode.getParent();
  5. }

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

  1. @Override
  2. protected boolean nodeMatches(Node node) {
  3. // Only get children (child level 1) below parent path
  4. try {
  5. return StringUtils.equals(parentPath, node.getParent().getPath());
  6. } catch (RepositoryException e) {
  7. return false;
  8. }
  9. }
  10. }

代码示例来源:origin: stackoverflow.com

  1. void rename(Node node, String newName) throws RepositoryException
  2. {
  3. node.getSession().move(node.getPath(), node.getParent().getPath() + "/" + newName);
  4. // Don't forget - not necessarily here at this place:
  5. // node.getSession().save();
  6. }

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

  1. /**
  2. * Check if node1 and node2 are siblings.
  3. */
  4. public static boolean isSameNameSiblings(Node node1, Node node2) throws RepositoryException {
  5. Node parent1 = node1.getParent();
  6. Node parent2 = node2.getParent();
  7. return isSame(parent1, parent2) && node1.getName().equals(node2.getName());
  8. }

代码示例来源:origin: stackoverflow.com

  1. for (Node n: chartBackground.getParent().getChildrenUnmodifiable()) {
  2. if (n != chartBackground && n != xAxis && n != yAxis) {
  3. n.setMouseTransparent(true);

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

  1. /**
  2. * Convenience - delegate to {@link Node#orderBefore(String, String)}.
  3. */
  4. public static void orderBefore(Node node, String siblingName) throws RepositoryException {
  5. node.getParent().orderBefore(node.getName(), siblingName);
  6. }

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

  1. public static boolean isFirstSibling(Node node) throws RepositoryException {
  2. Node parent = node.getParent();
  3. NodeIterator nodes = parent.getNodes();
  4. return isSame(nodes.nextNode(), node);
  5. }

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

  1. public static void moveNode(Node nodeToMove, Node newParent) throws RepositoryException {
  2. // ignore move request silently if moving within same folder. Such op, although in theory should be void, will fail in JR
  3. // with exception when same name siblings are restricted in NT definition.
  4. if (!newParent.getPath().equals(nodeToMove.getParent().getPath())) {
  5. String newPath = combinePathAndName(newParent.getPath(), nodeToMove.getName());
  6. nodeToMove.getSession().move(nodeToMove.getPath(), newPath);
  7. }
  8. }

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

  1. /**
  2. * Orders the node up one step among its siblings. If the node is the only sibling or the first sibling this method
  3. * has no effect.
  4. */
  5. public static void orderNodeUp(Node node) throws RepositoryException {
  6. Node siblingBefore = getSiblingBefore(node);
  7. if (siblingBefore != null) {
  8. node.getParent().orderBefore(node.getName(), siblingBefore.getName());
  9. }
  10. }

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

  1. public static void moveNodeBefore(Node nodeToMove, Node target) throws RepositoryException {
  2. Node targetParent = target.getParent();
  3. moveNode(nodeToMove, targetParent);
  4. targetParent.orderBefore(nodeToMove.getName(), target.getName());
  5. }

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

  1. public static void renameNode(Node node, String newName) throws RepositoryException {
  2. if (node.getName().equals(newName)) {
  3. return;
  4. }
  5. final Node parent = node.getParent();
  6. final String newPath = combinePathAndName(parent.getPath(), newName);
  7. final Node siblingAfter = NodeUtil.getSiblingAfter(node);
  8. node.getSession().move(node.getPath(), newPath);
  9. if (siblingAfter != null) {
  10. parent.orderBefore(newName, siblingAfter.getName());
  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: info.magnolia/magnolia-core

  1. @Override
  2. protected void doExecute(InstallContext installContext) throws RepositoryException, TaskExecutionException {
  3. final Node node = installContext.getJCRSession(repository).getNode(path);
  4. node.getParent().orderBefore(node.getName(), orderBeforeNodeName);
  5. }

代码示例来源:origin: org.apache.jackrabbit/jackrabbit-jcr-commons

  1. private Node getOrCreateParent(String key) throws RepositoryException {
  2. Node p = getParent(key);
  3. if (treeManager.isRoot(p)) {
  4. Node min = getMinimal();
  5. if (min != null) {
  6. p = min.getParent();
  7. renamePath(p, key);
  8. }
  9. }
  10. return p;
  11. }

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

  1. @Test
  2. public void testNavigatingWithNodeParentStillHidesExcludedNode() throws Exception {
  3. Node unspecified = sessionWrapper.getRootNode().getNode("unspecified");
  4. Node root = unspecified.getParent();
  5. assertFalse(root.hasNode("excluded"));
  6. try {
  7. root.getNode("excluded");
  8. fail();
  9. } catch (PathNotFoundException expected) {
  10. }
  11. }
  12. }

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

  1. @Override
  2. public Content getParent() throws PathNotFoundException, RepositoryException, AccessDeniedException {
  3. Node parentNode = getJCRNode().getParent();
  4. return parentNode == null ? null : new MockContent((MockNode) parentNode);
  5. }

代码示例来源: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. }

相关文章